[Tex/LaTex] \num with parameters in siunitx table

fpsiunitxtables

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.

Thanks for your help.

Best Answer

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}

enter image description here