Files
PrimeTeX/packages/Graphics.sty
Joshua Lucas f9a6c6e7cc - Refine Boxouts.
- General refactoring.
2025-08-27 16:41:25 -05:00

154 lines
3.0 KiB
TeX

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{PrimeTeX/packages/Graphics}[2025-07-09]
\RequirePackage{PrimeTeX/packages/Layout}
\RequirePackage{calc}
\RequirePackage{wrapfig2}
\providelength{\iconsize}[0.25in]
\providelength{\igh}[10pt] % igh = Inline Graphics Height.
% 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}
% Graphic file.
m
% Label.
>{\TrimSpaces}m
% Caption.
m
}{%
\BigFloat[#1][#2][#3]{figure}{%
\captionsetup{type=figure}%
\includegraphics[keepaspectratio,width=\linewidth]{#4}%
\Centering\captionof{figure}{#6}%\par
\label{fig:#5}%
}%
}
\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
}{%
\BigFloat[#1][p][#2]{figure}{%
\captionsetup{type=figure}%
\includegraphics[keepaspectratio,width=\textwidth]{#3}%
\Centering\captionof{figure}{#5}\par%
\label{fig:#4}
\bigskip
\captionsetup{type=figure}%
\includegraphics[keepaspectratio,width=\textwidth]{#6}%
\Centering\captionof{figure}{#8}\par%
\label{fig:#7}%
}%
}
\RequirePackage{tabularray}
\providelength{\twinfigspace}[3pt]
\providelength{\twinfigwidth}[
\textwidth / 2 + \bigfloatoverhang - \twinfigspace
]
\NewDocumentCommand{\twinfig}{%
O{\bigfloatoverhang} m >{\TrimSpaces}m m m >{\TrimSpaces}m m%
}{%
\BigFloat[#1]{table}{%
\begin{tblr}{%
colspec = {*{2}{Q[c,m,wd=\twinfigwidth]}},%
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 = \twinfigspace,%
rightspace = \twinfigspace,%
},%
}%
\vfill
\captionsetup{type=figure}%
\includegraphics[%
keepaspectratio,width=\twinfigwidth%
]{#2}%
\captionof{figure}{#4}%
\label{fig:#3}
\vfill%
&%
\vfill
\captionsetup{type=figure}%
\includegraphics[%
keepaspectratio,width=\twinfigwidth%
]{#5}%
\captionof{figure}{#7}%
\label{fig:#6}
\vfill%
\\%
\end{tblr}%
}%
}
\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%
}{%
\begin{wrapfigure}{#1}[#2]%
\captionsetup{type=figure}%
\capstart%
\includegraphics[%
keepaspectratio,%
#4%
]{#3}%
\Centering\captionof{figure}{#6}%
\label{fig:#5}%
\end{wrapfigure}%
}