16

I wish to type this table in REVTeX; however, the code below does not work for \documentclass{revtex4}. (It does work for the article document class, though.)

enter image description here

\documentclass{revtex4}
\usepackage{array,mathtools,amssymb,booktabs}
\newcolumntype{C}{>{$}c<{$}}
\begin{document}
    \begin{tabular}{cCCC}
      \toprule
      \multicolumn{2}{c}{} & K & H\\\midrule
      A & a & 1& 4\\\cmidrule(lr){2-4}
      B & b & 2 & 5\\\cmidrule(lr){1-4}
      \multicolumn{2}{c}{C}& 3 & 6\\\bottomrule
    \end{tabular}
\end{document}

The code is from the source of this page. Thanks to the generous cfr.

2 Answers 2

17

Update This answer addresses a workaround for revtex4-1 which is not needed with current releases (revtex4-2)


booktabs sets the default widths in a font dependent way (em units) but it seems that revtex does not set up the font until \begin{document} so you need to delay setting the rule widths via the \AtBeginDocument directive shown below.

\documentclass{revtex4}
\usepackage{array,mathtools,amssymb,booktabs}
\newcolumntype{C}{>{$}c<{$}}

\AtBeginDocument{%
  \heavyrulewidth=.08em
  \lightrulewidth=.05em
  \cmidrulewidth=.03em
  \belowrulesep=.65ex
  \belowbottomsep=0pt
  \aboverulesep=.4ex
  \abovetopsep=0pt
  \cmidrulesep=\doublerulesep
  \cmidrulekern=.5em
  \defaultaddspace=.5em
}

\begin{document}
    \begin{tabular}{cCCC}
      \toprule
      \multicolumn{2}{c}{} & K & H\\\midrule
      A & a & 1& 4\\\cmidrule(lr){2-4}
      B & b & 2 & 5\\\cmidrule(lr){1-4}
      \multicolumn{2}{c}{C}& 3 & 6\\\bottomrule
    \end{tabular}
\end{document}
8
  • Thank you. What is the purpose for this paragraph "\AtBeginDocument{...}" ? Where should I input this?
    – wonderich
    Jan 12, 2015 at 1:20
  • To avoid the duplicated code, couldn't one just do \AtBeginDocument{\usepackage{booktabs}} (also removing booktabs from the \usepackage on line 2, of course)? Jan 12, 2015 at 1:20
  • 2
    This is overwriting revtex4's own definition of commands such as \toprule. If this is for submission somewhere requiring the use of revtex4, I doubt this is a good idea at all.
    – cfr
    Jan 12, 2015 at 1:22
  • 1
    But it defines \toprule etc., right? So loading booktabs overwrites those definitions.
    – cfr
    Jan 12, 2015 at 2:03
  • 2
    @DavidCarlisle After these comments, it's hard to figure out what's the right way to proceed and whether the definitions get overwritten...
    – Dr_Zaszuś
    Aug 2, 2017 at 13:31
2

This problem was already solved in RevTeX 4.2e (released October 5, 2020)

https://journals.aps.org/revtex

1
  • 1
    You are not wrong, but your answer mentions revtex4-2, but OP uses the deprecated revtex4 (so it doesn't really answer the original question). Nothing was changed in this area in RevTeX (and there are no plans to update RevTeX 4 and 4.1 in this regard in the future) Apr 8, 2021 at 16:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .