[Tex/LaTex] Wrapping or adding line breaks in header cell of siunitx’s S-type column

siunitxtables

When using the siunitx package, is it possible to either "wrap" or insert line breaks in the header cell of an S-type column (see Section 4.6 of the documentation)?

I have a relatively long table wherein I'd like to do this.

Below, I show the general usage of the S-type column. Then, I (kind of) mimic what what to achieve using a p-type column, but it would be nice to be able to wrap the header while taking advantage of siunitx's S-type column.

MWE:

\documentclass[12pt]{article}
\usepackage{siunitx, booktabs}
\sisetup{per-mode=symbol}
\setlength\parindent{0em}
\begin{document}
  \begin{tabular}{@{}cSSS@{}}
    \toprule
      &
      {Reaction 1 (\si{\mmol\per\s})} &
      {Reaction 2 (\si{\umol\per\minute})} &
      {Reaction 3 (\si{\pmol\per\hour})} \\
    \midrule
      Item 1 & 10 & 12 & 15 \\
      Item 2 & 20 & 22 & 25 \\
      Item 3 & 30 & 32 & 35 \\
    \bottomrule
  \end{tabular}
  \par\bigskip
  \begin{tabular}{@{}cp{2cm}p{2cm}p{2cm}@{}}
    \toprule
      &
      {Reaction 1 (\si{\mmol\per\s})} &
      {Reaction 2 (\si{\umol\per\minute})} &
      {Reaction 3 (\si{\pmol\per\hour})} \\
    \midrule
      Item 1 & 10 & 12 & 15 \\
      Item 2 & 20 & 22 & 25 \\
      Item 3 & 30 & 32 & 35 \\
    \bottomrule
  \end{tabular}
\end{document}

MWE output

Best Answer

You can nest any construct that allows linebreaking (a tabular or \parbox, or here I use \shortstack for a change)

enter image description here

\documentclass[12pt]{article}
\usepackage{siunitx, booktabs}
\sisetup{per-mode=symbol}
\setlength\parindent{0em}
\begin{document}
  \begin{tabular}{@{}cSSS@{}}
    \toprule
      &
      {\shortstack{Reaction 1\\(\si{\mmol\per\s})}} &
      {\shortstack{Reaction 2\\(\si{\umol\per\minute})}} &
      {\shortstack{Reaction 3\\(\si{\pmol\per\hour})}} \\
    \midrule
      Item 1 & 10 & 12 & 15 \\
      Item 2 & 20 & 22 & 25 \\
      Item 3 & 30 & 32 & 35 \\
    \bottomrule
  \end{tabular}

\end{document}
Related Question