# Don't work together: siunitx, multicolumn and uncertainty?

I want a good-looking table with siunitx. I thought I can use the S-table from it to sort the numbers (all decimal points under each other etc.).

Unfortunately, It didn't work properly. I get an this error message:

siunitx error: "invalid-number" Invalid numerical input 'e'


I can't find the solution, can anybody help me here?

 \documentclass{article}
\usepackage[
locale=DE,
per-mode=fraction,
output-decimal-marker={{,}},
separate-uncertainty=true,
range-phrase={{ bis }},
]{siunitx}
\begin{document}

\begin{table}[H]
\centering
\caption{Test}
\label{tab:test}
\begin{tabular}{|l|*{6}{S[table-format=-3.0]|}}
\hline
& \multicolumn{5}{c|}{Offset [\si{\milli\volt}]} & {Mean Offset $\pm$ max. Variance  [\si{\milli\volt}]} \\ \hline \hline
P1        & -241    & -274    & -272    & -258    & -283   & -266 \pm 20           \\ \hline
P2        & -94     & -99     & -100    & -114    & -105   & -102 \pm 18           \\ \hline
P3        & 600     & 593     & 595     & 580     & 590    & 511 \pm 100            \\ \hline
P4        & 300     & 300     & 300     & 290     & 297    & 301 \pm 50            \\ \hline
\end{tabular}
\end{table}
\end{document}


Edit:

The Answer for this question is nearly this post: https://tex.stackexchange.com/a/354925/125143

Unfortunately, the uncertainty for example \pm 20is not shown in output pdf. Why?

• siunitx will add the scientific notation for4 you; it shouldn't be in the source. Your example doesn't really reflect your question -- it doesn't use the sinutix column types – Chris H Feb 21 '17 at 12:04
• Possible duplicate of siunitx tabular numbers with separated uncertainty – Chris H Feb 21 '17 at 12:05
• @ChrisH - It's not a duplicate. Instead, it's a case of the OP not realizing that he/she needs to "hide" non-numeric data from the operation of an S column type. – Mico Feb 21 '17 at 12:14
• You mention "uncertainty" in the title of your posting, but it doesn't appear to occur in your code. Please either fix the title or provide uncertainty-related code. – Mico Feb 21 '17 at 12:26
• @Mico that may be true but it's hard to tell from the example with c column types; the accepted answer is very close to what the OP needs – Chris H Feb 21 '17 at 13:15

please read https://www.inf.ethz.ch/personal/markusp/teaching/guides/guide-tables.pdf or have a look at Beautiful table samples

 \documentclass{article}
\usepackage[
locale=DE,
per-mode=fraction,
output-decimal-marker={{,}},
separate-uncertainty=true,
range-phrase={{ bis }},
]{siunitx}
\begin{document}

\begin{table}
\centering
\caption{Test}
\label{tab:test}
\begin{tabular}{|l|*{5}{S[table-format=-3.0]|}S[table-format=-3.0,table-figures-uncertainty=3]|}
\hline
& \multicolumn{5}{c|}{Offset [\si{\milli\volt}]} & {Mean Offset $\pm$ max. Variance  [\si{\milli\volt}]} \\ \hline \hline
P1 & -241& -274 & -272& -258 & -283   & -266 \pm 20\\ \hline
P2 & -94 & -99  & -100& -114 & -105   & -102 \pm 18\\ \hline
P3 & 600 & 593  & 595 & 580  & 590    & 511 \pm 100\\ \hline
P4 & 300 & 300  & 300 & 290  & 297    & 301 \pm 50\\ \hline
\end{tabular}
\end{table}
\end{document}


My suggestion:

(but I am not yet happy with the last column)

\documentclass{article}
\usepackage[
locale=DE,
per-mode=fraction,
output-decimal-marker={{,}},
range-phrase={{ bis }},
]{siunitx}

\usepackage{booktabs}
\renewcommand{\arraystretch}{1.3}
\setlength{\tabcolsep}{5pt}

\usepackage{caption}
\captionsetup[table]{skip=5pt}

\begin{document}

