2

I want to align my numbers with siunitx, but in combination with makecell it produce several error message based on my \makecell commands. I tried to protect my makecell commands with brackets, but it still does not work.

MWE:

\documentclass{scrreprt}
\usepackage{booktabs} %Table format
\usepackage{makecell} %Connected rows
\usepackage{siunitx} %Number alignment

\begin{document}

\begin{table}
\centering
\small
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{scc}
\toprule
\makecell{\textbf{A} \\ {[min]}} &
\makecell{\textbf{B} \\ {[\%]}} &
\makecell{\textbf{C} \\ {[\%]}} \\
\midrule
0.0 & 20.0 & 45.0 \\
8.0 & 29.0 & 45.0 \\
15.0 & 10.0 & 90.0 \\
20.0 & 15.0 & 90.0 \\
20.1 & 55.0 & 45.0 \\
30.0 & 55.0 & 45.0 \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

Thanks in advance!

  • \makecell had to be inside curly braces. also column type is S, not s. – Zarko Mar 6 '18 at 13:49
3

enter image description here

in S column type S texts (usual in column headers) had to be enclosed in curly braces, even if they are in \makecell or \thead macros form makecell package. exception is, if the header is inside \multicolumn cells.

your table should be for example as follows below:

\documentclass{scrreprt}
\usepackage{booktabs} %Table format
\usepackage{makecell} %Connected rows
\usepackage{siunitx} %Number alignment

\begin{document}
    \begin{table}
\centering
\small
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{*{3}{S[table-format=2.1]}}
    \toprule
{\makecell{\textbf{A} \\ {[min]}}} &
{\makecell{\textbf{B} \\ {[\%]}}}  &
{\makecell{\textbf{C} \\ {[\%]}}} \\
\midrule
 0.0 & 20.0 & 45.0 \\
 8.0 & 29.0 & 45.0 \\
15.0 & 10.0 & 90.0 \\
20.0 & 15.0 & 90.0 \\
20.1 & 55.0 & 45.0 \\
30.0 & 55.0 & 45.0 \\
\bottomrule
\end{tabular}
    \end{table}
\end{document}

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.