表のキャプションが revtex で左揃えになっていません

表のキャプションが revtex で左揃えになっていません

現在、APS の記事を執筆しており、以下を使用しています。

\documentclass[%
 reprint,
 amsmath,amssymb,
 aps,nofootinbib,
]{revtex4-1}
%
\usepackage{graphicx}
\usepackage{dcolumn}
\usepackage{bm}
\PassOptionsToPackage{linktocpage}{hyperref}
\usepackage[hyperindex,breaklinks]{hyperref}
\usepackage{tabularx}
\usepackage{enumitem}
\usepackage{slashed}
\usepackage{array}

図のキャプションは、当然ながら左揃えになっています。ただし、次のコードを使用すると、表のキャプションは中央揃えになります。

{\renewcommand{\arraystretch}{1.2}
\begin{table*}[t]
  \centering
\begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} l l}
   \hline
   \hline
   \multicolumn{1}{c}{ \rule{0pt}{3ex} ...} & \multicolumn{1}{c}{...} & \multicolumn{1}{c}{...} \\
   \hline
... & ... & ... \\
    \hline
    \hline
    \end{tabular*}
    \caption{Centered caption.}\label{tab:1}
\end{table*}
}

表のキャプションを左揃え(表の下ではなく上)にするにはどうすればよいでしょうか。

答え1

ドキュメントrevtex4-1クラスには、不要な動作をオフにするオプションがありません。つまり、短いキャプションは常に中央に配置されます。また、パッケージはまだcaption適応されていないためrevtex、責任のあるコードを自分でパッチする必要があります。例:

\long\def\@makecaption#1#2{%
  \par
  \vskip\abovecaptionskip
  \begingroup
   \small\rmfamily
   \sbox\@tempboxa{%
    \let\\\heading@cr
    \@make@capt@title{#1}{#2}%
   }%
   \@ifdim{\wd\@tempboxa >\hsize}{%
    \begingroup
     \samepage
     \flushing
     \let\footnote\@footnotemark@gobble
     \@make@capt@title{#1}{#2}\par
    \endgroup
   }{%
     \global \@minipagefalse
     \hb@xt@\hsize{\hfil\unhbox\@tempboxa\hfil}%
   }%
  \endgroup
  \vskip\belowcaptionskip
}%

次のようにパッチを適用できます:

\long\def\@makecaption#1#2{%
  \par
  \vskip\abovecaptionskip
  \begingroup
   \small\rmfamily
    \begingroup
     \samepage
     \flushing
     \let\footnote\@footnotemark@gobble
     \@make@capt@title{#1}{#2}\par
    \endgroup
  \endgroup
  \vskip\belowcaptionskip
}

完全なサンプルドキュメントとして:

\documentclass[%
 reprint,
 amsmath,amssymb,
 aps,nofootinbib,
]{revtex4-1}

\makeatletter
\renewcommand\@makecaption[2]{%
  \par
  \vskip\abovecaptionskip
  \begingroup
   \small\rmfamily
    \begingroup
     \samepage
     \flushing
     \let\footnote\@footnotemark@gobble
     \@make@capt@title{#1}{#2}\par
    \endgroup
  \endgroup
  \vskip\belowcaptionskip
}
\makeatother

\begin{document}

Some text...

\begin{table}
  Test
  \caption{Test}
\end{table}

Some text...

\end{document}

パッケージ[1]\patchcmdが提供するよりエレガントなソリューション:etoolbox

\documentclass[%
 reprint,
 amsmath,amssymb,
 aps,nofootinbib,
]{revtex4-1}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@makecaption}{\@ifdim{\wd\@tempboxa >\hsize}}{\@firstoftwo}{}{}
\makeatother

\begin{document}

Some text...

\begin{table}
  Test
  \caption{Test}
\end{table}

Some text...

\end{document}

ただし、ドキュメント クラスまたはパッケージの内部にパッチを適用することは、パッチを適用したドキュメント クラスまたはパッケージの将来のバージョンで内部が変更される可能性があるため、通常はお勧めできません。

[1] 参照:patchcmdとxpatchの使い方を教えてください

関連情報