My table caption spans more than on line so I added a \newline
to split the caption at an appropriate position. Now, the two lines are left aligned. How do I center the two lines of the caption?
\begin{table}[htb]
\begin{center}
\caption{my caption line one\newline my caption line two}
\begin{tabular}{|r|c|c|c|c|c|}
\end{tabular}
\end{center}
\end{table}
Best Answer
Package
caption
allows many customizations. Centered caption texts can be achieved by optionjustification=centering
.However, because of the manual line break, the result isn't too pleasing. Therefore I have added an own format using centering inside environment
varwidth
of packagevarwidth
. It cuts down the lines to the needed length.The third table adds
labelsep=newline
to add a first line for the table label.Tested with the following versions (
\listfiles
):