TeX - LaTeX Asked by MPKenning on August 2, 2021
I have been stuck on this problem for the last two hours, scouring this forum for any tips. Nothing has worked.
I want to present a table with uncertainties. I am describing the performance of models, so I need to display the standard deviation as a measure of the stability of the models. This is the code I have:
documentclass{article}
usepackage{graphicx,booktabs}
usepackage[separate-uncertainty=true, tight-spacing=true]{siunitx}
begin{document}
begin{table}
centering
caption{Why won't the headers just align to the centre?}
resizebox{textwidth}{!}{%
begin{tabular}{%
l
*{3}{S}[table-format=1.5(5)]
}
toprule
{Thing} & multicolumn{1}{c}{Statistic 1} & multicolumn{1}{c}{Statistic 2} & multicolumn{1}{c}{Statistic 3}
midrule
One thing & 0.77442pm0.00123 & 0.98234pm0.00033 & 0.99971pm0.00011
Second thing & 0.46622pm0.04567 & 0.91248pm0.01203 & 0.99925pm0.00022
bottomrule
end{tabular}
}
end{table}
end{document}
I had thought this would work, but irritatingly it produces headers that are offset. I added the multicolumn
command to try to fix it, but it doesn’t work. I had thought it was the uncertainties, so I played around with the table-format
option, but nothing seems to do it. The spacing is all off anyway, so I suspect I am doing something stupid.
Does anyone have any ideas?
You want three columns with S[table-format=1.5(5)]
, but your input actually specifies
SSS[table-format=1.5(5)]
because you have a misplaced }
. You want
*{3}{S[table-format=1.5(5)]}
Full code:
documentclass{article}
usepackage{booktabs}
usepackage[separate-uncertainty=true, tight-spacing=true]{siunitx}
begin{document}
begin{table}
centering
caption{The headers align to the centre}
begin{tabular}{%
l
*{3}{S[table-format=1.5(5)]} %%% <----- HERE
}
toprule
{Thing} & {Statistic 1} & {Statistic 2} & {Statistic 3}
midrule
One thing & 0.77442pm0.00123 & 0.98234pm0.00033 & 0.99971pm0.00011
Second thing & 0.46622pm0.04567 & 0.91248pm0.01203 & 0.99925pm0.00022
bottomrule
end{tabular}
end{table}
end{document}
Correct answer by egreg on August 2, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP