Files
PrimeTeX/MarginNotes.sty

65 lines
1.7 KiB
TeX

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{PrimeTeX/MarginNotes}[2025-07-09]
% Margin Note formatting.
%#region
\RequirePackage{marginnote}
\colorlet{marginTextColor}{PrimeBlue}
\renewcommand{\marginfont}{\small\color{marginTextColor}}
% Put a glossary definition in a margin note.
% Optional parameter is vertical adjustment of the note.
\newcommand{\mdef}[3][0pt]{%
\index{\glsentryname{#2}}% Add a reference to this in the index.
\textbf{#3{#2}}% This is the text that appears on the page.
\marginnote{% Create the margin note.
{\sbfamily\textbf{%
\Glsentryname{#2}:% Create the title of the margin note.
}}%
\glsdesc*{#2}% Create the text of the margin note.
}[#1]%
}
\newcommand{\margindef}[2][0pt]{%
\mdef[#1]{#2}{\gls}%
}
\newcommand{\Margindef}[2][0pt]{%
\mdef[#1]{#2}{\Gls}%
}
% Put a footnote in a margin note.
% Optional parameter is vertical adjustment of the note.
\newcommand{\mnote}[2][0pt]{%
\footnotemark%
\marginnote{%
\footnotemark[\value{footnote}]#2%
}[#1]%
}
\RequirePackage{changepage}
\RequirePackage{ifthen}
\newcommand{\marginfig}[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{%
\checkoddpage%
\ifthenelse{\boolean{oddpage}}{%
\captionsetup{%
type = figure,%
font = {color=marginTextColor},%
justification = raggedright,%
}%
}{%
\captionsetup{%
type = figure,%
font = {color=marginTextColor},%
justification = raggedleft,%
}%
}%
{\centering\includegraphics[keepaspectratio,#3]{#2}\par}%
\captionof{figure}{#5}%
\label{fig:#4}%
}[#1]%
}
%#endregion