# Table caption not left aligned in revtex

I am currently writing an APS article and use:

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


My figure captions are left aligned, as they should be. The table captions, however, are centered if I use the following code:

{\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*}
}


How can I make the table captions left aligned (and above and not below the table) as well?

• Are you sure that the table captions are not centred only because they are too short to fill a line? – campa Jun 10 '16 at 13:17
• The table captions are centered and they are too short to fill a line, yes. But even though they are short, I want them to be left aligned and not centered. – Thomas Jun 10 '16 at 14:11

The revtex4-1 document class do not offer an option to switch the unwanted behavior off, i.e. short captions are always centered. And since the caption package is not adapted to revtex yet one need to patch the responsible code for yourself, e.g.:

\long\def\@makecaption#1#2{%
\par
\vskip\abovecaptionskip
\begingroup
\small\rmfamily
\sbox\@tempboxa{%
\@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
}%


could be patched to:

\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
}


As complete example document:

\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}


A more elegant solution using \patchcmd offered by the etoolbox package [1]:

\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}


But please be aware that patching internals of document classes or packages is usually a bad idea since internals are subject of change in future versions of the patched document class or package.