Try to use l3keys.

This commit is contained in:
2025-09-02 16:42:46 -05:00
parent d8286a0904
commit d8ee8bf058
8 changed files with 159 additions and 94 deletions

View File

@@ -7,10 +7,10 @@
\RequirePackage{wrapfig2}
\providelength{\iconsize}[0.25in]
\ProvideLength{\iconsize}[0.25in]
\providelength{\@InlineGraphicHeight}[12pt]
\providelength{\@InlineGraphicOffset}[-2pt]
\ProvideLength{\@InlineGraphicHeight}[12pt]
\ProvideLength{\@InlineGraphicOffset}[-2pt]
\NewDocumentCommand{\InlineGraphic}{
O{\@InlineGraphicHeight}
@@ -89,34 +89,95 @@
\RequirePackage{tabularray}
\providelength{\twinfigspace}[3pt]
\providelength{\twinfigwidth}[
\textwidth / 2 + \bigfloatoverhang - \twinfigspace
\ProvideLength{\twinfigspace}[3pt]
\ProvideLength{\twinfigwidth}[
\textwidth / 2 + \bigfloatoverhang * 3 / 2 - \twinfigspace
]
\ExplSyntaxOn
\dim_new:N \l_twinfig_overhang
\dim_new:N \l_twinfig_width
\dim_new:N \l_twinfig_space
\fp_new:N \l_twinfig_offset
\str_new:N \l_twinfig_placement
\str_new:N \l_twinfig_valign
\keys_define:nn{twinfig}{
overhang .dim_set:N = \l_twinfig_overhang,
overhang .initial:e = \bigfloatoverhang,
}
\keys_define:nn{twinfig}{
placement .str_set:N = \l_twinfig_placement,
placement .initial:n = {htpb},%\bigfloatplacement,
}
\keys_define:nn{twinfig}{
offset .fp_set:N = \l_twinfig_offset,
offset .initial:n = {2.0},%\bigfloatoffsetratio,
}
\keys_define:nn{twinfig}{
valign .str_set:N = \l_twinfig_valign,
valign .initial:n = {m},
}
\keys_define:nn{twinfig}{
width .dim_set:N = \l_twinfig_width,
width .initial:n = {3.14in},%\twinfigwidth,
}
\keys_define:nn{twinfig}{
space .dim_set:N = \l_twinfig_space,
space .initial:n = {3pt},%\twinfigspace,
}
\keys_log:nn{twinfig}{overhang}
\keys_log:nn{twinfig}{placement}
\keys_log:nn{twinfig}{offset}
\keys_log:nn{twinfig}{valign}
\keys_log:nn{twinfig}{width}
\keys_log:nn{twinfig}{space}
\typeout{\the\l_twinfig_overhang}
\typeout{\l_twinfig_placement}
\typeout{\fp_use:N \l_twinfig_offset}
\typeout{\l_twinfig_valign}
\typeout{\the\l_twinfig_width}
\typeout{\the\l_twinfig_space}
\ProcessKeyOptions[twinfig]
\NewDocumentCommand{\twinfig}{%
% Big Float overhang.
O{\bigfloatoverhang}
% Float placement.
O{htpb}
% BigFloat offset ratio.
O{\bigfloatoffsetratio}
% First graphic file.
% #1: Big Float overhang.
%O{\bigfloatoverhang}
% #2: Float placement.
%O{htpb}
% #3: BigFloat offset ratio.
%O{\bigfloatoffsetratio}
% #1: Key=value options.
O{}
% #2: First graphic file.
m
% First label.
% #3: First label.
>{\TrimSpaces}m
% First caption.
% #4: First caption.
>{\TrimSpaces}m
% Second graphic file.
% #5: Second graphic file.
m
% Second label.
% #6: Second label.
>{\TrimSpaces}m
% Second caption.
% #7: Second caption.
>{\TrimSpaces}m
% #8: Image vertical alignment.
%O{m}
}{%
\begin{BigFloat}[figure][#1][#2][#3]%
\keys_set:nn{twinfig}{#1}%
\typeout{\the\l_twinfig_overhang}
\typeout{\l_twinfig_placement}
\typeout{\fp_use:N \l_twinfig_offset}
\typeout{\l_twinfig_valign}
\typeout{\the\l_twinfig_width}
\typeout{\the\l_twinfig_space}
\begin{BigFloat}[figure][\l_twinfig_overhang][\l_twinfig_placement][\l_twinfig_offset]%
\begin{tblr}{%
colspec = {*{2}{Q[c,m,wd=\twinfigwidth]}},%
colspec = {*{2}{Q[c,\l_twinfig_valign,wd=\l_twinfig_width]}},%
hlines = {0pt},
%vlines,% For debugging. Comment out when done.
hborder{1,Z} = {%
@@ -128,26 +189,26 @@
rightspace = 0pt,%
},%
vborder{2} = {%
leftspace = \twinfigspace,%
rightspace = \twinfigspace,%
leftspace = \l_twinfig_space,%
rightspace = \l_twinfig_space,%
},%
}%
\vfill
\captionsetup{type=figure}%
\includegraphics[%
keepaspectratio,width=\twinfigwidth%
]{#4}%
\captionof{figure}{#6}%
\label{fig:#5}
keepaspectratio,width=\l_twinfig_width%
]{#2}%
\captionof{figure}{#4}%
\label{fig:#3}
\vfill%
&%
\vfill
\captionsetup{type=figure}%
\includegraphics[%
keepaspectratio,width=\twinfigwidth%
]{#7}%
\captionof{figure}{#9}%
\label{fig:#8}
keepaspectratio,width=\l_twinfig_width%
]{#5}%
\captionof{figure}{#7}%
\label{fig:#6}
\vfill%
\\%
\end{tblr}%