\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{PrimeTeX/packages/Graphics}[2025-07-09]

\RequirePackage{PrimeTeX/packages/Layout}

% Graphics package for including images
\RequirePackage{graphicx}

\RequirePackage[
	hypcap=true,
]{caption}
\captionsetup{
	justification = centering,
	font = {
		small,
		color=PrimeBlue,
	},
}

% Define a justification style that is ragged on the side toward the outside of
% the page. I. e.
\RequirePackage{changepage}
%\RequirePackage{ifthen}
\DeclareCaptionJustification{raggedoutside}{
	\checkoddpage
	\ifoddpage
		\raggedright
	\else
		\raggedleft
	\fi
}

\RequirePackage{calc}

\RequirePackage{wrapfig2}

\newcommand{\iconsize}{0.25in}

\newcommand{\ig}[2][0.5in]{
	\includegraphics[keepaspectratio,width=#1]{#2}
}

\newcommand{\cfig}[4]{%

}
\newcommand{\centerfig}[4][]{
	\begin{figure}[htp]%
		\centering%
		\includegraphics[keepaspectratio,#1]{#2}%
		\caption{#4}%
		\label{fig:#3}%
	\end{figure}%
}

\newcommand{\bigfig}[4][\bigfloatoverhang]{%
	\bigfloat[#1]{figure}{htp}{%
		\captionsetup{type=figure}%
		\includegraphics[keepaspectratio,width=\textwidth]{#2}%
		\centering\captionof{figure}{#4}\par%
		\label{fig:#3}%
	}%
}

\newcommand{\doublebigfig}[7][\bigfloatoverhang]{%
	\bigfloat[#1]{figure}{p}{%
		\captionsetup{type=figure}%
		\includegraphics[keepaspectratio,width=\textwidth]{#2}%
		\centering\captionof{figure}{#4}\par%
		\label{fig:#3}
		\bigskip
		\captionsetup{type=figure}%
		\includegraphics[keepaspectratio,width=\textwidth]{#5}%
		\centering\captionof{figure}{#7}\par%
		\label{fig:#6}%
	}%
}

\newlength{\twinfigwidth}
\setlength{\twinfigwidth}{\textwidth / 2 + \bigfloatoverhang}

\newcommand{\twinfig}[7][\bigfloatoverhang]{%
	\bigfloat[#1]{figure}{htp}{%begin{table}[htp]%
		\begin{tabular}{*{2}{p{\twinfigwidth}}}%\begin{tblr}{Q[l,m]Q[l,m]}%
			\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{tabular}%\end{tblr}%
	}%\end{table}%
}

\newcommand{\wrapfig}[6][0in]{%
	% Syntax:
	% \wrapfig[%
	%	horizontal_offset
	% ]{
	%	graphic_file
	% }{
	%	alignment [l,r,i,o]
	% }{
	%	(width|height)=lengthvalue
	% }{
	%	label
	% }{
	%	caption
	% }
	%
	\begin{wrapfigure}{#3}[#1]%
		\captionsetup{type=figure}%
		\capstart%
		\includegraphics[%
			keepaspectratio,%
			#4%
		]{#2}%
		\centering\captionof{figure}{#6}%
		\label{fig:#5}%
	\end{wrapfigure}%
}
