68

I'm having a problem with centering my figure captions. Particuarly, I know that we can use \usepackage[justification=centering]{caption} to center captions, however, I'm interested in just centering a specific caption. I've read the caption manual but no luck, so my question is: How can I center a specific caption?

  • 1
    You can use \captionsetup{justification=centering} in the specific table or figure environment (after \usepackage{caption}. – egreg Jan 24 '13 at 15:14
  • Thanks @egreg, it worked! Please add as an aswer so I can close the question. :) – Marcos Roriz Junior Jan 24 '13 at 15:25
106

You can use \captionsetup in a specific figure (or table) environment:

\documentclass{article}

\usepackage{graphicx}
\usepackage{caption}

\begin{document}

\begin{figure}[hp]
\centering

\includegraphics[scale=.30]{example-image-a}

\caption{A caption with long text bla bla bla bla bla bla bla bla
bla bla bla bla bla bla bla bla bla bla}
\end{figure}

\begin{figure}[hp]
\centering
\captionsetup{justification=centering}

\includegraphics[scale=.30]{example-image-b}

\caption{A caption with long text bla bla bla bla bla bla bla bla
bla bla bla bla bla bla bla bla bla bla}
\end{figure}

\begin{figure}[hp]
\centering
\captionsetup{justification=centering,margin=2cm}

\includegraphics[scale=.30]{example-image-c}

\caption{A caption with long text bla bla bla bla bla bla bla bla
bla bla bla bla bla bla bla bla bla bla}
\end{figure}

\end{document}

enter image description here

| improve this answer | |
  • 1
    Does this also work for subfigures? – Shuvo Sarker Nov 6 '18 at 8:39
  • @ShuvoSarker I don't know, why don't you try? – egreg Nov 6 '18 at 8:57
  • @ShuvoSarker It does not, they just jump all the way to the right! Very annoying... – Jan M. Mar 8 '19 at 13:01

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