1

I have a figure made up of two subfigures but there is a slight vertical offset between the two. Here's the code:

\begin{figure}[h!]
\centering
\begin{subfigure}{0.49\textwidth}
\includegraphics[width=\textwidth]{black body.png}
\caption{Theortical intensity of a black body white light source according to equation~\ref{eq:black body}}
\label{fig:black body}
\end{subfigure}
\begin{subfigure}{0.49\textwidth}
\includegraphics[width=\textwidth]{black body plus response.png}
\caption{white light source measured with system repsonse }
\label{fig:black body plus response}
\end{subfigure}
\caption[Black body measurement]{Intensity of a perfect black body measured in a system with an equal response over all wavelengths}\label{fig:black body comparison}
\end{figure}

Here's how it looks in the pdf:

enter image description here

It also offsets if I change both of the subfigures to the same figure so it isn't a problem with one of the images having more space or something.

Anyone have any ideas?

Thanks a lot

3
  • Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – user31729
    Mar 19, 2015 at 17:04
  • 1
  • floatrow provides support for this by default - vertically aligned captions for sub-floats.
    – Werner
    Mar 19, 2015 at 17:08

1 Answer 1

1

The problem is that one of the subcaptions has two lines and the other only one, and LaTeX is trying to vertically center both subfigures (subcaptions included). To solve it add [t] to \begin{subfigure}:

\begin{subfigure}[t]{0.49\textwidth}

MWE:

\documentclass[demo]{article}
\usepackage{graphicx}
\usepackage{caption,subcaption}
\begin{document}
\begin{figure}[h!]
\centering
\begin{subfigure}[t]{0.49\textwidth}
\includegraphics[width=\textwidth]{black body.png}
\caption{Theortical intensity of a black body white light source according to equation~\ref{eq:black body}}
\label{fig:black body}
\end{subfigure}
\begin{subfigure}[t]{0.49\textwidth}
\includegraphics[width=\textwidth]{black body plus response.png}
\caption{white light source measured with system repsonse }
\label{fig:black body plus response}
\end{subfigure}
\caption[Black body measurement]{Intensity of a perfect black body measured in a system with an equal response over all wavelengths}\label{fig:black body comparison}
\end{figure}
\end{document}

enter image description here

2
  • Oh thanks so much that's worked brilliantly!
    – bonzo1984
    Mar 19, 2015 at 17:24
  • @bonzo1984 you are welcome. If that has solved your issue, please consider accepting the answer to mark the question as solved. See Accepting Answers: How does it work? for more info.
    – summer
    Mar 19, 2015 at 18:12

You must log in to answer this question.

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