Files
PrimeTeX/packages/Marginalia.sty
Silcantar c914902f59 - Add custom header/footer.
- Add option to generate files optimized for either print or electronic reading.
2025-08-17 22:29:41 -05:00

79 lines
1.8 KiB
TeX

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{PrimeTeX/packages/Marginalia}[2025-07-09]
% Marginalia formatting.
\colorlet{marginTextColor}{PrimeBlue}
\RequirePackage{marginalia}
\marginaliasetup{
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}},
}
% Put a glossary definition in a margin paragraph.
\newcommand{\mdef}[3][]{%
\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]{%
\strong{\Glsentryname{#2}:} % Create the title of the margin note.
\glsdesc*{#2}% Create the text of the margin note.
}%
}
\newcommand{\margindef}[2][]{%
\mdef[#1]{#2}{\gls}%
}
\newcommand{\Margindef}[2][]{%
\mdef[#1]{#2}{\Gls}%
}
\newcommand{\margindefpl}[2][]{%
\mdef[#1]{#2}{\glspl}%
}
\newcommand{\Margindefpl}[2][]{%
\mdef[#1]{#2}{\Glspl}%
}
% Put a footnote in a margin paragraph.
\newcommand{\mnote}[2][]{%
\footnotemark%
\marginalia[#1]{%
\footnotemark[\value{footnote}]#2%
}%
}
\newcommand{\marginfig}[4][]{%
% Syntax:
% \marginfig[
% (width|height)=lengthvalue, or any other optional \includegraphics
% parameters
% ]{
% graphic_file_name
% }{
% label
% }{
% caption
% }
%
% This strut ensures that the margin figure is counted as part of the
% following paragraph and is vertically aligned with it.
\strut%
\marginalia{%
\captionsetup{%
type = figure,%
%justification = raggedoutside,
}%
\centering\includegraphics[keepaspectratio,#1]{#2}\par%
\captionof{figure}{#4}%
\label{fig:#3}%
}%
}