
현재 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}
그러나 내부는 패치된 문서 클래스 또는 패키지의 향후 버전에서 변경될 수 있으므로 문서 클래스 또는 패키지의 내부를 패치하는 것은 일반적으로 좋지 않은 생각입니다.