
Actualmente estoy escribiendo un artículo de APS y uso:
\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}
Los títulos de mis figuras están alineados a la izquierda, como deberían estar. Los títulos de las tablas, sin embargo, están centrados si uso el siguiente código:
{\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*}
}
¿Cómo puedo hacer que los títulos de las tablas estén alineados a la izquierda (y encima y no debajo de la tabla) también?
Respuesta1
La revtex4-1
clase de documento no ofrece una opción para desactivar el comportamiento no deseado, es decir, los títulos breves siempre están centrados. Y dado que el caption
paquete revtex
aún no está adaptado, es necesario parchear el código responsable usted mismo, por ejemplo:
\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
}%
podría parchearse a:
\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
}
Como documento de ejemplo completo:
\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}
Una solución más elegante que \patchcmd
ofrece el etoolbox
paquete [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}
Pero tenga en cuenta que aplicar parches a los componentes internos de las clases o paquetes de documentos suele ser una mala idea, ya que los componentes internos están sujetos a cambios en futuras versiones de la clase o paquete de documentos parcheados.
[1] Ver también:Por favor enseñe el uso de patchcmd y xpatch.