我有一个由两个子图组成的图形,但两者之间有轻微的垂直偏移。以下是代码:
\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}
其 PDF 版本如下所示:
如果我将两个子图更改为同一个图,它也会发生偏移,因此其中一个图像具有更多空间或其他问题就不会出现。
有人有主意吗?
多谢
答案1
问题在于其中一个子标题有两行,而另一个只有一行,而 LaTeX 试图将两个子图(包括子标题)垂直居中。要解决这个问题,请[t]
添加\begin{subfigure}
:
\begin{subfigure}[t]{0.49\textwidth}
梅威瑟:
\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}