Add marginfig macro.

This commit is contained in:
Silcantar
2025-07-07 22:23:46 -05:00
parent db32ca3235
commit 73cdafc93b

View File

@@ -1,225 +1,244 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{latex-templates/PrimeManual}[2025-06-24]
% Suppress warning about \showhyphens being changed.
\let\CheckCommand\providecommand
\RequirePackage{microtype}
% Custom document properties.
%#region
\DeclareRobustCommand*{\customer}[1]{\gdef\@customer{#1}}
\DeclareRobustCommand*{\customerFull}[1]{\gdef\@customerFull{#1}}
\DeclareRobustCommand*{\projectNumber}[1]{\gdef\@projectNumber{#1}}
\DeclareRobustCommand*{\projectDesc}[1]{\gdef\@projectDesc{#1}}
\DeclareRobustCommand*{\version}[1]{\gdef\@version{#1}}
%#endregion
% Macros to insert document properties.
%#region
\newcommand{\sTitle}{\makeatletter{\@title}}
\newcommand{\sAuthor}{\makeatletter{\@author}}
\newcommand{\sDate}{\makeatletter{\@date}}
\newcommand{\sCustomer}{\makeatletter{\@customer}}
\newcommand{\sCustomerFull}{\makeatletter{\@customerFull}}
\newcommand{\sProjectNumber}{\makeatletter{\@projectNumber}}
\newcommand{\sProjectDesc}{\makeatletter{\@projectDesc}}
\newcommand{\sProjectTitle}{\makeatletter{Project \@projectNumber : \@projectDesc}}
\newcommand{\sVersion}{\makeatletter{\@version}}
%#endregion
% Specify Fonts
%#region
\RequirePackage{fontspec}
% Main font: Roboto Serif
\setmainfont{RobotoSerif}[
Path = ./fonts/RobotoSerif/,
Extension = .ttf,
UprightFont = *-Light,
BoldFont = *-SemiBold,
ItalicFont = *-LightItalic,
BoldItalicFont = *-SemiBoldItalic,
]
% Headings & Titles font: Roboto Slab
\setsansfont{RobotoSlab}[
Path = ./fonts/RobotoSlab/,
Extension = .ttf,
UprightFont = *-SemiBold,
BoldFont = *-Black,
]
% Monospace font: Roboto Mono
\setmonofont{RobotoMono}[
Path = ./fonts/RobotoMono/,
Extension = .ttf,
UprightFont = *-Regular,
BoldFont = *-Bold,
ItalicFont = *-Italic,
BoldItalicFont = *-BoldItalic,
]
%#endregion
% Page Layout
%#region
\RequirePackage[pass]{geometry}
%#endregion
% Title & Heading Options
%#region
\RequirePackage[sf,raggedright]{titlesec}
%#endregion
% Header & Footer Options
%#region
\pagestyle{plain}
%#endregion
% Color import and definition
%#region
\RequirePackage{xcolor}
\definecolor{PrimeBlue}{RGB}{25,45,145}
%#endregion
% Use Hyperref to automatically create links in the document
%#region
\RequirePackage{hyperref}
\hypersetup{colorlinks=true, allcolors=PrimeBlue}
%#endregion
% Graphics package for including images
%#region
\RequirePackage{graphicx}
\RequirePackage{calc}
%#endregion
% Define custom title page.
%#region
\newcommand{\PrimeTitlePage}{
\begin{titlepage}
\begin{sffamily}
{\raggedright\noindent\large
\vspace*{\stretch{1}}
\sCustomerFull
\medbreak
\sProjectTitle
\bigbreak
{\Huge \sTitle}
\vfill
{\leavevmode
% Move the rule graphic to 0.25 in from the left edge of the
% paper and vertically centered on the heartbeat graphic.
\put(-\oddsidemargin-0.75in,10pt){
\includegraphics{graphics/prime_rule.pdf}
}
% The numbers here are just what looks good.
\put(100pt,0pt){
\includegraphics{graphics/prime_heartbeat.pdf}
}
}
\sAuthor
Revision \sVersion
\sDate
\vfill
}
\end{sffamily}
\end{titlepage}
}
%#endregion
% Paragraph formatting.
%#region
\setlength{\parindent}{0pt}
\setlength{\parskip}{2ex plus 0.5ex minus 0.5ex}
%#endregion
% Table formatting.
%#region
%\renewcommand{\arraystretch}{1.5}
\RequirePackage{csvsimple}
\RequirePackage{longtable}
\RequirePackage{colortbl}
\RequirePackage{booktabs}
\RequirePackage{tabularray}
\newcommand{\bandedrows}{\rowcolors{2}{white}{gray!10}}
%#endregion
% Glossary formatting.
%#region
\RequirePackage[nopostdot,toc,sort=standard]{glossaries}
%#endregion
% Index formatting.
%#region
\RequirePackage{makeidx}
\RequirePackage{xstring}
\newcommand{\idx}[1]{\StrSubstitute{#1}{!}{ }\index{#1}}
%#endregion
% Margin Note formatting.
%#region
\RequirePackage{marginnote}
% -38pt seems to be just the right vertical adjustment to align margin notes
% with the reference in the text.
%\renewcommand{\marginnotevadjust}{-38pt}
\renewcommand{\marginfont}{\small\color{PrimeBlue}}
% Title formatting for margin notes.
\newcommand{\margintitle}[1]{\paragraph{\textbf{#1}}}
% Put a glossary definition in a margin note.
% Optional parameter is vertical adjustment of the note.
\newcommand{\margindef}[2][0pt]{%
\index{\glsentryname{#2}}% Add a reference to this in the index.
\textbf{\gls{#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}}[#1]% Create the text of the margin note.
}
% 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]}
%#endregion
% Cross references
%#region
\newcommand{\sectionRef}[3][]{#1 \ref{#2:#3}: #3}
\newcommand{\lblGeneral}[4][]{
\if\relax\detokenize{#1}\relax % Check if #1 is empty string.
#3{#2}\label{#4:#2}
\else
#3{#2}\label{#4:#1}
\fi
}
\newcommand{\lblChapter}[2][]{
\lblGeneral[#1]{#2}{\chapter}{ch}
}
\newcommand{\lblSection}[2][]{
\lblGeneral[#1]{#2}{\section}{sec}
}
\newcommand{\lblSubsection}[2][]{
\lblGeneral[#1]{#2}{\subsection}{subsec}
}
\newcommand{\lblSubsubsection}[2][]{
\lblGeneral[#1]{#2}{\subsubsection}{sssec}
}
\newcommand{\lblParagraph}[2][]{
\lblGeneral[#1]{#2}{\paragraph}{par}
}
\newcommand{\lblSubparagraph}[2][]{
\lblGeneral[#1]{#2}{\subparagraph}{subpar}
}
\newcommand{\lblTable}[2][]{
\textbf{\lblGeneral[#1]{#2}{\caption}{tbl}}
}
\newcommand{\lblFigure}[2][]{
\textbf{\lblGeneral[#1]{#2}{\caption}{fig}}
}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{latex-templates/PrimeManual}[2025-06-24]
% Suppress warning about \showhyphens being changed.
\let\CheckCommand\providecommand
\RequirePackage{microtype}
% Custom document properties.
%#region
\DeclareRobustCommand*{\customer}[1]{\gdef\@customer{#1}}
\DeclareRobustCommand*{\customerFull}[1]{\gdef\@customerFull{#1}}
\DeclareRobustCommand*{\projectNumber}[1]{\gdef\@projectNumber{#1}}
\DeclareRobustCommand*{\projectDesc}[1]{\gdef\@projectDesc{#1}}
\DeclareRobustCommand*{\version}[1]{\gdef\@version{#1}}
%#endregion
% Macros to insert document properties.
%#region
\newcommand{\sTitle}{\makeatletter{\@title}}
\newcommand{\sAuthor}{\makeatletter{\@author}}
\newcommand{\sDate}{\makeatletter{\@date}}
\newcommand{\sCustomer}{\makeatletter{\@customer}}
\newcommand{\sCustomerFull}{\makeatletter{\@customerFull}}
\newcommand{\sProjectNumber}{\makeatletter{\@projectNumber}}
\newcommand{\sProjectDesc}{\makeatletter{\@projectDesc}}
\newcommand{\sProjectTitle}{\makeatletter{Project \@projectNumber : \@projectDesc}}
\newcommand{\sVersion}{\makeatletter{\@version}}
%#endregion
% Specify Fonts
%#region
\RequirePackage{fontspec}
% Main font: Roboto Serif
\setmainfont{RobotoSerif}[
Path = ./fonts/RobotoSerif/,
Extension = .ttf,
UprightFont = *-Light,
BoldFont = *-SemiBold,
ItalicFont = *-LightItalic,
BoldItalicFont = *-SemiBoldItalic,
]
% Headings & Titles font: Roboto Slab
\setsansfont{RobotoSlab}[
Path = ./fonts/RobotoSlab/,
Extension = .ttf,
UprightFont = *-SemiBold,
BoldFont = *-Black,
]
% Monospace font: Roboto Mono
\setmonofont{RobotoMono}[
Path = ./fonts/RobotoMono/,
Extension = .ttf,
UprightFont = *-Regular,
BoldFont = *-Bold,
ItalicFont = *-Italic,
BoldItalicFont = *-BoldItalic,
]
%#endregion
% Page Layout
%#region
\RequirePackage[pass]{geometry}
%#endregion
% Title & Heading Options
%#region
\RequirePackage[sf,raggedright]{titlesec}
%#endregion
% Header & Footer Options
%#region
\pagestyle{plain}
%#endregion
% Color import and definition
%#region
\RequirePackage{xcolor}
\definecolor{PrimeBlue}{RGB}{25,45,145}
%#endregion
% Use Hyperref to automatically create links in the document
%#region
\RequirePackage{hyperref}
\hypersetup{colorlinks=true, allcolors=PrimeBlue}
%#endregion
% Graphics package for including images
%#region
\RequirePackage{graphicx}
\RequirePackage{calc}
%#endregion
% Define custom title page.
%#region
\newcommand{\PrimeTitlePage}{
\begin{titlepage}
\begin{sffamily}
{\raggedright\noindent\large
\vspace*{\stretch{1}}
\sCustomerFull
\medbreak
\sProjectTitle
\bigbreak
{\Huge \sTitle}
\vfill
{\leavevmode
% Move the rule graphic to 0.25 in from the left edge of the
% paper and vertically centered on the heartbeat graphic.
\put(-\oddsidemargin-0.75in,10pt){
\includegraphics{graphics/prime_rule.pdf}
}
% The numbers here are just what looks good.
\put(100pt,0pt){
\includegraphics{graphics/prime_heartbeat.pdf}
}
}
\sAuthor
Revision \sVersion
\sDate
\vfill
}
\end{sffamily}
\end{titlepage}
}
%#endregion
% Paragraph formatting.
%#region
\setlength{\parindent}{0pt}
\setlength{\parskip}{2ex plus 0.5ex minus 0.5ex}
%#endregion
% Table formatting.
%#region
%\renewcommand{\arraystretch}{1.5}
\RequirePackage{csvsimple}
\RequirePackage{longtable}
\RequirePackage{colortbl}
\RequirePackage{booktabs}
\RequirePackage{tabularray}
\newcommand{\bandedrows}{\rowcolors{2}{white}{gray!10}}
%#endregion
% Glossary formatting.
%#region
\RequirePackage[nopostdot,toc,sort=standard]{glossaries}
%#endregion
% Index formatting.
%#region
\RequirePackage{makeidx}
\RequirePackage{xstring}
\newcommand{\idx}[1]{\StrSubstitute{#1}{!}{ }\index{#1}}
%#endregion
% Margin Note formatting.
%#region
\RequirePackage{marginnote}
% -38pt seems to be just the right vertical adjustment to align margin notes
% with the reference in the text.
%\renewcommand{\marginnotevadjust}{-38pt}
\renewcommand{\marginfont}{\small\color{PrimeBlue}}
% Title formatting for margin notes.
%\newcommand{\margintitle}[1]{\paragraph{\textbf{#1}}}
% Put a glossary definition in a margin note.
% Optional parameter is vertical adjustment of the note.
\newcommand{\margindef}[2][0pt]{%
\index{\glsentryname{#2}}% Add a reference to this in the index.
\textbf{\gls{#2}}% This is the text that appears on the page.
\marginnote{% Create the margin note.
%\marginfont
\textsf{\textbf{
\Glsentryname{#2}:% Create the title of the margin note.
}}
\glsdesc*{#2}
}[#1]% Create the text of the margin note.
}
% Put a footnote in a margin note.
% Optional parameter is vertical adjustment of the note.
\newcommand{\mnote}[2][0pt]{%
\footnotemark
\marginnote{
%\marginfont
\footnotemark[\value{footnote}]#2}[#1]
}
\RequirePackage[hypcap=true]{caption}
\newcommand{\marginfig}[2]{%
\marginnote{
%\marginfont
\captionsetup{type=figure}
\begin{center}
\includegraphics{#1}
\end{center}
\captionof{figure}{#2}
}
}
%#endregion
% Cross references
%#region
\newcommand{\sectionRef}[3][]{#1 \ref{#2:#3}: #3}
\newcommand{\lblGeneral}[4][]{
\if\relax\detokenize{#1}\relax % Check if #1 is empty string.
#3{#2}\label{#4:#2}
\else
#3{#2}\label{#4:#1}
\fi
}
\newcommand{\lblChapter}[2][]{
\lblGeneral[#1]{#2}{\chapter}{ch}
}
\newcommand{\lblSection}[2][]{
\lblGeneral[#1]{#2}{\section}{sec}
}
\newcommand{\lblSubsection}[2][]{
\lblGeneral[#1]{#2}{\subsection}{subsec}
}
\newcommand{\lblSubsubsection}[2][]{
\lblGeneral[#1]{#2}{\subsubsection}{sssec}
}
\newcommand{\lblParagraph}[2][]{
\lblGeneral[#1]{#2}{\paragraph}{par}
}
\newcommand{\lblSubparagraph}[2][]{
\lblGeneral[#1]{#2}{\subparagraph}{subpar}
}
\newcommand{\lblTable}[2][]{
\textbf{\lblGeneral[#1]{#2}{\caption}{tbl}}
}
\newcommand{\lblFigure}[2][]{
\textbf{\lblGeneral[#1]{#2}{\caption}{fig}}
}
%#endregion