3

I have a figure in my LaTeX file with two subfigures. I want to add a label to each subfigure like (a) and (b) while maintaining an overall description of the figure below.

The code that I have is like this:

\usepackage{caption}
\usepackage{subcaption}


\begin{figure*}[!t]
    \begin{subfigure}
        \centering
        \includegraphics[trim={0, 50, 0, 0}, width=0.5\textwidth]{figures/plot1.pdf}
        \caption{Caption 1} \label{fig:1a}
    \end{subfigure}
    \begin{subfigure}
        \centering
        \includegraphics[trim={0, 50, 0, 0}, width=0.5\textwidth]{figures/plot2.pdf}
        \caption{Caption 2} \label{fig:2a}
    \end{subfigure}
\caption{Something.}
\label{fig:figure2}
\end{figure*}

However, this produces the following: enter image description here

As you can see, this is not at all what I want. How should I go about maintaining the two subfigures side by side while adding labels beneath them? Thanks.

1
  • You also probably want [clip=true]. Mar 7, 2021 at 1:55

1 Answer 1

3

To achieve the correct labeling for subfigures, you have to use \subcaption instead of the regular \caption.

Also, the subfigure environment takes another obligatory argument for its width. If you set that to .5\textwidth or less for both figures, they should appear side by side.

You must log in to answer this question.

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