对齐并排子图的标题

对齐并排子图的标题

我正在尝试将两个图形并排放置在投影仪环境中。使用以下几行可以正确放置图形:

\usepackage{subcaption}
 ....

\begin{figure}
\centering
\begin{subfigure}{.5\textwidth}\centering
  \includegraphics[width=\columnwidth]{a.pdf}
  \caption{Figure a}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}\centering
  \includegraphics[width=\columnwidth]{b.pdf}
  \caption{Figure b}
\end{subfigure}
\end{figure}

但标题没有对齐。左图的标题位置很好,但右图的标题却显示在图下方几厘米处:

|------------------|           |------------------|
|------------------|           |------------------|
|------------------|           |------------------|
    (a) Figure a                   


                                  (b) Figure b

答案1

只需使用可选[t]参数subcaption

\documentclass{article}
\usepackage{graphicx,subcaption}

\begin{document}
\begin{figure}
%\centering -> This is irrelevant because of the '.5\textwidth' as Mico advised below.
\begin{subfigure}[t]{.5\textwidth}\centering
  \includegraphics[width=.8\columnwidth]{example-image-a.pdf}
  \caption{Figure a}
\end{subfigure}%
\begin{subfigure}[t]{.5\textwidth}\centering
  \includegraphics[width=\columnwidth]{example-image-b.pdf}
  \caption{Figure b}
\end{subfigure}
\end{figure}
\end{document}

在此处输入图片描述

相关内容