105

I am using the following code to put my two figures side by side with different captions,

\begin{figure*}[t!]
    \centering
    \begin{subfigure}[b]{0.5\textwidth}
        \centering
        \includegraphics[height=1.2in]{a}
        \caption{Lorem ipsum}
    \end{subfigure}%
    ~ 
    \begin{subfigure}[b]{0.5\textwidth}
        \centering
        \includegraphics[height=1.2in]{b}
        \caption{Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum}
    \end{subfigure}
    \caption{Caption place holder}
\end{figure*}

I get the following output: output

However, I want to position both my images vertically same line, like the following:

Desired output: desired

3
  • 5
    IJust curious: Why are you using the "starred" version of the figure environment? Is your document maybe being typeset in twocolumn mode? If so, the only place where LaTeX will place a double-wide float is at the top of the page, which would make the [t!] location specifier unnecessary. – Mico Jun 19 '13 at 12:58
  • 2
    @Mico, yes. I was using a document in twocolumn mode. In MWE, I should have deleted that part, sorry. – Sait Jun 20 '13 at 14:15
  • 18
    Can @Sait show the usepackages please? – Gennaro Arguzzi Dec 6 '17 at 10:09
141

Use the t option for the alignment of the subfigures:

\begin{figure*}[t!]
    \centering
    \begin{subfigure}[t]{0.5\textwidth}
        \centering
        \includegraphics[height=1.2in]{a}
        \caption{Lorem ipsum}
    \end{subfigure}%
    ~ 
    \begin{subfigure}[t]{0.5\textwidth}
        \centering
        \includegraphics[height=1.2in]{b}
        \caption{Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum}
    \end{subfigure}
    \caption{Caption place holder}
\end{figure*}

Using this, both images will be aligned on top:

enter image description here

7
  • 21
    Which pkg is required to use subfigure? – hhh Jul 15 '16 at 16:15
  • 44
    The subcaption package is the one for that :) – latex user Jul 20 '16 at 12:30
  • 4
    What's the meaning of "~"? – skan Nov 16 '17 at 22:42
  • 4
    @skan It's a non-breaking space. The subfigures don't stay next to each other when there is an empty line between them, so the space was added. Alternatively you could omit that line – it would just give you different horizontal spacing between the subfigures. – V02460 Nov 26 '17 at 15:49
  • 3
    what is figure*? – Hao S Oct 9 '19 at 21:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.