TransWikia.com

How to get justified subcaptions with subfloat in revtex

TeX - LaTeX Asked by Zaus on January 27, 2021

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 as elaborated by karlkoeller and egreg.

However, even with the option 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{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. 
    Addsomeveryextremelylongwords tomakethingsworse andthus moreclear.]
    {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. 
    Addsomeveryextremelylongwords tomakethingsworse andthus moreclear.]
    {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}

One Answer

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.
    Addsomeveryextremelylongwords tomakethingsworse andthus moreclear.]
    {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.
    Addsomeveryextremelylongwords tomakethingsworse andthus moreclear.]
    {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: two subfigures side by side with justified captions below them

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

Answered by caenrigen on January 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP