- 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

@@ -40,7 +40,7 @@
\colorlet{boxedcoloroutline}{black}
\newcommand{\boxedcolor}[3][\rule{0pt}{1ex}\rule{1ex}{0pt}]{%
\NewDocumentCommand{\boxedcolor}{O{\rule{0pt}{1ex}\rule{1ex}{0pt}} m m}{%
\providelength[\fboxsep]{\fboxsepdefault}%
\providelength[\fboxrule]{\fboxruledefault}%
%
@@ -55,7 +55,7 @@
\providelength[12.3599pt]{\warningboxsizeoffset}
\newcommand{\warningbox}[2][\textwidth - \warningboxsizeoffset]{%
\NewDocumentCommand{\warningbox}{O{\textwidth-\warningboxsizeoffset} +m}{%
\noindent%
\fcolorbox{WarningBoxFGColor}{WarningBoxBGColor}{%
\noindent%

View File

@@ -2,48 +2,48 @@
\ProvidesPackage{PrimeTeX/packages/CrossRef}[2025-07-09]
% Cross references
\newcommand{\refPart}[2][Part~]{#1\ref{pt:#2}}
\newcommand{\refChapter}[2][Chapter~]{#1\ref{ch:#2}}
\newcommand{\refAppendix}[2][Appendix~]{#1\ref{ch:#2}}
\newcommand{\refSection}[2][Section~]{#1\ref{sec:#2}}
\newcommand{\refSubsection}[2][Subsection~]{#1\ref{subsec:#2}}
\newcommand{\refSubsubsection}[2][Sub-subsection~]{#1\ref{sssec:#2}}
\newcommand{\refParagraph}[2][Paragraph]{#1\ref{par:#2}}
\newcommand{\refSubparagraph}[2][Subparagraph~]{#1\ref{subpar:#2}}
\newcommand{\refTable}[2][Table~]{#1\ref{tbl:#2}}
\newcommand{\refFigure}[2][Figure~]{#1\ref{fig:#2}}
\NewDocumentCommand{\refPart}{O{Part~} m}{#1\ref{pt:#2}}
\NewDocumentCommand{\refChapter}{O{Chapter~} m}{#1\ref{ch:#2}}
\NewDocumentCommand{\refAppendix}{O{Appendix~} m}{#1\ref{ch:#2}}
\NewDocumentCommand{\refSection}{O{Section~} m}{#1\ref{sec:#2}}
\NewDocumentCommand{\refSubsection}{O{Subsection~} m}{#1\ref{subsec:#2}}
\NewDocumentCommand{\refSubsubsection}{O{Sub-subsection~} m}{#1\ref{sssec:#2}}
\NewDocumentCommand{\refParagraph}{O{Paragraph} m}{#1\ref{par:#2}}
\NewDocumentCommand{\refSubparagraph}{O{Subparagraph~} m}{#1\ref{subpar:#2}}
\NewDocumentCommand{\refTable}{O{Table~} m}{#1\ref{tbl:#2}}
\NewDocumentCommand{\refFigure}{O{Figure~} m}{#1\ref{fig:#2}}
\newcommand{\lblGeneral}[4][]{
\NewDocumentCommand{\lblGeneral}{>{\TrimSpaces}O{} >{\TrimSpaces}m m >{\TrimSpaces}m}{
\if\relax\detokenize{#1}\relax % Check if #1 is empty string.
#3{#2}\label{#4:#2}
\else
#3{#2}\label{#4:#1}
\fi
}
\newcommand{\lblPart}[2][]{
\NewDocumentCommand{\lblPart}{O{} m}{
\lblGeneral[#1]{#2}{\part}{pt}
}
\newcommand{\lblChapter}[2][]{
\NewDocumentCommand{\lblChapter}{O{} m}{
\lblGeneral[#1]{#2}{\chapter}{ch}
}
\newcommand{\lblSection}[2][]{
\NewDocumentCommand{\lblSection}{O{} m}{
\lblGeneral[#1]{#2}{\section}{sec}
}
\newcommand{\lblSubsection}[2][]{
\NewDocumentCommand{\lblSubsection}{O{} m}{
\lblGeneral[#1]{#2}{\subsection}{subsec}
}
\newcommand{\lblSubsubsection}[2][]{
\NewDocumentCommand{\lblSubsubsection}{O{} m}{
\lblGeneral[#1]{#2}{\subsubsection}{sssec}
}
\newcommand{\lblParagraph}[2][]{
\NewDocumentCommand{\lblParagraph}{O{} m}{
\lblGeneral[#1]{#2}{\paragraph}{par}
}
\newcommand{\lblSubparagraph}[2][]{
\NewDocumentCommand{\lblSubparagraph}{O{} m}{
\lblGeneral[#1]{#2}{\subparagraph}{subpar}
}
\newcommand{\lblTable}[2][]{
\NewDocumentCommand{\lblTable}{O{} m}{
\lblGeneral[#1]{#2}{\caption}{tbl}
}
\newcommand{\lblFigure}[2][]{
\NewDocumentCommand{\lblFigure}{O{} m}{
\lblGeneral[#1]{#2}{\caption}{fig}
}

View File

@@ -9,13 +9,13 @@
\DeclareRobustCommand*{\version}[1]{\gdef\@version{#1}}
% Macros to insert document properties.
\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}}
\NewDocumentCommand{\sTitle}{}{\makeatletter{\@title}}
\NewDocumentCommand{\sAuthor}{}{\makeatletter{\@author}}
\NewDocumentCommand{\sDate}{}{\makeatletter{\@date}}
\NewDocumentCommand{\sCustomer}{}{\makeatletter{\@customer}}
\NewDocumentCommand{\sCustomerFull}{}{\makeatletter{\@customerFull}}
\NewDocumentCommand{\sProjectNumber}{}{\makeatletter{\@projectNumber}}
\NewDocumentCommand{\sProjectDesc}{}{\makeatletter{\@projectDesc}}
\NewDocumentCommand{\sProjectTitle}{}{\makeatletter{Project \@projectNumber : \@projectDesc}}
\NewDocumentCommand{\sVersion}{}{\makeatletter{\@version}}
%#endregion

View File

@@ -4,7 +4,7 @@
% Specify Fonts
\RequirePackage{fontspec}
\newcommand{\fontpath}{PrimeTeX/fonts}
\NewDocumentCommand{\fontpath}{}{PrimeTeX/fonts}
% Main font: Roboto Serif
\setmainfont{RobotoSerif}[
@@ -48,13 +48,13 @@
BoldItalicFont = RobotoSerif/RobotoSerif-ExtraBoldItalic,
]
\newcommand{\serif}[1]{\textrm{#1}}
\newcommand{\sans}[1]{\textsf{#1}}
\newcommand{\mono}[1]{\texttt{#1}}
\newcommand{\slab}[1]{{\sbfamily{}#1}}
\newcommand{\code}[1]{\mono{\small{}#1}}
\NewDocumentCommand{\serif}{m}{\textrm{#1}}
\NewDocumentCommand{\sans}{m}{\textsf{#1}}
\NewDocumentCommand{\mono}{m}{\texttt{#1}}
\NewDocumentCommand{\slab}{m}{{\sbfamily{}#1}}
\NewDocumentCommand{\code}{m}{\mono{\small{}#1}}
\newcommand{\objref}[1]{{\sans{\strong{#1}}}}
\NewDocumentCommand{\objref}{m}{{\sans{\strong{#1}}}}
\RequirePackage{amssymb}

View File

@@ -10,7 +10,7 @@
hypcap=true,
]{caption}
\captionsetup{
justification = centering,
justification = Centering,
font = {
small,
color=PrimeBlue,
@@ -18,59 +18,62 @@
}
% Define a justification style that is ragged on the side toward the outside of
% the page. I. e.
% the page. I. e. RaggedRight on
\RequirePackage{changepage}
%\RequirePackage{ifthen}
\DeclareCaptionJustification{raggedoutside}{
\checkoddpage
\ifoddpage
\raggedright
\else
\raggedleft
\fi
\DeclareCaptionJustification{RaggedOutside}{%
\ifthenelse{\boolean{isElectronic}}{%
\RaggedRight%
}{%
\checkoddpage%
\ifoddpage%
\RaggedRight%
\else%
\RaggedLeft%
\fi%
}%
}
\RequirePackage{calc}
\RequirePackage{wrapfig2}
\newcommand{\iconsize}{0.25in}
\NewDocumentCommand{\iconsize}{}{0.25in}
\newcommand{\ig}[2][0.5in]{
\NewDocumentCommand{\ig}{O{0.5in} m}{
\includegraphics[keepaspectratio,width=#1]{#2}
}
\newcommand{\cfig}[4]{%
}
\newcommand{\centerfig}[4][]{
\NewDocumentCommand{\centerfig}{O{} m >{\TrimSpaces}m m}{
\begin{figure}[htpb]%
\centering%
\Centering%
\includegraphics[keepaspectratio,#1]{#2}%
\caption{#4}%
\label{fig:#3}%
\end{figure}%
}
\newcommand{\bigfig}[4][\bigfloatoverhang]{%
\NewDocumentCommand{\bigfig}{O{\bigfloatoverhang} m >{\TrimSpaces}m m}{%
\bigfloat[#1]{figure}{htpb}{%
\captionsetup{type=figure}%
\includegraphics[keepaspectratio,width=\textwidth]{#2}%
\centering\captionof{figure}{#4}\par%
\Centering\captionof{figure}{#4}\par%
\label{fig:#3}%
}%
}
\newcommand{\doublebigfig}[7][\bigfloatoverhang]{%
\NewDocumentCommand{\doublebigfig}{%
O{\bigfloatoverhang} m >{\TrimSpaces}m m m >{\TrimSpaces}m m%
}{%
\bigfloat[#1]{figure}{p}{%
\captionsetup{type=figure}%
\includegraphics[keepaspectratio,width=\textwidth]{#2}%
\centering\captionof{figure}{#4}\par%
\Centering\captionof{figure}{#4}\par%
\label{fig:#3}
\bigskip
\captionsetup{type=figure}%
\includegraphics[keepaspectratio,width=\textwidth]{#5}%
\centering\captionof{figure}{#7}\par%
\Centering\captionof{figure}{#7}\par%
\label{fig:#6}%
}%
}
@@ -82,7 +85,9 @@
\textwidth / 2 + \bigfloatoverhang - \twinfigspace
]{\twinfigwidth}
\newcommand{\twinfig}[7][\bigfloatoverhang]{%
\NewDocumentCommand{\twinfig}{%
O{\bigfloatoverhang} m >{\TrimSpaces}m m m >{\TrimSpaces}m m%
}{%
\bigfloat[#1]{figure}{htpb}{%
\begin{tblr}{%
colspec = {%
@@ -119,7 +124,9 @@
}%
}
\newcommand{\wrapfig}[6][0in]{%
\NewDocumentCommand{\wrapfig}{%
O{0in} m m m >{\TrimSpaces}m m%
}{%
% Syntax:
% \wrapfig[%
% horizontal_offset
@@ -142,7 +149,7 @@
keepaspectratio,%
#4%
]{#2}%
\centering\captionof{figure}{#6}%
\Centering\captionof{figure}{#6}%
\label{fig:#5}%
\end{wrapfigure}%
}

View File

@@ -15,7 +15,7 @@
\newlength{\insideheaderoffset}
\setlength{\insideheaderoffset}{0.5in}
\newcommand{\parttitle}{}
\NewDocumentCommand{\parttitle}{}
\renewcommand{\chaptermark}[1]{ \markboth{#1}{} }

View File

@@ -4,4 +4,4 @@
% Index formatting.
\RequirePackage{makeidx}
\RequirePackage{xstring}
\newcommand{\idx}[1]{\StrSubstitute{#1}{!}{ }\index{#1}}
\NewDocumentCommand{\idx}{m}{\StrSubstitute{#1}{!}{ }\index{#1}}

View File

@@ -46,9 +46,9 @@
% all,
% ]{nowidow}
\RequirePackage{lua-widow-control}
\RequirePackage[balanced]{lua-widow-control}
\ifthenelse{\boolean{isDraft}}{
\lwcdraft{draft}
\lwcsetup{draft}
}{}
% Paragraph formatting.
@@ -71,9 +71,9 @@
\renewcommand{\dblfloatpagefraction}{0.8} % require fuller float pages
% Line-breaking zero-width space
\newcommand{\zws}{\hspace{0pt}}
\NewDocumentCommand{\zws}{}{\hspace{0pt}}
% Line-breaking dot
\newcommand{\bdot}{.\hspace{0pt}}
\NewDocumentCommand{\bdot}{}{.\hspace{0pt}}
\newlength{\bigfloatoffset}
\setlength{\bigfloatoffset}{0.25in}
@@ -82,7 +82,7 @@
\newlength{\bigfloatoverhang}
\setlength{\bigfloatoverhang}{0.81in}
\newcommand{\bigfloat}[4][\bigfloatoverhang]{%
\NewDocumentCommand{\bigfloat}{O{\bigfloatoverhang} m m +m}{%
\begin{#2}[#3]%
\ifthenelse{\boolean{isElectronic}}{
\begin{adjustwidth}{-#1+\bigfloatoffset}{-#1-\bigfloatoffset}%
@@ -100,31 +100,24 @@
\end{#2}%
}
% \newcommand{\bignotfloat}[2][\bigfloatoverhang]{%
% \begin{adjustwidth*}{-#1+\bigfloatoffset}{-#1-\bigfloatoffset}%
% \begin{minipage}{#1 * 2 + \textwidth}%
% #2%
% \end{minipage}%
% \end{adjustwidth*}%
% }
\providelength[0.5em]{\boxoutpadding}
\newlength{\boxoutpadding}
\setlength{\boxoutpadding}{0.5em}
\colorlet{boxoutbgcolor}{PrimePaleBlue}
\colorlet{boxoutfgcolor}{PrimeBlue}
\newcommand{\boxoutbgcolor}{PrimePaleBlue}
\newcommand{\boxoutfgcolor}{PrimeBlue}
\newcommand{\boxout}[5][0in]{%
\NewDocumentCommand{\boxout}{%
O{0in} m m >{\TrimSpaces}m +m%
}{%
\begin{wrapfigure}{#2}[#1]%
\fcolorbox{\boxoutfgcolor}{\boxoutbgcolor}{%
\fcolorbox{boxoutfgcolor}{boxoutbgcolor}{%
\begin{minipage}{#3}%
\vspace{\boxoutpadding}%
{\centering%
{\Centering%
\begin{minipage}{\boxoutpadding*-2 + \textwidth}%
\label{box:#4}%
\setlength{\parskip}{\medskipamount}%
{\centering\slab{\strong{#4}}\par}%
\small{}#5%
{\Centering\slab{\strong{#4}}\par}%
\justifying\small{}#5%
\end{minipage}%
\par}%
\vspace{\boxoutpadding}%
@@ -133,17 +126,19 @@
\end{wrapfigure}%
}
\newcommand{\bigboxout}[4][\bigfloatoverhang]{%
\NewDocumentCommand{\bigboxout}{%
O{\bigfloatoverhang} m >{\TrimSpaces}m +m%
}{%
\bigfloat[#1]{figure}{#2}{%
\fcolorbox{\boxoutfgcolor}{\boxoutbgcolor}{%
\fcolorbox{boxoutfgcolor}{boxoutbgcolor}{%
\begin{minipage}{\boxoutpadding*-2 + \textwidth}%
\vspace{\boxoutpadding}%
{\centering%
{\Centering%
\begin{minipage}{\boxoutpadding*-2 + \textwidth}%
\label{box:#3}%
\setlength{\parskip}{\medskipamount}%
{\centering\slab{\strong{#3}}\par}%
\small{}#4%
{\Centering\slab{\strong{#3}}\par}%
\justifying\small{}#4%
\end{minipage}%
\par}%
\vspace{\boxoutpadding}%

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}%
}%
}

View File

@@ -4,10 +4,10 @@
\RequirePackage{graphicx}
% Define custom title page.
\newcommand{\PrimeTitlePage}[1][]{
\NewDocumentCommand{\PrimeTitlePage}{O{}}{
\begin{titlepage}
\begin{sbfamily}
{\raggedright\noindent\large
{\RaggedRight\noindent\large
\vspace*{\stretch{1}}
\sCustomerFull

View File

@@ -6,13 +6,13 @@
\renewcommand{\thepart}{\arabic{part}}
\titleformat{\part}[display]{
\normalfont\sbfamily\huge\centering
\normalfont\sbfamily\huge\Centering
}{
\partname{} \thepart
}{20pt}{\Huge}
\titleformat{\chapter}[display]{
\normalfont\sbfamily\huge\raggedright
\normalfont\sbfamily\huge\RaggedRight
}{
\chaptertitlename{} \thechapter
}{20pt}{\Huge}