2

I would like to have a caption which is centered and has multiple lines. For example,

\documentclass{article}

\begin{document}
\begin{figure}
\centering
\begin{tabular}{cc}
  \rule{5cm}{3cm} & \rule{5cm}{3cm} \\
  (a) & (b) \\
\end{tabular}
\caption{\begin{tabular}{ll}
  (a) & This is a .... \\
  (b) & This is a ... 
\end{tabular}}
\end{figure}

\end{document}

When this compiles, there is a centered caption, but the Figure label does not match up with the first line. I have used the caption package and inserted new lines, however when I insert \\ or \newline, I lose the centering.

Simply put, I would like to have multi-line captions which are centered on the page (as a whole), the first line matches the Figure label, and ideally will allow me to use a table to construct my caption.

2
  • Use \begin{tabular}[t], and supply an additional LoT entry via \caption[..]{...}.
    – Werner
    Jul 22, 2014 at 14:14
  • Do you know the package subcaption? This would be a nicer approach as you seem to do captions for each image here.
    – LaRiFaRi
    Jul 22, 2014 at 15:19

1 Answer 1

1

In order to align a tabular's first line with the surrounding text, use a [t]op alignment.

enter image description here

\documentclass{article}

\begin{document}

\listoffigures

\begin{figure}
  \centering
  \begin{tabular}{ c c }
    \rule{5cm}{3cm} & \rule{5cm}{3cm} \\
    (a) & (b)
  \end{tabular}
  \caption[(a) X; (b) Y]{\begin{tabular}[t]{ @{} r @{\ } l @{}}
    (a) & This is X. \\
    (b) & This is Y. 
  \end{tabular}}
\end{figure}

\end{document}

Note that \captions send their content to the LoT/LoF. Since it would be weird to have a tabular in the LoT/LoF, you can use the optional argument of \caption to specify this part.

You must log in to answer this question.

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