TransWikia.com

Two images side by side with another two images in the same column

TeX - LaTeX Asked on February 15, 2021

I am trying to achieve something like this (with individual subcaption for each image):

enter image description here

I would like to know how to be able to add an arbitrary number of images A on the left (or right) of the two images-colum. I did not understood how latex works in placing images:

    newsavebox{measurebox}
   usepackage{graphicx}
   usepackage{subfig}
  begin{figure}[h!]
    centering
    sbox{measurebox}{%
        begin{minipage}[b]{.33textwidth}
            subfloat
            []
            {label{fig:figA}includegraphics[width=textwidth,height=5cm]{images/bosquet_1.png}}
    end{minipage}}
    usebox{measurebox}qquad
    begin{minipage}[b][htmeasurebox][s]{.33textwidth}
        centering
        subfloat
        []
        {label{fig:figB}includegraphics[width=textwidth,height=2cm]{example-image-a}}
        
        vfill
        
        subfloat
        []
        {label{fig:figC}includegraphics[width=textwidth,height=2cm]{example-image-a}}
    end{minipage}
    caption{my caption. (a) is .... (b) is .... (c) is ....}
    label{fig:Test}
end{figure}

One Answer

Whatever you put into the first minipage will end up in the "left column", separate two images that you want to appear on top of each other by an empty line. If you place multiple images in the first minipage, all of them will be taken into account by the savebox. All images you place in the second minipage will appear in the "right column". If you want them to be evenly spread, separate them by empty lines and vfill.

Two further examples with different amounts of images per column could look like the following:

enter image description here

enter image description here

documentclass{article}
    newsavebox{measurebox}
   usepackage{graphicx}
   usepackage{subcaption}
begin{document}

begin{figure}[h!]
    centering
    sbox{measurebox}{%
        begin{minipage}[b]{.33textwidth}
            subfloat
            []
            {label{fig:figA}includegraphics[width=textwidth,height=5cm]{example-image-a}}
            
            subfloat
            []
            {label{fig:figB}includegraphics[width=textwidth,height=6cm]{example-image-a}}
    end{minipage}}
    usebox{measurebox}qquad
    begin{minipage}[b][htmeasurebox][s]{.33textwidth}
        centering
        subfloat
        []
        {label{fig:figC}includegraphics[width=textwidth,height=2cm]{example-image}}
        
        vfill
        
        subfloat
        []
        {label{fig:figD}includegraphics[width=textwidth,height=2cm]{example-image}}
        
        vfill
        
        subfloat
        []
        {label{fig:figE}includegraphics[width=textwidth,height=2cm]{example-image}}
        
        vfill
        
        subfloat
        []
        {label{fig:figF}includegraphics[width=textwidth,height=2cm]{example-image}}
    end{minipage}
    caption{my caption. (subref{fig:figA}) is .... (subref{fig:figB}) is .... (subref{fig:figC}) is .... }
    label{fig:Test}
end{figure}


begin{figure}[h!]
    centering
    sbox{measurebox}{%
        begin{minipage}[b]{.33textwidth}
            subfloat
            []
            {label{fig:figA}includegraphics[width=textwidth,height=3cm]{example-image-a}}
            
            subfloat
            []
            {label{fig:figB}includegraphics[width=textwidth,height=3cm]{example-image-a}}
            
            subfloat
            []
            {label{fig:figC}includegraphics[width=textwidth,height=3cm]{example-image-a}}
    end{minipage}}
    usebox{measurebox}qquad
    begin{minipage}[b][htmeasurebox][s]{.33textwidth}
        centering
        subfloat
        []
        {label{fig:figD}includegraphics[width=textwidth,height=4cm]{example-image}}
        
        vfill
        
        subfloat
        []
        {label{fig:figE}includegraphics[width=textwidth,height=4cm]{example-image}}
    end{minipage}
    caption{my caption. (subref{fig:figA}) is .... (subref{fig:figB}) is .... (subref{fig:figC}) is .... }
    label{fig:Test}
end{figure}

end{document}

Side notes:

For your actual images, make sure, you only use width=.. or height=...(or at least add keepaspectratio), otherwise the images will get distorted, as you can see from my two examples.

Make sure the contents in the first minipage are taller than the contents in teh second minipage. Otherwise you will see overlaps.

In order to add more information about each subfigure inside of the main caption of the figure, you can use subref as I did in my example code. I also suggest using more descriptive keys for the labels. Identifying images will then be a lot easier, especially if you later on decide to remove/add an image. (If you do so, fig:figB would not necessarily correspond to the sufigure with the caption (b))


Update regarding the request in the comments:

enter image description here

documentclass{article}
    newsavebox{measurebox}
   usepackage{graphicx}
   usepackage{subcaption}
begin{document}

  begin{figure}[h!]
    centering
    sbox{measurebox}{%
        begin{minipage}[b]{.3textwidth}
            subfloat
            []
            {label{fig:figA}includegraphics[width=textwidth,height=5cm]{example-image-a}}
    end{minipage}}
    usebox{measurebox}hfill
    begin{minipage}[b]{.3textwidth}
            subfloat
            []
            {label{fig:figA2}includegraphics[width=textwidth,height=5cm]{example-image-a}}
    end{minipage}hfill
    begin{minipage}[b][htmeasurebox][s]{.3textwidth}
        centering
        subfloat
        []
        {label{fig:figB}includegraphics[width=textwidth,height=2cm]{example-image-a}}
        
        vfill
        
        subfloat
        []
        {label{fig:figC}includegraphics[width=textwidth,height=2cm]{example-image-a}}
    end{minipage}
    caption{my caption. (a) is .... (b) is .... (c) is ....}
    label{fig:Test}
end{figure}

end{document}

Correct answer by leandriis on February 15, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP