- Replace all \newcommands with \NewDocumentCommand.

- Add Ragged2e dependency for better alignment options.
- Refine marginalia, widow control.
This commit is contained in:
Silcantar
2025-08-18 22:00:52 -05:00
parent 89340afd62
commit 0c84476fc5
12 changed files with 115 additions and 110 deletions

View File

@@ -4,6 +4,9 @@
% Marginalia formatting.
\colorlet{marginTextColor}{PrimeBlue}
% Allow hyphenation in narrow margin paragraphs.
\RequirePackage{ragged2e}
\RequirePackage{marginalia}
\marginaliasetup{
ysep = {\parskip},
@@ -17,12 +20,12 @@
- \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}},
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][]{%
\NewDocumentCommand{\mdef}{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]{%
@@ -30,28 +33,28 @@
\glsdesc*{#2}% Create the text of the margin note.
}%
}
\newcommand{\margindef}[2][]{%
\NewDocumentCommand{\margindef}{O{} m}{%
\mdef[#1]{#2}{\gls}%
}
\newcommand{\Margindef}[2][]{%
\NewDocumentCommand{\Margindef}{O{} m}{%
\mdef[#1]{#2}{\Gls}%
}
\newcommand{\margindefpl}[2][]{%
\NewDocumentCommand{\margindefpl}{O{} m}{%
\mdef[#1]{#2}{\glspl}%
}
\newcommand{\Margindefpl}[2][]{%
\NewDocumentCommand{\Margindefpl}{O{} m}{%
\mdef[#1]{#2}{\Glspl}%
}
% Put a footnote in a margin paragraph.
\newcommand{\mnote}[2][]{%
\NewDocumentCommand{\mnote}{O{} +m}{%
\footnotemark%
\marginalia[#1]{%
\footnotemark[\value{footnote}]#2%
}%
}
\newcommand{\marginfig}[4][]{%
\NewDocumentCommand{\marginfig}{O{} m m +m}{%
% Syntax:
% \marginfig[
% (width|height)=lengthvalue, or any other optional \includegraphics
@@ -70,10 +73,10 @@
\marginalia{%
\captionsetup{%
type = figure,%
%justification = raggedoutside,
justification = RaggedOutside,%
}%
\centering\includegraphics[keepaspectratio,#1]{#2}\par%
\captionof{figure}{#4}%
\Centering\includegraphics[keepaspectratio,#1]{#2}\par%
\noindent\captionof{figure}{#4}%
\label{fig:#3}%
}%
}