127

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
  • 6
    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
    Commented Jun 19, 2013 at 12:58
  • 2
    @Mico, yes. I was using a document in twocolumn mode. In MWE, I should have deleted that part, sorry.
    – Sait
    Commented Jun 20, 2013 at 14:15
  • 20
    Can @Sait show the usepackages please? Commented Dec 6, 2017 at 10:09

1 Answer 1

179

Use the t option for the alignment of the subfigures:

\usepackage{subcaption}
\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

12
  • 28
    Which pkg is required to use subfigure?
    – hhh
    Commented Jul 15, 2016 at 16:15
  • 52
    The subcaption package is the one for that :)
    – latex user
    Commented Jul 20, 2016 at 12:30
  • 7
    What's the meaning of "~"?
    – skan
    Commented Nov 16, 2017 at 22:42
  • 7
    @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
    Commented Nov 26, 2017 at 15:49
  • 5
    what is figure*?
    – Hao S
    Commented Oct 9, 2019 at 21:08

You must log in to answer this question.

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