\begin{table}
\centering
\caption{Test}
\label{tab:test}
\begin{tabular}{%
@{}
l
*{5}{S[table-format=-3.0, tight-spacing=true,table-alignment=right]}
@{\extracolsep{8pt}}
S[table-format=-3.0,separate-uncertainty=true,table-figures-uncertainty=3,table-align-uncertainty=true]
@{}
}
\toprule
& \multicolumn{5}{c}{Offset [\si{\milli\volt}]} & {Mean Offset $\pm$ max. Variance  [\si{\milli\volt}]} \\
\cmidrule(r{6pt}){1-1}\cmidrule(l{5pt}){2-6}\cmidrule{7-7}
P1 & -241& -274 & -272& -258 & -283   & -266 \pm 20\\
P2 & -94 & -99  & -100& -114 & -105   & -102 \pm 18\\
P3 & 600 & 593  & 595 & 580  & 590    & 511 \pm 100\\
P4 & 300 & 300  & 300 & 290  & 297    & 301 \pm 50\\
\bottomrule
\end{tabular}
\end{table}

\end{document}


• Thank you! I will check the links. Those tables are really good-looking! – Mike1993 Feb 21 '17 at 17:41
• well, I hope, that you will suggest solution according to the first link in your answer ... :-) . (+1) for it. one more interesting link: wiert.me/2014/04/03/… – Zarko Feb 21 '17 at 17:48
• @Zarko Nice visualisation! I tried to improve the formatting, but I'n not yet happy with the last column. Do you have any suggestions? – user36296 Feb 21 '17 at 18:21
• @samcarter, difficult to say. The both of us haven't information about table background. I would describe with some math expression, but which one? Like $\overline{\text{offset}}\pm\max\sigma$ [mV] ? – Zarko Feb 21 '17 at 18:40
• @Mike1993 @{} makes the rules and the text lie flush against each other, otherwise the rules would be longer (see the pdf in the first link). @{\extracolsep{8pt}} adds some space between the columns -- I used it to separate the partial lines underneath the header. And separate-uncertainty=true should also work as global option, I guess I moved it there during debugging but never moved it back. – user36296 Feb 23 '17 at 20:48

You need to encase the contents of the final header cell in a pair of curly braces.

\documentclass{article}
\usepackage{siunitx}
\begin{document}
\begin{table}
\centering
\caption{Test table\strut} % use '\strut' to create a bit more vert. separation
\begin{tabular}{|l|*{6}{S[table-format=-3.0]|}}
\hline
& \multicolumn{5}{c|}{Numbers 1 [\si{\milli\volt}]}
& {Mean $\pm$ max.\ Variance  [\si{\milli\volt}]} \\ % <-- note the curly braces
\hline \hline
P1        & -241    & -274    & -272    & -258    & -283   & -266 \\ \hline
P2        &  -94    &  -99    & -100    & -114    & -105   & -102 \\ \hline
P3        &  600    &  593    &  595    & 580     &  590   &  511 \\ \hline
P4        &  300    &  300    &  300    & 290     &  297   &  301 \\ \hline
P5        & -730    & -734    & -732    & -778    & -741   & -738 \\ \hline
\end{tabular}
\end{table}
\end{document}

• This es what I need! Thanks you! But I don't understand it exactly. The braces, ok, but I need this part as well: {|l|*{6}{S[table-format=-3.0]|}}. What does this part mean, exactly? With {|l|c|c|c|c|c|c|} it don't work even I use the braces in the column's title. – Mike1993 Feb 21 '17 at 17:16
• Btw, How can I use code in the comments properly? – Mike1993 Feb 21 '17 at 17:17
• @Mike1993 - l means "left-aligned" column type. S is a column type provided by the siunitx package. The option table-format=-3.0 specifies that LaTeX should set aside enough space for a - (minus) sign, 3 digits before the (implied) decimal marker, and 0 digits after the (implied) decimal marker. The *{6}{S[...]} part means "repeat the S[...] column six times. – Mico Feb 21 '17 at 17:19
• Thanks! Unfortunately, the uncertainty isn't shown, when I use it the way I did in the edited MWE. How can I get this right? How do you put the code in comments like you did in the last one? – Mike1993 Feb 21 '17 at 17:25
• @Mike1993 - Just change the column type of the final column from S[table-format=-3.0] to S[table-format=-3.0(3), separate-uncertainty=true]. – Mico Feb 21 '17 at 19:11