# How to get justified subcaptions with \subfloat in revtex

I know that the documentclass revtex4-1 is incompatible with the caption (and subcaption) package and thus when using the subfig package I need to add the option [caption=false] as elaborated by karlkoeller and egreg.

However, even with the option [caption=false] I still get subcaptions that are not justified. The main caption is nicely justified, but long subcaptions are not. On the other hand, changing the justification to [justification=raggedright] works as expected. Also with \documentclass{article} things are fine.

Any way of making long _sub_captions justified in revtex4-1?

Minimum example:

\documentclass[reprint,amsmath,amssymb,aps,prd]{revtex4-1}
% \documentclass{article}  % works with docclass article but not with revtex
\usepackage{graphicx}
\usepackage[caption=false,justification=justified]{subfig}
% raggedright works, justified does not
\usepackage{todonotes}

\begin{document}

\begin{figure*}[htb]
\centering
\subfloat[Long text here. Long text here. Long irregular text here.
More irregular text here. Long text here. Broken up with some other words.
Trying to show the ragged effect left and right.
{\missingfigure[figwidth=5cm]{}}
\hspace{1cm}
\subfloat[Long text here. Long text here. Long irregular text here.
More irregular text here. Long text here. Broken up with some other words.
Trying to show the ragged effect left and right.
{\missingfigure[figwidth=5cm]{}}
\caption{Large caption spanning both subfigures.
This caption actually is justified as it is supposed to be.
Unfortunately the same does not go for the subcaptions above
which are not justified. Using raggedright'' in the captionsetup
actually works also on the subcaptions. justified'' however does not.}
\end{figure*}

\end{document}

• Are you sure they are supposed to be justified? – cfr Aug 1 '18 at 3:03
• On page 16 of the REVTeX 4.1 Author's Guide it only says very generally: "Captions less than one line long are centered under the figure, otherwise they span the width of the figure." It says nothing about subcaptions explicitly, so I'd have thought subcaptions should be justified as well. – Zaus Aug 1 '18 at 11:05

For whom might end up here looking for an answer

Note that revtex provides the commads \onecolumngrid and \twocolumngrid. From my experience they help dealing with floats that require two columns.

Here is possible solution that at least takes it close to the justified option:

\documentclass[reprint,amsmath,amssymb,aps,prd]{revtex4-1}
% \documentclass{article}  % works with docclass article but not with revtex
\usepackage{graphicx}
\usepackage[caption=false, justification=centerlast]{subfig}
% raggedright works, justified does not
\usepackage{todonotes}

\begin{document}
\onecolumngrid% Mind one empty line below

\begin{figure}[htb]
% \centering
\subfloat[Long text here. Long text here. Long irregular text here.
More irregular text here. Long text here. Broken up with some other words.
Trying to show the ragged effect left and right.
{\missingfigure[figwidth=5cm]{}}
\hspace{1cm}
\subfloat[Long text here. Long text here. Long irregular text here.
More irregular text here. Long text here. Broken up with some other words.
Trying to show the ragged effect left and right.
{\missingfigure[figwidth=5cm]{}}
\caption{Large caption spanning both subfigures.
This caption actually is justified as it is supposed to be.
Unfortunately the same does not go for the subcaptions above
which are not justified. Using raggedright'' in the captionsetup
actually works also on the subcaptions. justified'' however does not.}
\end{figure}
\twocolumngrid

\end{document}


Result:

If you are trying to use subfloat or phantomcaption in revtex, this answer might help you.

When using the caption=false option, subfig loads the caption3 package for configuration. This package defines the various possible justification styles. However, have a look at how justified is defined, as opposed to the others:

\DeclareCaptionJustification{justified}{}
\DeclareCaptionJustification{centering}{\centering}
\DeclareCaptionJustification{centerfirst}{\centerfirst}
\DeclareCaptionJustification{centerlast}{\centerlast}
\DeclareCaptionJustification{raggedleft}{\raggedleft}
\DeclareCaptionJustification{raggedright}{\raggedright}


So the package just assumes that justification is the default anyway and therefore does not do anything to enforce it - which appears to be wrong when using REVTeX.

The solution is simple. Just overwrite the declaration afterwards to automatically re-justify:

\usepackage[caption=false]{subfig} % loads caption3
\usepackage{ragged2e} % for the \justifying macro
\DeclareCaptionJustification{justified}{\justifying}


Since the default option of subfig is to use justified anyway, all we needed to do was to fix its definition.