14

enter image description here

I am trying to align caption to the left but its coming centered. Please see the figure. The code is

\begin{figure}[!t]
\includegraphics[scale=0.22]{Figure 1.pdf}
\caption{The caption is coming to the center. It should be aligned to the left. }
\label{Figure 1}
\end{figure}

The previously mentioned solutions were tried. But they didn't work. How can I left-align a caption?

Any solution for the above problem.

A full MWE:

\documentclass[%
 aip,
 amsmath,amssymb,
]{revtex4-1}
\draft

\usepackage{graphicx}
\usepackage{dcolumn}
\usepackage{bm}
\usepackage{times}
\DeclareGraphicsExtensions{.pdf,.jpeg,.jpg, .png, .eps, .tiff}
\usepackage{epstopdf}
\usepackage{lipsum}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{array}
\usepackage{natbib}
\usepackage{color}
\usepackage{grffile}
\usepackage{caption}
\usepackage{boxhandler}
\usepackage{float}
\begin{document}

\begin{figure}[!t]
\centering
\includegraphics[scale=0.5]{Figure 3.pdf}
\caption{}   
\label{Figure 4}
\end{figure}
\end{document}
  • Which document class are you using? – user11232 Oct 27 '15 at 5:15
  • Does \usepackage{caption} and \captionsetup{format=hang} work? – user11232 Oct 27 '15 at 5:18
  • I am already using the \usepackage{caption}. And By additionally using \captionsetup{format=hang} does not seem to provide the solution – user87834 Oct 27 '15 at 5:22
  • Please add a compilable code starting from \documentclass{...} and ending at \end{document}. Now we are really clueless as to why and what is not working for you. – user11232 Oct 27 '15 at 5:27
  • 1
    See my above comment please. – user11232 Oct 27 '15 at 5:27
12

You should add the following instruction to the preamble, after loading the caption package:

\captionsetup{justification=raggedright,singlelinecheck=false}

If you want "hanging indentation" of multiline captions, you should add the option

format=hang

to the argument of \captionsetup.

A full MWE (with all packages not relevant for the issue at hand removed from the preamble):

enter image description here

\documentclass[aip,amsmath,amssymb,draft]{revtex4-1}
%%% \draft % this instruction is deprecated -- use 'draft' option instead

\usepackage[demo]{graphicx} % remove 'demo' option in real document
\usepackage{times}
\usepackage{caption}
\captionsetup{justification   = raggedright,
              singlelinecheck = false}
\begin{document}
\setcounter{figure}{2}  % just for this example

\begin{figure}[!t]
\includegraphics[width=\textwidth]{Figure3.pdf}
\caption{The caption is now no longer centered. Instead, it is left-aligned, which is also known as ``ragged-right''.}   
\label{fig:3}
\end{figure}

\end{document}
  • caption is not recommended to be used with this class. Remove caption package and the captions are left aligned. Why OP loaded caption is not clear to me. Similarly \draft is obsolete over draft option. – user11232 Oct 27 '15 at 6:40
  • @HarishKumar - Without the caption package, the captions will be fully justified only if they're longer than one line. Single-line captions will still be centered. – Mico Oct 27 '15 at 6:58
  • But caption is not compatible with revtex4-1, hence it will break something some where. – user11232 Oct 27 '15 at 6:58
  • caption package is used for the working of \captionof in some of the figures. – user87834 Oct 27 '15 at 7:02
  • 1
    @snoram - Instead of width=\textwidth, one can of course set width=0.8\textwidth -- or any other width fraction less than 1. (For reasons that are hopefully obvious, one shouldn't make the figure wider than \textwidth.) If you choose a width factor less than 1, you should probably also supply the instruction \centering, in order to center the image file horizontally. – Mico Sep 14 '18 at 13:19
1

I know this is a bit old, but I came across this after having a similar problem and found a simple solution that isn't mentioned for those who are just looking to use \captionof for figures (like in minipages as I was using).

The caption package has the wording in their docs: And if you are just interested in using the command \captionof, loading of the very small capt-of package is usually sufficient.

Changing \usepackage{caption} to \usepackage{capt-of} worked for me. Because capt-of is small, it doesn't interfere with other revtek captioning like full line usage -the caption uses the full line on both left and right side.

0

The caption package is not recommended, as it interferes with the caption formatting of revtex. The boxhandler package doesn't seem to have this drawback.

A few comments about your code: ther's a warning in the .log file to inform that the draft command is obsolete and should be replaced with the draft option for the document class. The times package is also obsolete, and should be replaced with mathptmx or, better, newtxtext, newtxmath, which uses TeX Gyre Termes, a more complete clone of Times.

\documentclass[%
 aip,
 amsmath,amssymb,
]{revtex4-1}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{dcolumn}
\usepackage{bm}
\usepackage{newtxtext, newtxmath}
\DeclareGraphicsExtensions{.pdf,.jpeg,.jpg, .png, .eps, .tiff}
\usepackage{epstopdf}
\usepackage{lipsum}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{array}
\usepackage{natbib}
\usepackage{xcolor}
\usepackage{grffile}
\usepackage{boxhandler}
\usepackage{float}

\begin{document}

\bxfigure{\textit{Piero di Cosimo}, The Death of Procris (1495)}{\includegraphics[scale=0.4]{Piero_di_Cosimo_1}}

\end{document} 

enter image description here

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.