I need to make a collage of picture responsive. Below my current MWE, I cannot use any environemnt but subcaption as this is the guideline of my university:
\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width=.8\linewidth]{figures/cool/flock.jpg}
\caption{1a}
\label{fig:sfig1}
\end{subfigure}%
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width=.8\linewidth]{figures/cool/whale_sound.jpg}
\caption{1b}
\label{fig:sfig2}
\end{subfigure}
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width=.8\linewidth]{figures/cool/wolfe_hierarchies.png}
\caption{1c}
\label{fig:sfig3}
\end{subfigure}
\caption{plots of....}
\label{fig:fig}
\end{figure}
\end{document}
That is giving me the following result:
Instead, I would like to have something like that:
As you can see the figure 1b is bigger and 1c has been moved to the bottom. So, right now I am doing that changing the width of each subfigure environment. Is there a way to do it dynamically, hopefully, according to the height of all the images? Moreover, I can I center image 1c in the second example?
Below the code for example 2:
\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width=.8\linewidth]{figures/cool/flock.jpg}
\caption{1a}
\label{fig:sfig1}
\end{subfigure}%
\begin{subfigure}{.66\textwidth}
\centering
\includegraphics[width=.8\linewidth]{figures/cool/whale_sound.jpg}
\caption{1b}
\label{fig:sfig2}
\end{subfigure}
\begin{subfigure}{.33\textwidth}
\centering
\includegraphics[width=.8\linewidth]{figures/cool/wolfe_hierarchies.png}
\caption{1c}
\label{fig:sfig3}
\end{subfigure}
\caption{plots of....}
\label{fig:fig}
\end{figure}
\end{document}
Best Answer
You can try this, it works as follows :
\imagewidth
is created to store the image width at each call\subgraphics
taking two input arguments (image file andsubfigure
caption) stores the width of the input image file for a height of 2cm in this case. Then it creates asubfigure
that exactly fits this width and includes the file.With this command, the width of the
subfigure
derives from the width of the image for a given image height.I would personally not use such a process, as it may result in unreadable information.