Files
PrimeTeX/packages/Marginalia.sty
Joshua Lucas 5e578de497 - Change underscores in file names to hyphens.
- Make color names clearer.
- Clean up commonincludes.
2025-09-15 17:00:34 -05:00

86 lines
2.1 KiB
TeX

\NeedsTeXFormat{LaTeX2e}
\ProvidesExplPackage{PrimeTeX/packages/Marginalia}{2025-09-12}{1.0}{
Marginalia commands.
}
\marginaliasetup{
width = {\marginparwidth},
xsep = {\marginparsep},
ysep = {\parskip},
ysep~page~bottom = {
- 1in % Top gutter
+ \paperheight
- \voffset
- \topmargin
- \headheight
- \headsep
- \textheight
},
yshift = {7pt}, % Just a magic number that lines up margin notes with their reference.
style~recto~outer = {\RaggedRight\small\color{marginTextColor}},
style~verso~outer = {\RaggedLeft\small\color{marginTextColor}},
}
\NewDocumentCommand{\MarginHyperSetup}{}{
\ifthenelse{\boolean{isElectronic}}{
\hypersetup{allcolors = linkColor}
}{
\hypersetup{allcolors = marginTextColor}
}
}
% Put a glossary definition in a margin paragraph.
\NewDocumentCommand{\@MarginDef}{O{} m m}{%
\index{\glsentryname{#2}}% Add a reference to this in the index.
\strong{#3{#2}}% This is the text that appears on the page.
\marginalia[#1]{%
\MarginHyperSetup%
\strong{\Glsentryname{#2}:}% Create the title of the margin note.
\enspace\glsdesc*{#2}% Create the text of the margin note.
}%
}
\NewDocumentCommand{\MarginDef}{O{} m}{%
\@MarginDef[#1]{#2}{\gls}%
}
\NewDocumentCommand{\MarginDefCap}{O{} m}{%
\@MarginDef[#1]{#2}{\Gls}%
}
\NewDocumentCommand{\MarginDefPl}{O{} m}{%
\@MarginDef[#1]{#2}{\glspl}%
}
\NewDocumentCommand{\MarginDefCapPl}{O{} m}{%
\@MarginDef[#1]{#2}{\Glspl}%
}
% Put a footnote in a margin paragraph.
\NewDocumentCommand{\MarginNote}{O{} +m}{%
\footnotemark%
\marginalia[#1]{%
\MarginHyperSetup%
\footnotemark[\value{footnote}]#2%
}%
}
\NewDocumentCommand{\MarginFig}{
% #1: Options passed to \includegraphics.
O{}
% #2: Graphic file name.
m
% #3: Label.
>{\TrimSpaces}m
+m
}{
% This strut ensures that the margin figure is counted as part of the
% following paragraph and is vertically aligned with it.
%\strut {\setlength{\parskip}{0pt} \par} \strut
\mbox{
\marginalia{
\MarginHyperSetup
\begin{MyCaption}[
format={\RaggedOutside\small\color{captionColor}}
]{fig:#3}{#4}
\Centering\includegraphics[keepaspectratio,#1]{#2}
\end{MyCaption}
}
}
}