5

I am trying to used the revtex4-1 document class for a paper, and I want to align the decimal point in columns of numbers. I am trying to use the S column type from the siunitx package. If I use the ruledtabular environment defined by the revtex4-1 class, using an S column locks up the pdflatex compilation. I can use the S column in a regular tabular environment.

Does someone have a fix for this situation, or do I need to try another package. I can't seem to find whether revtex4-1 provides for decimal aligned columns.

Here's the 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}
Bill N
  • 652
  • 6
  • 16

2 Answers2

4

The ruledtabular environment, in addition to inserting double horizontal rules, modifies quite a few table-related parameters. As a result, as you've discovered, the S column type of the siunitx package does not appear to be compatible with the ruledtabular environment. The same is true, by the way, for the D column type of the dcolumn package.

Fortunately, it's not too difficult to re-create the look of a ruledtabular environment using a standard tabular* environment. In the code below, note the use of the @{\extracolsep{\fill}} directive, the doubled \hline directives, and the use of \Tstrut ("top strut") and \Bstrut ("bottom strut") to re-create the amount of vertical whitespace generated by ruledtabular.

enter image description here

\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}
Mico
  • 506,678
3

@Mico pointed me in the right direction and it works very well, but I want to give an alternate answer. I found that revtex4-1 has some table rules defined: \toprule will produce double rules and colrule will produce a single rule. However, the vertical spacing is slightly off. Here's a slight modification to @Mico 's answer without using struts and using the predefined double rules:

\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}
Bill N
  • 652
  • 6
  • 16