2

So if I use a caption in following example:

\documentclass{article}
\begin{document}
\begin{table}
\caption{test}
\centering
\begin{tabular}{ll}
\hline
Name: & Baggins \\
First Name: & Bilbo\\
Address: & Bagshot Row 56, 10982 Hobbiton\\
\hline
\end{tabular}
\end{table}
\end{document}

So per default short captions are centered. With the caption package and singlinecheck=off I can remove the centering of the caption. But what if I wanted the caption aligned with the left side of the table, is there a way to achieve this?

2 Answers 2

3

The simplest way is to use the threeparttable package, which measures the tables widths. Here is a code, in which I improved vertical spacing of rows:

\documentclass{article}
\usepackage[singlelinecheck = off]{caption}
\usepackage{threeparttable, booktabs}

\begin{document}

\begin{table}
  \centering\renewcommand\arraystretch{1.1}
  \begin{threeparttable}
    \caption{test}
    \begin{tabular}{ll}
      \toprule
      Name: & Baggins \\
      First Name: & Bilbo \\
      Address: & Bagshot Row 56, 10982 Hobbiton \\
      \bottomrule
    \end{tabular}
  \end{threeparttable}
\end{table}

\end{document} 

enter image description here

3

This can be done with the caption package and the setup

\captionsetup[table]{singlelinecheck=false,position=top}

After that you have to insert your caption inside a \captionbox as in the following MWE

\documentclass{article}
\usepackage{caption}
\captionsetup[table]{singlelinecheck=false,position=top}
\begin{document}
\begin{table}
\centering
\captionbox{test}
{\begin{tabular}{ll}
\hline
Name: & Baggins \\
First Name: & Bilbo\\
Address: & Bagshot Row 56, 10982 Hobbiton\\
\hline
\end{tabular}}
\end{table}
\end{document} 

Output:

enter image description here

You must log in to answer this question.

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