84

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
    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
  • @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
  • 11
    Can @Sait show the usepackages please? – Gennaro Arguzzi Dec 6 '17 at 10:09
117

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

  • 2
    ...or as an alternative use the \captionbox command instead of the subfigure environment. \captionboxes will be aligned by the first line of the caption automatically. – Axel Sommerfeldt Jun 19 '13 at 19:16
  • 15
    Which pkg is required to use subfigure? – hhh Jul 15 '16 at 16:15
  • 31
    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

protected by Community Jun 27 '18 at 16:46

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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