Refactoring Boxouts.

This commit is contained in:
2025-08-26 17:00:31 -05:00
parent 7945ab0e6b
commit 1ce3cd364f
5 changed files with 207 additions and 99 deletions

View File

@@ -3,50 +3,142 @@
\RequirePackage{PrimeTeX/packages/Layout} \RequirePackage{PrimeTeX/packages/Layout}
\RequirePackage{PrimeTeX/packages/Color} \RequirePackage{PrimeTeX/packages/Color}
\RequirePackage{PrimeTeX/packages/Tables}
\RequirePackage{calc}
\providelength{\boxoutpadding}[0.5em] \providelength{\boxoutpadding}[1em]
\providelength{\boxoutrule}[1pt]
\colorlet{boxoutbgcolor}{PrimePaleBlue} \colorlet{boxoutbgcolor}{PrimePaleBlue}
\colorlet{boxoutfgcolor}{PrimeBlue} \colorlet{boxoutfgcolor}{PrimeBlue}
\NewDocumentCommand{\boxout}{% \NewTblrEnviron{tblrBoxout}
O{0in} m m >{\TrimSpaces}m +m% \SetTblrInner[tblrBoxout]{
}{% %colspec = {X[1,l,h]},
\begin{wrapfigure}{#2}[#1]% cells = {boxoutbgcolor},
\fcolorbox{boxoutfgcolor}{boxoutbgcolor}{% hlines = {0pt},
\begin{minipage}{#3}% hline{1,Z} = {\boxoutrule,boxoutfgcolor},
\vspace{\boxoutpadding}% row{1} = {font={\bfseries\sbfamily}},
{\Centering% vborder{1} = {rightspace=\boxoutpadding},
\begin{minipage}{\boxoutpadding*-2 + \textwidth}% vborder{Z} = {leftspace=\boxoutpadding},
\label{box:#4}% vlines = {0pt},
\setlength{\parskip}{\medskipamount}% vline{1,Z} = {\boxoutrule,boxoutfgcolor},
{\Centering\slab{\strong{#4}}\par}%
\justifying\small{}#5%
\end{minipage}%
\par}%
\vspace{\boxoutpadding}%
\end{minipage}%
}%
\end{wrapfigure}%
} }
\NewDocumentCommand{\bigboxout}{% \NewDocumentEnvironment{Boxout}{
O{\bigfloatoverhang} m >{\TrimSpaces}m +m% O{colspec={X[l,h]}}
>{\TrimSpaces}m
+m
+b
}{% }{%
\bigfloat[#1]{figure}{#2}{% \label{box:#2}%
\fcolorbox{boxoutfgcolor}{boxoutbgcolor}{% \captionlistentry[figure]{#3}%
\begin{minipage}{\boxoutpadding*-2 + \textwidth}% \begin{tblrBoxout}{#1}%
\vspace{\boxoutpadding}% {\Centering{}#3}\\%
{\Centering% #4\\%
\begin{minipage}{\boxoutpadding*-2 + \textwidth}% \end{tblrBoxout}%
\label{box:#3}% }{}
\setlength{\parskip}{\medskipamount}%
{\Centering\slab{\strong{#3}}\par}% \NewDocumentEnvironment{BigBoxout}{
\justifying\small{}#4% O{\bigfloatoverhang}
\end{minipage}% O{htpb}
\par}% O{\bigfloatoffset}
\vspace{\boxoutpadding}% O{X[l,h]}
\end{minipage}% >{\TrimSpaces}m
}% +m
}% +b
} }{
\begin{figure}[#2]%
\begin{adjustwidth}{-#1 + #3}{-#1 - #3}%
\begin{Boxout}[#4]{#5}{#6}%
#7%
\end{Boxout}%
\end{adjustwidth}%
\end{figure}%
}{}
\NewDocumentEnvironment{WrapBoxout}{
% position [l,r,i,o]
O{O}
% offset
O{\marparwidth}
% width
O{3in}
O{X[l,h]}
>{\TrimSpaces}m
+m
+b
}{%
\begin{wrapfigure}{#1}[#2]%
\begin{minipage}{#3}%
\begin{Boxout}[#4]{#5}{#6}%
#7%
\end{Boxout}%
\end{minipage}%
\end{wrapfigure}%
}{}
% \NewDocumentCommand{\Boxout}{
% % width
% O{\textwidth}
% % label
% >{\TrimSpaces}m
% % heading
% +m
% % body
% +m
% }{%
% {% Temporarily set \fboxsep and \fboxrule.
% \setlength{\fboxrule}{\boxoutrule}%
% \setlength{\fboxsep}{\boxoutpadding}%
% \fcolorbox{boxoutfgcolor}{boxoutbgcolor}{%
% \begin{minipage}{#4 - \fboxrule * 2 - \fboxsep * 2}%
% %{\Centering%
% \captionlistentry[figure]{#3.}%
% \label{box:#1}%
% \setlength{\parskip}{\medskipamount}%
% {\Centering\slab{\strong{#2}}\par}%
% \justifying\small{}#3%
% %}%
% \end{minipage}%
% }%
% }%
% }
% \NewDocumentCommand{\BigBoxout}{%
% % overhang
% O{\bigfloatoverhang}
% % Float position.
% O{htpb}
% % offset
% O{\bigfloatoffset}
% % label
% m
% % heading
% +m
% % body
% +m
% }{%
% \BigFloat[#1][#2][#3]{figure}{%
% \Boxout{#4}{#5}{#6}%
% }%
% }
% \NewDocumentCommand{\WrapBoxout}{%
% % position [l,r,i,o]
% O{O}
% % offset
% O{\marparwidth}
% % width
% O{3in}
% % label
% m
% % heading
% +m
% % body
% +m
% }{%
% \begin{wrapfigure}{#1}[#2]%
% \Boxout[#3]{#4}{#5}{#6}%
% \end{wrapfigure}%
% }

View File

@@ -41,17 +41,14 @@
\colorlet{boxedcoloroutline}{black} \colorlet{boxedcoloroutline}{black}
\NewDocumentCommand{\boxedcolor}{O{\rule{0pt}{1ex}\rule{1ex}{0pt}} m m}{% \NewDocumentCommand{\boxedcolor}{O{\rule{0pt}{1ex}\rule{1ex}{0pt}} m m}{%
{ % Temporarily set fboxrule and fboxsep. {\setlength{\fboxrule}{0.2pt}% Temporarily set \fboxrule and \fboxsep.
\setlength{\fboxrule}{0.2pt}% \setlength{\fboxsep}{1pt}%
\setlength{\fboxsep}{1pt}% \fcolorbox{boxedcoloroutline}{#2}{\color{#3}\strut{}#1}}%
%
\fcolorbox{boxedcoloroutline}{#2}{\color{#3}\strut{}#1}%
}%
} }
\providelength{\warningboxsizeoffset}[12.3599pt] \providelength{\warningboxwidth}[\textwidth - \fboxsep * 2 - \fboxrule *2]
\NewDocumentCommand{\warningbox}{O{\textwidth-\warningboxsizeoffset} +m}{% \NewDocumentCommand{\warningbox}{O{\warningboxwidth} +m}{%
\noindent% \noindent%
\fcolorbox{WarningBoxFGColor}{WarningBoxBGColor}{% \fcolorbox{WarningBoxFGColor}{WarningBoxBGColor}{%
\noindent% \noindent%

View File

@@ -25,7 +25,7 @@
} }
\NewDocumentCommand{\bigfig}{O{\bigfloatoverhang} m >{\TrimSpaces}m m}{% \NewDocumentCommand{\bigfig}{O{\bigfloatoverhang} m >{\TrimSpaces}m m}{%
\bigfloat[#1]{figure}{htpb}{% \BigFloat[#1]{figure}{%
\captionsetup{type=figure}% \captionsetup{type=figure}%
\includegraphics[keepaspectratio,width=\textwidth]{#2}% \includegraphics[keepaspectratio,width=\textwidth]{#2}%
\Centering\captionof{figure}{#4}\par% \Centering\captionof{figure}{#4}\par%
@@ -34,18 +34,33 @@
} }
\NewDocumentCommand{\doublebigfig}{% \NewDocumentCommand{\doublebigfig}{%
O{\bigfloatoverhang} m >{\TrimSpaces}m m m >{\TrimSpaces}m m% % BigFloat overhang.
O{\bigfloatoverhang}
% BigFloat offet.
O{\bigfloatoffset}
% First graphic filename.
m
% First graphic label.
>{\TrimSpaces}m
% First graphic caption.
m
% Second graphic filename.
m
% Second graphic label.
>{\TrimSpaces}m
% Second Graphic caption.
m
}{% }{%
\bigfloat[#1]{figure}{p}{% \BigFloat[#1][p][#2]{figure}{%
\captionsetup{type=figure}% \captionsetup{type=figure}%
\includegraphics[keepaspectratio,width=\textwidth]{#2}% \includegraphics[keepaspectratio,width=\textwidth]{#3}%
\Centering\captionof{figure}{#4}\par% \Centering\captionof{figure}{#5}\par%
\label{fig:#3} \label{fig:#4}
\bigskip \bigskip
\captionsetup{type=figure}% \captionsetup{type=figure}%
\includegraphics[keepaspectratio,width=\textwidth]{#5}% \includegraphics[keepaspectratio,width=\textwidth]{#6}%
\Centering\captionof{figure}{#7}\par% \Centering\captionof{figure}{#8}\par%
\label{fig:#6}% \label{fig:#7}%
}% }%
} }
@@ -59,7 +74,7 @@
\NewDocumentCommand{\twinfig}{% \NewDocumentCommand{\twinfig}{%
O{\bigfloatoverhang} m >{\TrimSpaces}m m m >{\TrimSpaces}m m% O{\bigfloatoverhang} m >{\TrimSpaces}m m m >{\TrimSpaces}m m%
}{% }{%
\bigfloat[#1]{table}{htpb}{% \BigFloat[#1]{table}{%
\begin{tblr}{% \begin{tblr}{%
colspec = {% colspec = {%
*{2}{Q[c,m,wd=\twinfigwidth]}% *{2}{Q[c,m,wd=\twinfigwidth]}%
@@ -101,31 +116,27 @@
}% }%
} }
\NewDocumentCommand{\wrapfig}{% \NewDocumentCommand{\wrapfig}{
O{0in} m m m >{\TrimSpaces}m m% % alignment [l,r,i,o]
O{O}
% horizontal_offset
O{\marparwidth}
% graphic_file
m
% (width|height)=lengthvalue
O{}
% label
>{\TrimSpaces}m
% caption
m%
}{% }{%
% Syntax: \begin{wrapfigure}{#1}[#2]%
% \wrapfig[%
% horizontal_offset
% ]{
% graphic_file
% }{
% alignment [l,r,i,o]
% }{
% (width|height)=lengthvalue
% }{
% label
% }{
% caption
% }
%
\begin{wrapfigure}{#3}[#1]%
\captionsetup{type=figure}% \captionsetup{type=figure}%
\capstart% \capstart%
\includegraphics[% \includegraphics[%
keepaspectratio,% keepaspectratio,%
#4% #4%
]{#2}% ]{#3}%
\Centering\captionof{figure}{#6}% \Centering\captionof{figure}{#6}%
\label{fig:#5}% \label{fig:#5}%
\end{wrapfigure}% \end{wrapfigure}%

View File

@@ -47,7 +47,6 @@
\RequirePackage{calc} \RequirePackage{calc}
\RequirePackage[strict]{changepage} \RequirePackage[strict]{changepage}
%\newlength{\contentwidth}
\providelength{\marparwidth}[\marginparsep + \marginparwidth] \providelength{\marparwidth}[\marginparsep + \marginparwidth]
\providelength{\contentwidth}[\textwidth + \marparwidth] \providelength{\contentwidth}[\textwidth + \marparwidth]
@@ -89,25 +88,45 @@
\providecommand{\adjwidthtype}{} \providecommand{\adjwidthtype}{}
\NewDocumentCommand{\bigfloat}{ \makeatletter
O{\bigfloatoverhang} m m +m O{\bigfloatoffset}
\NewDocumentCommand{\BigFloat}{
% Overhang: the distance that the BigFloat extends into the margins.
O{\bigfloatoverhang}
% Float position: where the float may appear on the page.
O{htpb}
% Offset: the distance to offset the center of the BigFloat from the center
% of the text block.
O{\bigfloatoffset}
% Float type: figure or table.t
m
% Content: what appears in the BigFloat.
+m
}{% }{%
\ifthenelse{\boolean{isElectronic}}{% \ifthenelse{\boolean{isElectronic}}{%
\bfloat{#1}{#2}{#3}{#4}{#5}{adjustwidth}% \@bfloat{#1}{#2}{#3}{#4}{#5}{adjustwidth}%
}{% }{%
\bfloat{#1}{#2}{#3}{#4}{#5}{adjustwidth*}% \@bfloat{#1}{#2}{#3}{#4}{#5}{adjustwidth*}%
}% }%
} }
\NewDocumentCommand{\bfloat}{m m m +m m m}{ \NewDocumentCommand{\@bfloat}{
\begin{#2}[#3]% % First 5 arguments are same as \BigFloat.
\begin{#6}{-#1+#5}{-#1-#5}% m m m m +m
% Argument 6 is the adjustwidth type [adjustwidth for one-sided document,
% adjustwidth* for two-sided].
m
}{
\begin{#4}[#2]% figure/table
\begin{#6}{-#1+#3}{-#1-#3}% adjustwidth(*)
\begin{minipage}{#1 * 2 + \textwidth}% \begin{minipage}{#1 * 2 + \textwidth}%
\ifthenelse{\boolean{isDraft}}{% \ifthenelse{\boolean{isDraft}}{%
\rule{\textwidth}{1pt}\zws% \rule{\textwidth}{1pt}\zws%
}{}% }{}%
#4% #5%
\end{minipage}% \end{minipage}%
\end{#6}% \end{#6}%
\end{#2}% \end{#4}%
} }
\makeatother

View File

@@ -28,17 +28,6 @@
hline{2} = {0.4pt}, hline{2} = {0.4pt},
} }
\NewTblrEnviron{tblrBoxout}
\SetTblrInner[tblrBoxout]{
colspec = {Q[c,h]X[1,m]},
hline{1,Z} = {0.6pt,PrimeBlue},
vline{1,Z} = {0.6pt,PrimeBlue},
hline{2} = {0.0pt,PrimePaleBlue},
vline{2} = {0.0pt,PrimePaleBlue},
vborder{Z} = {leftspace=12pt},
columns = {PrimePaleBlue},
}
\NewTblrTableCommand{\midtitle}[1][pageColor]{ \NewTblrTableCommand{\midtitle}[1][pageColor]{
\SetCell[c=2]{ \SetCell[c=2]{
c, c,