我怎样才能使标题和图像对齐?

我怎样才能使标题和图像对齐?

我有这个代码

\begin{figure}
\begin{tabular}{cc}
\subfloat[$T_s$ = 119 Position with sine]{\includegraphics[width = 2in]{T119PosiSin.eps}} &
\subfloat[$T_s$ = 118 Position with sine]{\includegraphics[width = 2in]{T118PosiSin.eps}} &
\\
\subfloat[$T_s$ = 119 Current with sine]{\includegraphics[width = 2in]{T119CurrSin.eps}} &
\subfloat[$T_s$ = 118 Current with sine]{\includegraphics[width = 2in]{T118CurrSin.eps}} &
\\
\subfloat[$T_s$ = 119 Position with square]{\includegraphics[width = 2in]{T119PosiSqu.eps}} &
\subfloat[$T_s$ = 118 Position with square]{\includegraphics[width = 2in]{T118PosiSqu.eps}} &
\\
\subfloat[$T_s$ = 119 Current with square]{\includegraphics[width = 2in]{T119CurrSqu.eps}} &
\subfloat[$T_s$ = 118 Current with square]{\includegraphics[width = 2in]{T118CurrSqu.eps}} 
\end{tabular}
\caption{4 x 2}
\end{figure}

这导致所附图片和标题未正确对齐。有人知道我该如何让它们正确对齐吗?在此处输入图片描述

答案1

tabular定义了两列,但您在tabular正文中使用了三列:

\begin{tabular}{ c c }
  <first column> & <second column> & <third column>
  \\
  <first column> & <second column> & <third column>
  \\
  % ...
\end{tabular}

删除第二个&,以便仅使用指定的列。

在此处输入图片描述

\documentclass{article}

\usepackage{graphicx,subfig}

\begin{document}

\begin{figure}
  \begin{tabular}{ c c }
    \subfloat[$T_s = 119$ Position with sine]{\includegraphics[width = 2in]{example-image-a}} &
    \subfloat[$T_s = 118$ Position with sine]{\includegraphics[width = 2in]{example-image-b}}
    \\
    \subfloat[$T_s = 119$ Current with sine]{\includegraphics[width = 2in]{example-image-a}} &
    \subfloat[$T_s = 118$ Current with sine]{\includegraphics[width = 2in]{example-image-b}}
    \\
    \subfloat[$T_s = 119$ Position with square]{\includegraphics[width = 2in]{example-image-b}} &
    \subfloat[$T_s = 118$ Position with square]{\includegraphics[width = 2in]{example-image-a}}
    \\
    \subfloat[$T_s = 119$ Current with square]{\includegraphics[width = 2in]{example-image-b}} &
    \subfloat[$T_s = 118$ Current with square]{\includegraphics[width = 2in]{example-image-a}} 
  \end{tabular}
  \caption{$2 \times 4$}
\end{figure}

\end{document}

相关内容