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/Color}
\RequirePackage{PrimeTeX/packages/Tables}
\RequirePackage{calc}
\providelength{\boxoutpadding}[0.5em]
\providelength{\boxoutpadding}[1em]
\providelength{\boxoutrule}[1pt]
\colorlet{boxoutbgcolor}{PrimePaleBlue}
\colorlet{boxoutfgcolor}{PrimeBlue}
\NewDocumentCommand{\boxout}{%
O{0in} m m >{\TrimSpaces}m +m%
}{%
\begin{wrapfigure}{#2}[#1]%
\fcolorbox{boxoutfgcolor}{boxoutbgcolor}{%
\begin{minipage}{#3}%
\vspace{\boxoutpadding}%
{\Centering%
\begin{minipage}{\boxoutpadding*-2 + \textwidth}%
\label{box:#4}%
\setlength{\parskip}{\medskipamount}%
{\Centering\slab{\strong{#4}}\par}%
\justifying\small{}#5%
\end{minipage}%
\par}%
\vspace{\boxoutpadding}%
\end{minipage}%
}%
\end{wrapfigure}%
\NewTblrEnviron{tblrBoxout}
\SetTblrInner[tblrBoxout]{
%colspec = {X[1,l,h]},
cells = {boxoutbgcolor},
hlines = {0pt},
hline{1,Z} = {\boxoutrule,boxoutfgcolor},
row{1} = {font={\bfseries\sbfamily}},
vborder{1} = {rightspace=\boxoutpadding},
vborder{Z} = {leftspace=\boxoutpadding},
vlines = {0pt},
vline{1,Z} = {\boxoutrule,boxoutfgcolor},
}
\NewDocumentCommand{\bigboxout}{%
O{\bigfloatoverhang} m >{\TrimSpaces}m +m%
\NewDocumentEnvironment{Boxout}{
O{colspec={X[l,h]}}
>{\TrimSpaces}m
+m
+b
}{%
\bigfloat[#1]{figure}{#2}{%
\fcolorbox{boxoutfgcolor}{boxoutbgcolor}{%
\begin{minipage}{\boxoutpadding*-2 + \textwidth}%
\vspace{\boxoutpadding}%
{\Centering%
\begin{minipage}{\boxoutpadding*-2 + \textwidth}%
\label{box:#3}%
\setlength{\parskip}{\medskipamount}%
{\Centering\slab{\strong{#3}}\par}%
\justifying\small{}#4%
\end{minipage}%
\par}%
\vspace{\boxoutpadding}%
\end{minipage}%
}%
}%
}
\label{box:#2}%
\captionlistentry[figure]{#3}%
\begin{tblrBoxout}{#1}%
{\Centering{}#3}\\%
#4\\%
\end{tblrBoxout}%
}{}
\NewDocumentEnvironment{BigBoxout}{
O{\bigfloatoverhang}
O{htpb}
O{\bigfloatoffset}
O{X[l,h]}
>{\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}
\NewDocumentCommand{\boxedcolor}{O{\rule{0pt}{1ex}\rule{1ex}{0pt}} m m}{%
{ % Temporarily set fboxrule and fboxsep.
\setlength{\fboxrule}{0.2pt}%
\setlength{\fboxsep}{1pt}%
%
\fcolorbox{boxedcoloroutline}{#2}{\color{#3}\strut{}#1}%
}%
{\setlength{\fboxrule}{0.2pt}% Temporarily set \fboxrule and \fboxsep.
\setlength{\fboxsep}{1pt}%
\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%
\fcolorbox{WarningBoxFGColor}{WarningBoxBGColor}{%
\noindent%

View File

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

View File

@@ -47,7 +47,6 @@
\RequirePackage{calc}
\RequirePackage[strict]{changepage}
%\newlength{\contentwidth}
\providelength{\marparwidth}[\marginparsep + \marginparwidth]
\providelength{\contentwidth}[\textwidth + \marparwidth]
@@ -89,25 +88,45 @@
\providecommand{\adjwidthtype}{}
\NewDocumentCommand{\bigfloat}{
O{\bigfloatoverhang} m m +m O{\bigfloatoffset}
\makeatletter
\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}}{%
\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}{
\begin{#2}[#3]%
\begin{#6}{-#1+#5}{-#1-#5}%
\NewDocumentCommand{\@bfloat}{
% First 5 arguments are same as \BigFloat.
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}%
\ifthenelse{\boolean{isDraft}}{%
\rule{\textwidth}{1pt}\zws%
}{}%
#4%
#5%
\end{minipage}%
\end{#6}%
\end{#2}%
\end{#4}%
}
\makeatother

View File

@@ -28,17 +28,6 @@
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]{
\SetCell[c=2]{
c,