3

I am having trouble getting the multirow command to work with the siunitx package in the following example:

\documentclass[]{article}
\usepackage{siunitx}
\usepackage{multirow}
\usepackage{booktabs}

\begin{document}
\begin{table}[tbh]
    \centering
    \begin{tabular}{llSSSS}
    \toprule
    A & B & {C} & {D} & {E} & {F} \\
    \midrule
    \multirow{2}{*}{Value 1} & \multirow{2}{*}{1.2e-4} & \multirow{2}{*}{1.0} & 3.0                  & \multirow{2}{*}{1.0} & 0.3 \\
                             &                         &                      & 4.0                  &                      & 0.7 \\ \midrule
    \multirow{2}{*}{Value 2} & 3.2e-4                  & \multirow{2}{*}{2.0} & \multirow{2}{*}{1.0} & \multirow{2}{*}{9.2} & 0.4 \\
                             & 1.2e-8                  &                      &                      &                      & 0.5 \\
    \bottomrule
    \end{tabular}
\end{table}
\end{document}

The only way I can remedy the error is to replace

\begin{tabular}{llSSSS}

with

\begin{tabular}{llcccc}

This, however, defeats the purpose of using the siunitx package in the present case.

Does anyone have a solution to this problem? Thank you in advance.

  • Hi, welcome. Your example missed the booktabs package, and you also need to have braces around the non-numerical content in S columns, e.g. {D}. I took the liberty of fixing those things in your example, hope that's fine. – Torbjørn T. Mar 4 '17 at 12:02
  • Welcome to TeX - LaTeX! If you add Thorbjørn's braces around the multirow commands {\multirow{}...{}} then you deal with the error, but might not get the expected alignment. – Andrew Swann Mar 4 '17 at 12:04
  • You are correct @AndrewSwann. This allows me to proceed without error and correctly formats values not within the multirow operator. I attempted to use the \tablenum command and received the error: TeX capacity exceeded, sorry [grouping levels=255]. ...\tablenum[table-format=1.2e-1]{1.2e-4}}} & – Brad D Mar 4 '17 at 12:18
2

A safer alternative is to use a [c] column and add \tablenum to all the numbers. It isn't obvious from this example, but adding extra digits shows that it is working.

\documentclass[]{article}
\usepackage{siunitx}
\usepackage{multirow}
\usepackage{booktabs}

\begin{document}
\begin{table}[tbh]
    \centering
    \begin{tabular}{llcccS}
    \toprule
    A & B & C & D & E & {F} \\
    \midrule
    \multirow{2}{*}{Value 1} & \multirow{2}*{1.2e-4} & \multirow{2}{*}{\tablenum{1.0}} & \tablenum{3.0}                  & \multirow{2}{*}{\tablenum{1.0}} & 0.3 \\
                             &                       &                                 & \tablenum{4.0}                  &                                 & 0.7 \\ \midrule
    \multirow{2}{*}{Value 2} & 3.2e-4                & \multirow{2}{*}{\tablenum{2.0}} & \multirow{2}{*}{\tablenum{1.0}} & \multirow{2}{*}{\tablenum{9.2}} & 0.4 \\
                             & 1.2e-8                &                                 &                                 &                                 & 0.5 \\
    \bottomrule
    \end{tabular}
\end{table}
\end{document}
0

An alternative without multirow and siunitx but makecell is added:

\documentclass[]{article}
\usepackage{booktabs, makecell}

\begin{document}
\begin{table}[htb]
    \centering
    \begin{tabular}{llcccc}
    \toprule
    A & B & C & D & E & {F} \\
    \midrule
Value 1 & 1.2e-4    & 1.0   & \makecell{3.0\\ 4.0}      & 1.0   & \makecell{0.3\\ 0.7}  \\
    \midrule
Value 2 & \makecell{3.2e-4\\ 1.2e-8}    & 2.0   & 1.0   & 9.2   & \makecell{0.4\\0.5}   \\
    \bottomrule
    \end{tabular}
\end{table}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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