# captionsetup not working

I'm trying to format the caption of a table using "captionsetup", but whatever options I give it have no effect and no error message is returned. I want to format it so that the label and the caption are on two different lines and justified to the left.

Any help on that?

This is my code:

\documentclass{article}
\usepackage{caption}
\begin{document}
\begin{table}[h]
\captionsetup[table]{position=above,justification=raggedright}
\caption{\\Title of the table}
\begin{center}
\begin{tabular}{llp{2cm}p{2cm}}
...
\end{tabular}
\end{center}
\label{BoS}
\end{table}
\end{document}

• labelsep=newline should do, but with short captions it will still be centered. – egreg Nov 23 '15 at 14:51
• Maybe the missing piece could be singlelinecheck=false. – Johannes_B Nov 23 '15 at 14:59
• Your \captionsetup[table]{...} is too late since all stored table options of the caption package were already applied at \begin{table}. Therefore you either need to move this line or use \captionsetup{...} instead. – user2574 Nov 24 '15 at 8:46

As @egreg and @Johannes_B said in the comments you probably want labelsep=newline and singlelinecheck=false. Without the latter short captions are centered instead of aligned to the left.

BTW: the setup should go in the preamble except you want this setup only for the one table. I'd also use \centering instead of the center´ environment. The environment inserts additional vertical space.

\documentclass{article}
\usepackage{caption}
% the setup belongs into the preamble! you don't want to repeat the setup each
% time you insert a new table.
\captionsetup[table]{
position=above,
justification=raggedright,
labelsep=newline, % <<< label and text on different lines
singlelinecheck=false % <<< raggadright also when the caption is shorter
% than a single line
}
\begin{document}

\begin{table}
\centering
\caption{Title of the table}\label{tab:first}
This is my first table.
\end{table}

\begin{table}
\centering
\caption{Title of the table that is a bit longer. Indeed it is longer than
one line. We still need a little more.}\label{tab:second}
This is my second table.
\end{table}

\end{document}
`

• Cool, thanks.. moving the \captionsetup to the preamble made it work just fine.. but how do I now constrain the caption to the widthspan of the table and not more? – Andy Nov 25 '15 at 8:00