57

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
92

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

  • 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 at 13:01

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.