我知道 documentclass与(和)包revtex4-1
不兼容,因此在使用caption
subcaption
subfig
包我需要添加选项[caption=false]
,详细说明如下卡尔科勒和埃格尔。
但是,即使选择了此选项,[caption=false]
我仍然会得到未对齐的副标题。主标题对齐得很好,但长副标题却不是。另一方面,将对齐方式更改为 可以[justification=raggedright]
按预期工作。其他\documentclass{article}
一切都很好。
有什么方法可以使长_sub_captions 对齐吗revtex4-1
?
最小示例:
\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.
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}
答案1
使用该caption=false
选项时,subfig
加载caption3
包进行配置。此包定义了各种可能的对齐样式。但是,请看一下它justified
的定义方式,而不是其他方式:
\DeclareCaptionJustification{justified}{}
\DeclareCaptionJustification{centering}{\centering}
\DeclareCaptionJustification{centerfirst}{\centerfirst}
\DeclareCaptionJustification{centerlast}{\centerlast}
\DeclareCaptionJustification{raggedleft}{\raggedleft}
\DeclareCaptionJustification{raggedright}{\raggedright}
因此,该软件包只是假定对齐是默认设置,因此不会采取任何措施来强制执行它 - 这在使用 REVTeX 时似乎是错误的。
解决方案很简单。只需在之后覆盖声明即可自动重新对齐:
\usepackage[caption=false]{subfig} % loads caption3
\usepackage{ragged2e} % for the \justifying macro
\DeclareCaptionJustification{justified}{\justifying}
由于的默认选项subfig
是无论如何使用justified
,我们需要做的就是修复其定义。
答案2
谁可能会在这里寻找答案
请注意,revtex
提供命令\onecolumngrid
和\twocolumngrid
。根据我的经验,它们有助于处理需要两列的浮点数。
这是一个至少接近选项的可能解决方案justified
:
\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}
如果您尝试在 中使用subfloat
或,phantomcaption
revtex
这个答案可能会对你有帮助。