This commit is contained in:
2025-09-04 17:12:01 -05:00
parent 6130aab230
commit db078eb5df
4 changed files with 74 additions and 42 deletions

View File

@@ -23,17 +23,30 @@
vlines = {0pt,boxoutBG},
vline{1,Z} = {\boxoutrule,boxoutFG},
}
% \SetTblrOuter[tblrBoxout]{
% expand+ = \l_Boxout_body_tl,
% }
\str_const:Nn \c_Boxout_colspec_str {{X[l,h]}}
\tl_const:Nn \c_Boxout_innerspec_tl {colspec={X[l,h]}}
\bool_const:Nn \c_Boxout_warning_bool {\c_false_bool}
\tl_new:N \l_Boxout_title_tl
\keys_define:nn{Boxout}{
colspec .str_set_e:N= \l_Boxout_colspec_str,
colspec .initial:e = {\c_Boxout_colspec_str},
innerspec .tl_set_e:N= \l_Boxout_innerspec_tl,
innerspec .initial:e = {\c_Boxout_innerspec_tl},
innerspec .default:e = {\c_Boxout_innerspec_tl},
warning .bool_set:N = \l_Boxout_warning_bool,
warning .initial:e = {false},
warning .default:e = {true},
}
% \NewExpandableDocumentCommand{\__Boxout_body:Nnn}{m +m +m}{
% %\message{boxout~body~start}
% }
\NewDocumentEnvironment{Boxout}{
% #1: Key-value options.
O{}
@@ -45,18 +58,23 @@
+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}%
\bool_if:nT \l_Boxout_warning_bool {
\colorlet{boxoutBG}{warningBG}
\colorlet{boxoutFG}{warningFG}
}
\label{box:#2}
\tl_if_empty:nTF {#3} {
\expanded{\noexpand\begin{tblrBoxout}{\l_Boxout_innerspec_tl}}
\setlength{\parskip}{\medskipamount}
#4\\
\end{tblrBoxout}
}{
\expanded{\noexpand\begin{tblrBoxout}{\l_Boxout_innerspec_tl}}
\SetCell{halign=c, font={\sbfamily\bfseries}}{#3}\\
\setlength{\parskip}{\medskipamount}
#4\\
\end{tblrBoxout}
}
}{}
\keys_define:nn{}{
@@ -69,8 +87,6 @@
O{}
% #2: Label, passed to Boxout argument #1.
>{\TrimSpaces}m
% #5: Tabularray colspec, passed to Boxout argument #2.
%O{X[l,h]}
% #3: Caption, passed to Boxout argument #3.
m
% #4: Body, passed to Boxout.
@@ -84,12 +100,12 @@
offset = \l_BigFloat_offset_fp,
]%
\begin{Boxout}[%
warning=\l_Boxout_warning_bool,
colspec=\l_Boxout_colspec_str,
]{#2}[\l_Boxout_colspec_str]{#3}%
#4%
\end{Boxout}%
\end{BigFloat}%
innerspec:e = \l_Boxout_innerspec_tl,
warning:e = \bool_to_str:N \l_Boxout_warning_bool,
]{#2}{#3}
#4
\end{Boxout}
\end{BigFloat}
}{}
\str_const:Nn \c_WrapBoxout_position_str {o}
@@ -100,7 +116,7 @@
WrapBoxout .inherit:n = Boxout,
}
\keys_define:nn{WrapBoxout}{
position .choices:nn = {l,r,i,o}{
position .choices:nn = {L,l,R,r,I,i,O,o}{
\str_set:Nn \l_WrapBoxout_position_str {\l_keys_choice_tl}
},
position .initial:e = {\c_WrapBoxout_position_str},
@@ -126,8 +142,8 @@
\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,
innerspec:e = \l_Boxout_innerspec_tl,
warning:e = \bool_to_str:N \l_Boxout_warning_bool,
]{#2}{#3}%
#4%
\end{Boxout}%