- Add Hyphenation package. - Make margin figure caption ragged right/left depending on page.
71 lines
1.8 KiB
TeX
71 lines
1.8 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.
|
|
\textsf{\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{\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{%
|
|
\checkoddpage%
|
|
\ifthenelse{\boolean{oddpage}}{%
|
|
\captionsetup{%
|
|
type = figure,%
|
|
font = {color=marginTextColor},%
|
|
justification = raggedright,%
|
|
}%
|
|
}{%
|
|
\captionsetup{%
|
|
type = figure,%
|
|
font = {color=marginTextColor},%
|
|
justification = raggedleft,%
|
|
}%
|
|
}%
|
|
{\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 |