Rewrite Float commands in Latex3 and move them to new Floats package.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
\NeedsTeXFormat{LaTeX2e}
|
||||
\ProvidesPackage{PrimeTeX/packages/Graphics}[2025-07-09]
|
||||
\ProvidesExplPackage{PrimeTeX/packages/Graphics}{2025-09-03}{1.0}{
|
||||
Custom non-floating Graphics commands.
|
||||
}
|
||||
|
||||
\RequirePackage{PrimeTeX/packages/Layout}
|
||||
|
||||
@@ -7,212 +9,37 @@
|
||||
|
||||
\RequirePackage{wrapfig2}
|
||||
|
||||
\ProvideLength{\iconsize}[0.25in]
|
||||
\dim_const:Nn \c_Graphics_icon_dim {0.25in}
|
||||
|
||||
\ProvideLength{\@InlineGraphicHeight}[12pt]
|
||||
\ProvideLength{\@InlineGraphicOffset}[-2pt]
|
||||
\NewDocumentCommand{\IconSize}{}{\c_Graphics_icon_dim}
|
||||
|
||||
\keys_define:nn{InlineGraphic}{
|
||||
height .dim_set:N = \l_InlineGraphic_height_dim,
|
||||
height .initial:n = {12pt},
|
||||
% height .default:n = {12pt},
|
||||
|
||||
offset .dim_set:N = \l_InlineGraphic_offset_dim,
|
||||
offset .initial:n = {-2pt},
|
||||
% offset .default:n = {-2pt},
|
||||
}
|
||||
|
||||
\NewDocumentCommand{\InlineGraphic}{
|
||||
O{\@InlineGraphicHeight}
|
||||
m
|
||||
O{\@InlineGraphicOffset}
|
||||
}{%
|
||||
\raisebox{#3}{\includegraphics[keepaspectratio,height=#1]{#2}}%
|
||||
}
|
||||
|
||||
% Shorthand command for \includegraphics.
|
||||
\NewDocumentCommand{\ig}{O{width=0.5in} m}{%
|
||||
\includegraphics[keepaspectratio,#1]{#2}%
|
||||
}
|
||||
|
||||
\NewDocumentCommand{\centerfig}{O{} m >{\TrimSpaces}m m}{
|
||||
\begin{figure}[htpb]%
|
||||
\Centering%
|
||||
\includegraphics[keepaspectratio,#1]{#2}%
|
||||
\caption{#4}%
|
||||
\label{fig:#3}%
|
||||
\end{figure}%
|
||||
}
|
||||
|
||||
\NewDocumentCommand{\bigfig}{
|
||||
% BigFloat overhang.
|
||||
O{\bigfloatoverhang}
|
||||
% Float positioning.
|
||||
O{htpb}
|
||||
% BigFloat offset ratio.
|
||||
O{\bigfloatoffsetratio}
|
||||
% Key=value options.
|
||||
O{}
|
||||
% Graphic file.
|
||||
m
|
||||
% Label.
|
||||
>{\TrimSpaces}m
|
||||
% Caption.
|
||||
m
|
||||
}{%
|
||||
\begin{BigFloat}[figure][#1][#2][#3]%
|
||||
\captionsetup{type=figure}%
|
||||
\includegraphics[keepaspectratio,width=\linewidth]{#4}%
|
||||
\Centering\captionof{figure}{#6}%\par
|
||||
\label{fig:#5}%
|
||||
\end{BigFloat}%
|
||||
\keys_set:nn{InlineGraphic}{#1}
|
||||
\raisebox{\l_InlineGraphic_offset_dim}{
|
||||
\includegraphics[keepaspectratio,height=\l_InlineGraphic_height_dim]{#2}
|
||||
}%
|
||||
}
|
||||
|
||||
\NewDocumentCommand{\doublebigfig}{%
|
||||
% BigFloat overhang.
|
||||
O{\bigfloatoverhang}
|
||||
% BigFloat offet.
|
||||
O{\bigfloatoffsetratio}
|
||||
% 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
|
||||
}{%
|
||||
\begin{BigFloat}[figure][#1][p][#2]%
|
||||
\captionsetup{type=figure}%
|
||||
\includegraphics[keepaspectratio,width=\textwidth]{#3}%
|
||||
\Centering\captionof{figure}{#5}%
|
||||
\label{fig:#4}
|
||||
\bigskip
|
||||
\captionsetup{type=figure}%
|
||||
\includegraphics[keepaspectratio,width=\textwidth]{#6}%
|
||||
\Centering\captionof{figure}{#8}%
|
||||
\label{fig:#7}%
|
||||
\end{BigFloat}%
|
||||
}
|
||||
\dim_const:Nn \c_ig_width_dim {0.5in}
|
||||
|
||||
\RequirePackage{tabularray}
|
||||
|
||||
\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}{%
|
||||
% #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
|
||||
% #3: First label.
|
||||
>{\TrimSpaces}m
|
||||
% #4: First caption.
|
||||
>{\TrimSpaces}m
|
||||
% #5: Second graphic file.
|
||||
m
|
||||
% #6: Second label.
|
||||
>{\TrimSpaces}m
|
||||
% #7: Second caption.
|
||||
>{\TrimSpaces}m
|
||||
% #8: Image vertical alignment.
|
||||
%O{m}
|
||||
}{%
|
||||
\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,\l_twinfig_valign,wd=\l_twinfig_width]}},%
|
||||
hlines = {0pt},
|
||||
%vlines,% For debugging. Comment out when done.
|
||||
hborder{1,Z} = {%
|
||||
abovespace = 0pt,%
|
||||
belowspace = 0pt,%
|
||||
},%
|
||||
vborder{1,Z} = {%
|
||||
leftspace = 0pt,%
|
||||
rightspace = 0pt,%
|
||||
},%
|
||||
vborder{2} = {%
|
||||
leftspace = \l_twinfig_space,%
|
||||
rightspace = \l_twinfig_space,%
|
||||
},%
|
||||
}%
|
||||
\vfill
|
||||
\captionsetup{type=figure}%
|
||||
\includegraphics[%
|
||||
keepaspectratio,width=\l_twinfig_width%
|
||||
]{#2}%
|
||||
\captionof{figure}{#4}%
|
||||
\label{fig:#3}
|
||||
\vfill%
|
||||
&%
|
||||
\vfill
|
||||
\captionsetup{type=figure}%
|
||||
\includegraphics[%
|
||||
keepaspectratio,width=\l_twinfig_width%
|
||||
]{#5}%
|
||||
\captionof{figure}{#7}%
|
||||
\label{fig:#6}
|
||||
\vfill%
|
||||
\\%
|
||||
\end{tblr}%
|
||||
\end{BigFloat}%
|
||||
% Shorthand command for \includegraphics.
|
||||
\NewDocumentCommand{\ig}{O{width=\c_ig_width_dim} m}{%
|
||||
\includegraphics[keepaspectratio,#1]{#2}%
|
||||
}
|
||||
|
||||
\NewDocumentCommand{\wrapfig}{
|
||||
|
||||
Reference in New Issue
Block a user