2

I am writing a two-columns latex file based on an aip templates. Now I have 6 figures, and I want to arrange them in a 3*2 format in one column. Here is an example I desired desired output I've tried subfigure, but it will expand the two figures in each row to the whole width of the page. Any suggestions?

I've tried the following codes

\begin{figure}
\centering
\begin{subfigure}{0.45\columnwidth}
    \includegraphics[width=\textwidth]{example_imagA}
    \caption{Image A}
\end{subfigure}
\hfill
\begin{subfigure}{0.45\columnwidth}
    \includegraphics[width=\textwidth]{example_imagB}
    \caption{Image B} 
\end{subfigure} 
% 
\begin{subfigure}{0.45\columnwidth} 
    \includegraphics[width=\textwidth]{example_imagC} 
    \caption{Image C} 
\end{subfigure}  
\hfill 
\begin{subfigure}{0.45\columnwidth} 
    \includegraphics[width=\textwidth]{example_imagD} 
    \caption{Image D} 
\end{subfigure} 
\end{figure}

and I get the results as follows enter image description here as you can see, the subfigures are very small. How to make full use of the single column width?

1 Answer 1

4

Use \columnwidth when specifying how wide you want the figure to be, and \textwidth for how wide you want your images to be within that subfigure. So \columnwidth tells you you much of the width of the column you wish your figure to take up (say .45), and then within the subfigure, you want your image to take up the whole of the width of the subfigure. This is measured by any of \textwidth, \linewidth, \columnwidth, or \hsize. So the width can be set by say width=\textwidth. Using the package subcaption (not subfigure), the following should give you the output you need:

  \documentclass[twocolumn]{article}

  \usepackage{subcaption}
  \usepackage{graphicx}
  \usepackage{lipsum}

  \begin{document}
  \lipsum
  \begin{figure}
  \begin{subfigure}{0.45\columnwidth}
  \includegraphics[width=\textwidth]{example-image-a}
  \caption{Image A}
  \end{subfigure}
  \hfill
  \begin{subfigure}{0.45\columnwidth}
  \includegraphics[width=\textwidth]{example-image-b}
  \caption{Image B} 
  \end{subfigure} 
  % 
  \begin{subfigure}{0.45\columnwidth} 
  \includegraphics[width=\textwidth]{example-image-c} 
  \caption{Image C} 
  \end{subfigure}  
  \hfill 
  \begin{subfigure}{0.45\columnwidth} 
  \includegraphics[width=\textwidth]{example-image-a} 
  \caption{Image A again} 
  \end{subfigure}
  \caption{Wow! Look at all those letters!}
  \end{figure}
  \lipsum
  \end{document}

This should give output similar to:

Example of a 2 by 2 grid of images in one column of a 2 column document

8
  • The code indeed formats the 4 figures into 2*2 form, but the figures in each row are very small and much space is left in the column. I changed the numbers before \columnwidth from 0.45 to a larger one, say 0.9, the figure indeed become larger but it also exceeds the column and occupies the space of the other column. Would you please give me more advice on adjusting the figure size in the columns? I'm confused by \columnwidth and \textwidth. In my opinion, length of \textwidth is larger than \columnwidth, how can we put a figure with size of \textwidth into a box with size of \columnwidth?
    – Humblerose
    Commented Apr 10, 2019 at 12:24
  • The \textwidth in the subfigure refers to the width of the subfigure. So you want to use the full textwidth of the subfigure, which is itself .45 of the \columnwidth. This is because when you use subcaption, the subfigure environments are based on minipages, and within a minipage, textwidth refers to the textwidth of the minipage. Can you post the code you are using?
    – Martha
    Commented Apr 10, 2019 at 12:35
  • to figure i would add common caption and labels to each subfigure as well to figure (after theirs captions). also \centering is in your case superfluous.
    – Zarko
    Commented Apr 10, 2019 at 12:48
  • @Zarko - Thanks, I have added a common caption and removed the \centering. Is that what you meant?
    – Martha
    Commented Apr 10, 2019 at 12:56
  • @Martha, yes. I thought it would be a good idea for the OP to draw attention to this. Nice answer !
    – Zarko
    Commented Apr 10, 2019 at 13:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .