[Tex/LaTex] Space between table caption and caption text

captions

At the moment, I have the following code in the preamble:

\usepackage[justification=justified,singlelinecheck=false]{caption}
\captionsetup{format=hang, labelsep=quad}

This creates a nice space between the table caption and the caption text. However, I would also like to add a colon after the table number, and at the same time have the separation between the colon and the caption text. As far as I know, \captionsetup only allows one attribute for labelsep. Is there an easy way to accomplish this?

Best Answer

Yes, there is. The caption package provides the command \DeclareCaptionLabelSeparator to define your own caption label separator.

So, declaring

\DeclareCaptionLabelSeparator{mysep}{:\quad}

and using

\captionsetup{format=hang, labelsep=mysep}

you can obtain what you want.

MWE:

\documentclass{article}
\usepackage{caption}
\usepackage[justification=justified,singlelinecheck=false]{caption}
\DeclareCaptionLabelSeparator{mysep}{:\quad}
\captionsetup{format=hang, labelsep=mysep}
\begin{document}

\begin{table}
  \centering
  \begin{tabular}{c}
    \hline
    hello \\
    \hline
  \end{tabular}
  \caption{A table}
\end{table}

\end{document} 

enter image description here

Related Question