# Raggedright and caption package

11,155

By default, short captions (spanning no more than one line) will be centered (this is so in standard LaTeX, and the caption package honors this convention); deactivate this using singlelinecheck=off:

\usepackage{caption}
\captionsetup{%
labelsep=newline,
justification=raggedright,
labelfont=bf,
singlelinecheck=off
}

Share:
11,155

Author by

### Nicolas M

Updated on June 22, 2022

• Nicolas M less than a minute

I am trying to format my tables and figures' captions with the caption package. What I want is the caption label separated from the caption text by a new line and both of them completly to the left margin. Here is my attempt (and MWE):

\documentclass[a4paper,10pt]{article}
\usepackage[english]{babel}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage{threeparttable,booktabs}
\usepackage{lipsum}

\usepackage{ragged2e}
\usepackage{caption}
\captionsetup{%
labelsep=newline,
justification=raggedright,
labelfont=bf
}

\begin{document}
\lipsum[1]
\begin{table}[htpb]\centering
\caption{Title.}
\begin{tabular}{@{}[email protected]{}}\toprule
abc & abc & abc \\
abc & abc & abc \\
\bottomrule
\end{tabular}
\end{table}
\lipsum[1]
\end{document}


And this is the output:

This only way to do what I want is to created a long title:

Then the raggedleft option works:

Am I missing something ? Why don't raggedright and raggedleft options work for a sort caption ?

• Gonzalo Medina almost 9 years
Add the option singlelinecheck=off to deactivate centered short captions.
• egreg almost 9 years
If you have an up-to-date TeX distribution, loading xunicode and xltxtra is not recommended any more.