Skip to content

Instantly share code, notes, and snippets.

@moriglia
Created March 22, 2023 17:59
Show Gist options
  • Save moriglia/0d9dd1e21d40c15619d164d49a0474fb to your computer and use it in GitHub Desktop.
Save moriglia/0d9dd1e21d40c15619d164d49a0474fb to your computer and use it in GitHub Desktop.
Render images in equally wide minipages with the same hight
\newlength{\mycustomheight}
\settoheight{\mycustomheight}{\includegraphics[width=0.5\textwidth, keepaspectratio]{wider-image}}
% ^^^^^^^^^^^^ Note this cool trick guys! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
% Figures will have the same height though they are set in equally wide minipages :D
\begin{figure}
\centering
\begin{minipage}{0.5\textwidth}
\centering
\includegraphics[height=\mycustomheight{}, keepaspectratio]{narrower-image}
\caption{Caption of narrow}
\label{fig:narrow}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\centering
\includegraphics[height=\mycustomheight{}, keepaspectratio]{wider-image}
\caption{Caption of wide}
\label{fig:wide}
\end{minipage}
\end{figure}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment