From 40b8836e51e57a33ac3b92692341b572ebb01af4 Mon Sep 17 00:00:00 2001 From: Joshua Lucas Date: Wed, 9 Jul 2025 17:26:06 -0500 Subject: [PATCH] - Add full-width float macros. - Add reference macros. - Add versions of marginfig and centerfig that allow custom widths. --- PrimeManual.sty | 101 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 78 insertions(+), 23 deletions(-) diff --git a/PrimeManual.sty b/PrimeManual.sty index ff73e72..06eac78 100644 --- a/PrimeManual.sty +++ b/PrimeManual.sty @@ -61,6 +61,32 @@ % Page Layout %#region \RequirePackage[pass]{geometry} + \RequirePackage{calc} + \RequirePackage{ifoddpage} + + \newlength{\contentwidth} + \setlength{\contentwidth}{\textwidth+\marginparsep+\marginparwidth} + + \newlength{\bfFigureWidth} + \newlength{\bfMarginOffset} + \newcommand{\bigfloat}[2][1in]{% + \setlength{\bfFigureWidth}{#1*-2+\paperwidth}% + \checkoddpage% + \ifoddpage% + \setlength{\bfMarginOffset}{-1in+#1-\oddsidemargin}% + \else% + \setlength{\bfMarginOffset}{-1in+#1-\evensidemargin}% + \fi% + \begin{figure}[ht]% + {\leavevmode% + \put(\bfMarginOffset,0in){% + \begin{minipage}{\bfFigureWidth}% + #2% + \end{minipage}% + }% + }% + \end{figure}% + } %#endregion % Title & Heading Options @@ -79,15 +105,18 @@ \definecolor{PrimeBlue}{RGB}{25,45,145} %#endregion -% Use Hyperref to automatically create links in the document -%#region - \RequirePackage{hyperref} - \hypersetup{colorlinks=true, allcolors=PrimeBlue} -%#endregion - % Cross references %#region %\newcommand{\sectionRef}[2]{\ref{#1:#2}: #2} + \newcommand{\refChapter}[1]{Chapter \ref{ch:#1}} + \newcommand{\refAppendix}[1]{Appendix \ref{ch:#1}} + \newcommand{\refSection}[1]{Section \ref{sec:#1}} + \newcommand{\refSubsection}[1]{Subsection \ref{subsec:#1}} + \newcommand{\refSubsubsection}[1]{Sub-subsection \ref{sssec:#1}} + \newcommand{\refParagraph}[1]{Paragraph \ref{par:#1}} + \newcommand{\refSubparagraph}[1]{Subparagraph \ref{subpar:#1}} + \newcommand{\refTable}[1]{Table \ref{tbl:#1}} + \newcommand{\refFigure}[1]{Figure \ref{fig:#1}} \newcommand{\lblGeneral}[4][]{ \if\relax\detokenize{#1}\relax % Check if #1 is empty string. @@ -125,18 +154,30 @@ % Graphics package for including images %#region \RequirePackage{graphicx} + \RequirePackage[hypcap=true]{caption} \newcommand{\ig}[2][0.5in]{ - \includegraphics[keepaspectratio,width=#1]{graphics/#2} + \includegraphics[keepaspectratio,width=#1]{#2} } - \newcommand{\centerfig}[3]{ - \begin{figure}[ht] - \centering - \includegraphics{graphics/#1} - \caption{#3} - \label{fig:#2} - \end{figure} + \newcommand{\cfig}[4]{% + \begin{figure}[ht]% + \centering% + #4{#1}% + \caption{#3}% + \label{fig:#2}% + \end{figure}% + } + \newcommand{\centerfig}[3]{\cfig{#1}{#2}{#3}{\includegraphics}} + \newcommand{\centerfigw}[4][\textwidth]{\cfig{#2}{#3}{#4}{\includegraphics[keepaspectratio,width=#1]}} + + \newcommand{\bigfig}[4][1in]{% + \bigfloat[#1]{% + \captionsetup{type=figure}% + \includegraphics[keepaspectratio,width=\bfFigureWidth]{#2}% + \captionof{figure}{#4}% + \label{fig:#3}% + }% } %#endregion @@ -154,7 +195,7 @@ % Glossary formatting. %#region - \RequirePackage[nopostdot,toc,sort=standard]{glossaries} + \RequirePackage[xindy,nopostdot,toc,sort=standard]{glossaries} %#endregion % Index formatting. @@ -198,23 +239,37 @@ }[#1]% } - \RequirePackage[hypcap=true]{caption} - \newcommand{\marginfig}[4][0pt]{% + \newcommand{\mfig}[5][0pt]{% + % This strut ensures that the margin figure is counted as part of the + % following paragraph and is vertically aligned with it. + \strut% \marginnote{% \captionsetup{% type = figure,% font = {color=marginTextColor},% }% - {\centering\includegraphics{graphics/#2}\par}% - \captionof{figure}{#4}\label{fig:#3}% + {\centering#5{#2}\par}% + \captionof{figure}{#4}% + \label{fig:#3}% }[#1]% } + \newcommand{\marginfig}[4][0pt]{% + \mfig[#1]{#2}{#3}{#4}{\includegraphics}% + } + \newcommand{\marginfigw}[5][0pt]{% + \mfig[#1]{#2}{#3}{#4}{\includegraphics[keepaspectratio,width=#5]}% + } +%#endregion + +% Use Hyperref to automatically create links in the document +%#region + \RequirePackage{hyperref} + \hypersetup{colorlinks=true, allcolors=PrimeBlue} %#endregion % Define custom title page. %#region -\RequirePackage{calc} -\newcommand{\PrimeTitlePage}{ +\newcommand{\PrimeTitlePage}[1]{ \begin{titlepage} \begin{sffamily} {\raggedright\noindent\large @@ -230,11 +285,11 @@ % Move the rule graphic to 0.25 in from the left edge of the % paper and vertically centered on the heartbeat graphic. \put(-\oddsidemargin-0.75in,10pt){ - \includegraphics{graphics/title/prime_rule.pdf} + \includegraphics{#1/prime_rule.pdf} } % The numbers here are just what looks good. \put(100pt,0pt){ - \includegraphics{graphics/title/prime_heartbeat.pdf} + \includegraphics{#1/prime_heartbeat.pdf} } }