[Tex/LaTex] captionsetup not working

captions

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}

Best Answer

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}

enter image description here