[Tex/LaTex] how to put several images side by side in just one column in a two-column document

subfloatstwo-column

I am writing a paper which is a two-column document. Now I want to put several images side by side in just one of the columns, and I would like an illustrating text under each image which starts with (a), (b) and so on, and below them is the main caption for the whole figure.

Its effect is something like the image below (see the two side by side images on the left column with its own illustrating text below):
first figure

Yes, I have searched the stackexchange and googled, one answer shows how to achieve this using the minipage environment, but each image is numbered, i.e., figure 1, figure 2 and so on, which is not what I want. What I want is that the two images are as a whole, not independent.

There is also a post about using the subcaption package to achieve something similar but the document is just a one-column document. I tried to reproduce that under the two-column condition, but find that the \textwidth command does not seem to work well with the two-column environment. The minimal working example is like this

\documentclass[10pt,twocolumn,letterpaper]{article}
\usepackage{subcaption}
\usepackage{graphicx}
\begin{document}
\begin{figure}[t]
    \centering
    \begin{subfigure}{.3\textwidth}
        \centering
        \includegraphics[width=\textwidth]{figure1.png}
        \caption{level 1}
    \end{subfigure}%
    %\hspace{5mm}
    \begin{subfigure}{.3\textwidth}
        \centering
        \includegraphics[width=\textwidth]{figure1.png}
        \caption{level 2}
    \end{subfigure}%
    %\hspace{5mm}
    \begin{subfigure}{.3\textwidth}
        \centering
        \includegraphics[width=\textwidth]{figure1.png}
        \caption{level 3}
    \end{subfigure}
    \caption{some caption text}
    \label{fig:multiscale}
\end{figure}
% use the following as much as possible to fill two columns
blah blah blah blah blah blah blah blah blah blah blah blah blah
\end{document}

The produced document is shown the image below
second figure

The \textwidth command still uses the textwidth of one-column environment. One workaround way is to reduce the textwidth for subfigure environment, to about 0.15\textwidth.

Is there a more elegant way to achieve this other than decrease the textwidth mannually by trail and error?

Best Answer

When working with column-specific documents (this does include single column documents as well), use \columnwidth as the specifier of the local line width - see Difference between \textwidth, \linewidth and \hsize.

enter image description here

\documentclass[twocolumn]{article}

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

\begin{document}

\lipsum[1]

\begin{figure}[t]
  \centering
  \begin{subfigure}{.3\columnwidth}
    \centering
    \includegraphics[width=\linewidth]{example-image-a}
    \caption{Level 1}
  \end{subfigure}%
  \hfill
  \begin{subfigure}{.3\columnwidth}
    \centering
    \includegraphics[width=\linewidth]{example-image-b}
    \caption{Level 2}
  \end{subfigure}%
  \hfill
  \begin{subfigure}{.3\columnwidth}
    \centering
    \includegraphics[width=\linewidth]{example-image-c}
    \caption{Level 3}
  \end{subfigure}
  \caption{some caption text}
\end{figure}

\lipsum[2-7]

\end{document}

\hfill between each subfigure environment spreads them equally across the full width of the column - \columnwidth.