I can't for the life of me figure out what's causing the errors in this table. As written, I get about a dozen warnings (all on the first data line of the table) about missing }
or $
.
\documentclass{article}
\usepackage{mathpazo}
\usepackage{array}
\usepackage{booktabs,caption}
\usepackage{multirow}
\usepackage{siunitx}
\usepackage{color}
\begin{document}
\begin{table}[!htbp]
\captionsetup{skip=0.5\baselineskip,size=footnotesize}
\footnotesize
\centering
\begin{tabular}{c
S[table-format=2.0]
*3{S[table-format=1.1]}
}
\toprule
\multirow{2}[4]{*}{\textbf{Homegrid}} & \multirow{2}[4]{*}{\textbf{Battery capacity}} & \multicolumn{3}{c}{\textbf{Load priority and power}} \\ \cmidrule{3-5}
& & \textbf{High} & \textbf{Medium} & \textbf{Low} \\ \midrule
\textcolor[rgb]{ 0, .447, .741}{1} & 7 & 1.5 & 4.5 & 0 \\
\textcolor[rgb]{ .851, .325, .098}{2} & 55 & 1.5 & 4.5 & 1.5 \\ \bottomrule
\end{tabular}
\caption{Thresholds and actions for the homegrids of the experiment plotted in ...}
\label{tab:export}
\end{table}
\end{document}
As soon as I switch the tabular format to {ccccc}
, everything works perfectly.
I can use \tablenum{}
(as suggested in this answer) in the middle column to get 7 and 55 to line up properly, which is why I'm using siunitx
. But why won't siunitx work on it's own?
Best Answer
The
siunitx
code does it's best to 'guess' when content is 'purely textual', but it is best to give it some guidance. Here, the issue arises assiunitx
picks up\multirow
as 'before the number' but fails to grab all of the arguments in the same way. Adding a set of braces fixes this: