# \num with parameters in siunitx table

I have a couple of different methods to solve a diven problem and I want to compare them in a table. My aim is it to automatically add the relative deviation.

I got some problems using siunitx within a table, but I solved it using this.

Now my problem is, that my last column should have an explicit (plus) sign. When I use something like (did not use my automatic calculation in here, as the error occurs even without it)...

\documentclass{article}
\usepackage{siunitx}

\begin{document}

\begin{tabular}{lSSS}
\hline
\hline
\textbf{Type} & \textbf{before} & \textbf{after} & \textbf{change}\\
& $\left[\frac{m^3}{h}\right]$ & $\left[\frac{m^3}{h}\right]$ & $\left[\%\right]$\\
\hline
Method A & 10.05 & 22.84 & \num[explicit-sign=+]{127.26}
\hline
\hline
\end{tabular}

\end{document}

...I get the following error message.

> Argument of \num has an extra }.

Does anybody has an idea, why it did not work? Or what to do to make it work?

I cannot use explicit-sign=+ within \sisetup as I only want my last column to have the explicit sign.

You can use \begin{tabular}{lSSS[explicit-sign=+]} ....

BTW: non-numerical input in S-type columns should be escaped by putting the material in braces: {\textbf{before}}. Also: since you're using siunitx already you should use it for the units as well. In my example below I also use booktabs for nicer table rules.

\documentclass{article}
\usepackage{siunitx,booktabs}

\sisetup{per-mode=symbol}

\begin{document}

\begin{tabular}{lSSS[explicit-sign=+,table-format=3.2]}
\toprule
{\textbf{Type}} & {\textbf{before}} &
{\textbf{after}} & {\textbf{change}} \\
& {\si{\cubic\metre\per\hour}} & {\si{\cubic\metre\per\hour}}
& {\si{\percent}} \\
\midrule
Method A & 10.05 & 22.84 & 127.26 \\
Method A & 10.05 & 22.84 & 127.26 \\
\bottomrule
\end{tabular}

\end{document}

• How embarassing - this is indeed a simple solution. Do you have any idea why in-row-soluation does not work? Thank you anyways! At this moment I'm changing all my tables to siunitx-tables, so I'll take your other advices regarding the units, non-numerical input and tables rules. – Hackbard_C Aug 5 '14 at 9:56
• Simply put: cell contents in S columns already are parsed by a \num equivalent. Using \num in such a cell is a bit like \num{\num{...}} which you probably wouldn't expect to work... – clemens Aug 5 '14 at 9:59

It is enough to write {+}. I took the opportunity to load booktabsto improve the look of horizontal rules, defining a \doubletoprule and a doublebottomrule commands.

\documentclass{article}
\usepackage{siunitx}
\usepackage{amsmath}
\usepackage{nccmath}
\usepackage{booktabs}

\newcommand\doubletoprule{%
\toprule
\specialrule{0.025em}{0.6\doublerulesep}{\belowrulesep}}%
\newcommand\doublebottomrule{%
\specialrule{0.025em}{\aboverulesep}{0.6\doublerulesep}
\bottomrule}%

\begin{document}

\begin{tabular}{@{\hskip5pt}lSSS@{\hskip-5pt}}
\doubletoprule
\textbf{Type} & {\textbf{before}} & {\textbf{after}} & {\textbf{change  }}\\
& {$\Bigl [\mfrac{m^3}{h}\Bigr ]$} & {$\Bigl[\mfrac{m^3}{h}\Bigr]$} & {$\bigl[ \,\%\,\bigr]$} \\
\cmidrule(l{2pt}r{4pt}){1-4}
Method A & 10.05 & 22.84 & {+} 127.26\\
Method B & 10.05 &- 22.84 & - 127.26\\
\specialrule{0.025em}{\aboverulesep}{0.6\doublerulesep}
\bottomrule
\end{tabular}

\end{document}