2

I need to left justify long table captions, without overwriting all the special formatting (font etc.) of the style file I am required to use.

I tried to use

\usepackage{caption}
\captionsetup[table]{singlelinecheck=false}

but this affects everything. I want to just change a couple of problematic captions.

Is there any way to change the alignment just within a single caption? flushleft did not work.

2

Just issue a \raggedright within the \caption in question:

\documentclass{article}
\begin{document}

\begin{table}
  % This caption will be \raggedright.
  \caption[First caption]{\raggedright Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
  Phasellus ac magna eu risus consectetur fringilla vitae at mi. 
  Suspendisse nunc massa, maximus sit amet dignissim et, sodales at enim. 
  Nullam eleifend tincidunt sem, sed posuere ligula auctor sed. 
  Duis vitae tincidunt erat, id varius felis.}
\end{table}

\begin{table}
  % This caption will be justified.
  \caption[Second caption]{Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
  Phasellus ac magna eu risus consectetur fringilla vitae at mi. 
  Suspendisse nunc massa, maximus sit amet dignissim et, sodales at enim. 
  Nullam eleifend tincidunt sem, sed posuere ligula auctor sed. 
  Duis vitae tincidunt erat, id varius felis.}
\end{table}

\end{document}

Since the captions are long, you're bound to use the optional argument to set something shorter in the LoT. As such, there should be no concern about \protection for the alignment.

| improve this answer | |
  • Thanks - that's solved it. I don't actually need the short caption, but it makes it work so no reason not to include it. – Esme_ May 13 '15 at 7:27
2

Just to show the caption's way. You can use \captionsetup inside the table environment, making the effect local. You have to use \captionsetup{justification=raggedright}. If you want hyphenation inside the captions, use RaggedRight and this needs \usepackage{ragged2e}

\documentclass{article}
\usepackage{caption}
\begin{document}

\begin{table}
  % This caption will be \raggedright.
  \captionsetup{justification=raggedright}
  \caption[First caption]{Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  Phasellus ac magna eu risus consectetur fringilla vitae at mi.
  Suspendisse nunc massa, maximus sit amet dignissim et, sodales at enim.
  Nullam eleifend tincidunt sem, sed posuere ligula auctor sed.
  Duis vitae tincidunt erat, id varius felis.}
\end{table}

\begin{table}
  % This caption will be justified.
  \caption[Second caption]{Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  Phasellus ac magna eu risus consectetur fringilla vitae at mi.
  Suspendisse nunc massa, maximus sit amet dignissim et, sodales at enim.
  Nullam eleifend tincidunt sem, sed posuere ligula auctor sed.
  Duis vitae tincidunt erat, id varius felis.}
\end{table}

\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.