revtex4-1 中的“ruledtabular”环境是否会破坏“siunitx”中的 S 列?

revtex4-1 中的“ruledtabular”环境是否会破坏“siunitx”中的 S 列?

我正在尝试将revtex4-1文档类用于论文,并且我想对齐数字列中的小数点。我正在尝试使用包S中的列类型siunitx。如果我使用ruledtabularrevtex4-1 类定义的环境,则使用 S 列会锁定 pdflatex 编译。我可以在常规环境中使用 S 列tabular

有人能解决这种情况吗?还是我需要尝试其他软件包。我似乎找不到 revtex4-1 是否提供十进制对齐列。

这是MWE:

\documentclass[rmp,reprint]{revtex4-1}
\usepackage{siunitx}

\begin{document}
\title{Using S Columns with revtex4-1}

\begin{abstract}
Using S columns from \texttt{siunitx} doesn't seem to work.\end{abstract}
\maketitle

A table using \texttt{ruledtabular} environment with \texttt{ccc} columns works.

\begin{table}[h!]
\caption{Table of some gyromagnetic ratios and nuclear spins}
\begin{ruledtabular}\begin{tabular}{ccc}

    Nuclide & {$\gamma_n$ (MHz/T)}& spin quantum number\\

    $^1$H & 42.576 & $\frac{1}{2}$\\

    $^2$H & 6.536 & $ 1$ \\

\end{tabular}\end{ruledtabular}
\end{table}

A table NOT using \texttt{ruledtabular} environment with \texttt{cSc} columns works.
\begin{table}[h!]
\caption{Table of some gyromagnetic ratios and nuclear spins}
\begin{tabular}{cSc}

    Nuclide & {$\gamma_n$ (MHz/T)}& spin quantum number\\

    $^1$H & 42.576 & $\frac{1}{2}$\\

    $^2$H & 6.536 & $ 1$ \\

\end{tabular}
\end{table}
\end{document}

答案1

ruledtabular环境除了插入双水平线外,还修改了相当多与表相关的参数。结果,正如您所发现的,包S的列类型siunitx似乎与环境不兼容。顺便说一句,包的列类型也是ruledtabular如此。Ddcolumn

ruledtabular幸运的是,使用标准环境重新创建环境的外观并不太难tabular*。在下面的代码中,请注意指令的使用@{\extracolsep{\fill}}、双重\hline指令以及\Tstrut(“top strut”)和\Bstrut(“bottom strut”)的使用,以重新创建由 生成的垂直空白量ruledtabular

在此处输入图片描述

\documentclass[rmp,reprint]{revtex4-1}
\usepackage{siunitx}
% Define struts, as suggested by Claudio Beccari in TeX and TUG News in 1993.
% The vertical heights (+2.4ex and -1.3ex) are chosen to mimic the spacing
% generated by "ruledtabular".
\newcommand\Tstrut{\rule{0pt}{2.4ex}}       % top strut
\newcommand\Bstrut{\rule[-1.3ex]{0pt}{0pt}} % bottom strut


\begin{document}
\title{How to make S columns work with revtex4-1}

\begin{abstract}
Using S columns from \texttt{siunitx} can work.\end{abstract}
\maketitle

\begin{table}[h!]
\caption{Ruledtabular, tabular, and ccc}
\begin{ruledtabular}\begin{tabular}{ccc}
Nuclide & \multicolumn{1}{c}{$\gamma_n$ (MHz/T)}& spin quantum number\\
$^1$H & 42.576 & $\frac{1}{2}$\\
$^2$H & 6.536 & $ 1$ \\
\end{tabular}\end{ruledtabular}
\end{table}

\begin{table}[h!]
\caption{tabular*, struts, and cSc}
\begin{tabular*}{\columnwidth}{c@{\extracolsep{\fill}}
     S[table-format=2.3]c}
\hline\hline
Nuclide\Tstrut & {$\gamma_n$ (MHz/T)}& spin quantum number\\
$^1$H & 42.576 & $\frac{1}{2}$\\
$^2$H\Bstrut & 6.536 & $ 1$ \\
\hline\hline
\end{tabular*}
\end{table}

\end{document}

答案2

@Mico 为我指明了正确的方向,而且效果很好,但我想给出另一个答案。我发现revtex4-1定义了一些表规则:\toprule将产生双重规则,colrule将产生单一规则。但是,垂直间距略有偏差。以下是对 @Mico 的答案的轻微修改,不使用 struts 并使用预定义的双重规则:

\documentclass[rmp,reprint]{revtex4-1}
\usepackage{siunitx}

\begin{document}
\title{Using S Columns with revtex4-1}

\maketitle

\begin{table}[h!]
\caption{Table of \texttt{ruledtabular} and \texttt{ccc} }
\begin{ruledtabular}\begin{tabular}{ccc}

    Nuclide & {$\gamma_n$ (MHz/T)}& spin quantum number\\

    $^1$H & 42.576 & $\frac{1}{2}$\\

    $^2$H & 6.536 & $ 1$ \\
\end{tabular}\end{ruledtabular}
\end{table}

\begin{table}[h!]
\caption{Table with \texttt{tabular*} and \texttt{cSc}}
\begin{tabular*}{\columnwidth}{c@{\extracolsep{\fill}}Sc}
   \toprule   \vspace{-6pt}\\

    Nuclide & {$\gamma_n$ (MHz/T)}& spin quantum number\\

    $^1$H & 42.576 & $\frac{1}{2}$\\

    $^2$H & 6.536 & $ 1$ \\
\botrule


\end{tabular*}
\end{table}
\end{document}

相关内容