0

I would like to know, how is it possible to correctly align all figures below without passing through a vectorial processing software. Is it possible in LaTex ? I am working with subfiguresbut didn't manage to do it properly. Here is my code :

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption,subcaption}

\begin{document}

%Figure 1 \begin{figure}[ht] \centering \begin{subfigure}[b]{0.5\linewidth} \centering \includegraphics[width=0.95\textwidth]{example-image-a}\[1mm] \caption{}\label{fig:fig1a} \hfil \includegraphics[width=0.95\textwidth]{example-image-b} \caption{}\label{fig:fig1b} \end{subfigure}% \begin{subfigure}[b]{0.5\linewidth} \centering \includegraphics[width=0.95\textwidth]{example-image-c}\[1mm] \caption{}\label{fig:fig2} \hfil \includegraphics[width=0.45\textwidth]{example-image-a} \includegraphics[width=0.45\textwidth]{example-image-a} \hfil \caption{}\label{fig:fig2} \end{subfigure}
\end{figure}

\end{document}

enter image description here And with my own figures, I obtain this : enter image description here

I thought about labels as here : This post but didn't work for me Any help is appreciated !

Thank you,

P.S : Here are the images of the template :

image1

image2

image3

image4

image5

Waxler
  • 680
  • Do you mean that you have pictures with different heights, but want the captions aligned? – egreg Feb 05 '24 at 17:09
  • @egreg Correct : also is there a way to adjust the height of the figures directly in LaTex ? I am exploring to what extent I can avoid processing images with other softwares – Waxler Feb 05 '24 at 17:22
  • it's rather hard to comment as you do not provide a full example that can be used, and show the output from a different document. you probably want to scale the images to the same height rather than scaling to specific widths, then they will line up naturally. – David Carlisle Feb 05 '24 at 17:36
  • @DavidCarlisle I have tried to impose the same height for the concerned images but didn't succeed to have the right outcome. I have shared the files in my post. Sorry for not doing it before : I thought it was not allowed – Waxler Feb 05 '24 at 18:05
  • your code doesn't run as it has no \documentclass it would be better to demonstrate the problem using example-image.... but the links are ok if the image is really important to the example (which seems unlikely here) but your code doesn't match the filenames. can you not replace width=... by height=... if you do not want to scale them to the same height, what output do you want? – David Carlisle Feb 05 '24 at 18:54
  • I wanted to have each subfigure with same width and each picture with same height : this is why I am asking for an advice here – Waxler Feb 05 '24 at 19:08
  • 1
    If you want them to be the same height, do as @DavidCarlisle says and use height=. Then fill the spaces between with space if you want the subfigures to be the same width. It might be easier to use a sub-figure box for each image (or image pair). Off-topic: isn't it confusing to label them left-down-up and right-down rather than left-to-right by row? – cfr Feb 06 '24 at 01:55
  • 1
    then keep the width key on subfigure as now and change the width key on includegraphics to height – David Carlisle Feb 06 '24 at 07:17
  • @cfr Thank you : it worked when removing width and only imposing height. But I didn't get your proposition to fill the spaces with space to get the same width ? Could you please explain it in more details ? Appreciated ! – Waxler Feb 06 '24 at 16:46
  • All I meant was what @DavidCarlisle said. If you keep the subfigure width and standardise the height, your code will fill the gaps between the images with space. That may or may not look odd depending, but that's all you can really do given your desiderata. – cfr Feb 06 '24 at 19:06

0 Answers0