Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.