Fix bugs.

This commit is contained in:
Silcantar
2025-09-03 22:19:44 -05:00
parent 5178581bbb
commit 6130aab230
7 changed files with 134 additions and 114 deletions

View File

@@ -1,5 +1,7 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{PrimeTeX/packages/Boxout}[2025-08-20]
\ProvidesExplPackage{PrimeTeX/packages/Boxout}{2025-09-03}{1.0}{
Commands for typesetting boxouts.
}
\RequirePackage{PrimeTeX/packages/Layout}
\RequirePackage{PrimeTeX/packages/Color}
@@ -16,107 +18,118 @@
hborder{Z} = {abovespace=\boxoutpadding},
hlines = {0pt,boxoutBG},
hline{1,Z} = {\boxoutrule,boxoutFG},
%row{1} = {font={\bfseries\sbfamily}},
vborder{1} = {rightspace=\boxoutpadding},
vborder{Z} = {leftspace=\boxoutpadding},
vlines = {0pt,boxoutBG},
vline{1,Z} = {\boxoutrule,boxoutFG},
}
\NewDocumentEnvironment{@boxout}{
m m +b
}{
\label{box:#1}%
\begin{tblrBoxout}{#2}%
#3%
\str_const:Nn \c_Boxout_colspec_str {{X[l,h]}}
\bool_const:Nn \c_Boxout_warning_bool {\c_false_bool}
\keys_define:nn{Boxout}{
colspec .str_set_e:N= \l_Boxout_colspec_str,
colspec .initial:e = {\c_Boxout_colspec_str},
warning .bool_set:N = \l_Boxout_warning_bool,
}
\NewDocumentEnvironment{Boxout}{
% #1: Key-value options.
O{}
% #2: Label, passed to @boxout argument #1.
>{\TrimSpaces}m
% #3: Caption.
m
% #4: Body, passed to @boxout.
+b
}{%
\keys_set:nn{Boxout}{#1}
\bool_if:nT \l_Boxout_warning_bool {%
\colorlet{boxoutBG}{warningBG}%
\colorlet{boxoutFG}{warningFG}%
}%
\label{box:#2}%
\message{colspec=\str_use:N \l_Boxout_colspec_str}
\SetTblrInner{colspec:e=\l_Boxout_colspec_str}
\begin{tblrBoxout}{}%
\IfBlankF{#3}{\Centering\sbfamily\bfseries #3\\}%
\setlength{\parskip}{\medskipamount}%
#4\\%
\end{tblrBoxout}%
}{}
\NewDocumentEnvironment{Boxout}{
% #1: Label, passed to @boxout argument #1.
>{\TrimSpaces}m
% #2: Tabularray colspec, passed to @boxout argument #2.
O{colspec={X[l,h]}}
% #3: Caption.
m
% #4: [Ww] for warning box.
o
% #5: Body, passed to @boxout.
+b
}{%
\ifthenelse{\equal{#4}{w}\OR\equal{#4}{W}}{%
\colorlet{boxoutBG}{warningBG}%
\colorlet{boxoutFG}{warningFG}%
}{}%
\IfBlankTF{#3}{%
\begin{@boxout}{#1}{#2}{}%
\setlength{\parskip}{\medskipamount}%
#5\\%
\end{@boxout}%
}{%
\begin{@boxout}{#1}{#2}%
{\Centering\sbfamily\bfseries #3}\\%
\setlength{\parskip}{\medskipamount}%
#5\\%
\end{@boxout}%
}%
}{}
\keys_define:nn{}{
BigBoxout .inherit:n = BigFloat,
BigBoxout .inherit:n = Boxout,
}
\ExplSyntaxOn
\NewDocumentEnvironment{BigBoxout}{
% #1: Overhang, passed to BigFloat argument #1.
O{\c_BigFloat_overhang_dim}
% #2: Float placement, passed to BigFloat argument #2.
O{h,t,p,b}
% #3: Offset ratio, passed to BigFloat argument #3.
O{\c_BigFloat_offset_fp}
% #4: Label, passed to Boxout argument #1.
% #1: Key-value options.
O{}
% #2: Label, passed to Boxout argument #1.
>{\TrimSpaces}m
% #5: Tabularray colspec, passed to Boxout argument #2.
O{X[l,h]}
% #6: Caption, passed to Boxout argument #3.
% #5: Tabularray colspec, passed to Boxout argument #2.
%O{X[l,h]}
% #3: Caption, passed to Boxout argument #3.
m
% #7: [Ww] for warning box, if present passed to Boxout argument #4.
o
% #8: Body, passed to Boxout.
% #4: Body, passed to Boxout.
+b
}{
\keys_set:nn{BigBoxout}{#1}
\begin{BigFloat}[
type = generic,
overhang = #1,
placement = {#2},
offset = #3,
overhang = \l_BigFloat_overhang_dim,
placement:e = \l_BigFloat_placement_clist,
offset = \l_BigFloat_offset_fp,
]%
\IfNoValueTF{#7}{%
\begin{Boxout}{#4}[#5]{#6}%
#8%
\end{Boxout}%
}{%
\begin{Boxout}{#4}[#5]{#6}[#7]%
#8%
\end{Boxout}%
}%
\begin{Boxout}[%
warning=\l_Boxout_warning_bool,
colspec=\l_Boxout_colspec_str,
]{#2}[\l_Boxout_colspec_str]{#3}%
#4%
\end{Boxout}%
\end{BigFloat}%
}{}
\ExplSyntaxOff
\str_const:Nn \c_WrapBoxout_position_str {o}
\dim_const:Nn \c_WrapBoxout_offset_dim {\marparwidth}
\dim_const:Nn \c_WrapBoxout_width_dim {3in}
\keys_define:nn{}{
WrapBoxout .inherit:n = Boxout,
}
\keys_define:nn{WrapBoxout}{
position .choices:nn = {l,r,i,o}{
\str_set:Nn \l_WrapBoxout_position_str {\l_keys_choice_tl}
},
position .initial:e = {\c_WrapBoxout_position_str},
offset .dim_set:N = \l_WrapBoxout_offset_dim,
offset .initial:e = {\c_WrapBoxout_offset_dim},
width .dim_set:N = \l_WrapBoxout_width_dim,
width .initial:e = {\c_WrapBoxout_width_dim},
}
\NewDocumentEnvironment{WrapBoxout}{
% position [l,r,i,o]
O{o}
% offset
O{\marparwidth}
% width
O{3in}
O{X[l,h]}
% #1: Key-value options.
O{}
% #2: Label.
>{\TrimSpaces}m
% #3: Caption
m
o
% #4: Body.
+b
}{%
\begin{wrapfigure}{#1}[#2]%
\begin{minipage}{#3}%
\begin{Boxout}[#4]{#5}{#6}[#7]%
#8%
\keys_set:nn{WrapBoxout}{#1}
\begin{wrapfigure}{\l_WrapBoxout_position_str}[\l_WrapBoxout_offset_dim]%
\begin{minipage}{\l_WrapBoxout_width_dim}%
\begin{Boxout}[
colspec = \l_Boxout_colspec_str,
warning = \l_Boxout_warning_bool,
]{#2}{#3}%
#4%
\end{Boxout}%
\end{minipage}%
\end{wrapfigure}%