5

After rewriting this post multiple times, I'll just write it like this:

  • How can I use \cmidrule in combination with siunitx? Is this even adviseable or not?

  • Did I make an error somewhere else? The whole table looks so. freaking. weird.

I like the way the error (values are actually the confidence intervals but never mind) are parsed. But overall the rules put below AAA, BBB and CCC, I just do not get them. I also do not understand why the cmidrule below AAA goes way too far to the left? I'd really like to avoid the weird rule lengths and just have it as long as the vanilla command would produce it. :(

Picture of status quo

enter image description here

Picture of output with table-number-alignment=right

enter image description here

MWE

\documentclass[
a4paper
]{scrartcl}

\usepackage{
lmodern,
booktabs
}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[
per-mode=fraction,
locale=DE,
separate-uncertainty=true,
retain-explicit-plus,
binary-units,
%table-number-alignment=right
]{siunitx}


\begin{document}
\begin{tabular}{lSSSS}
\toprule
{ValueA} & {VALUEb} & {AAA} & {BBB} & {CCC} \\
\cmidrule(lr){1-1}
\cmidrule(lr){2-2}
\cmidrule(lr){3-3}
\cmidrule(lr){4-4}
\cmidrule(lr){5-5}
20 & 10 & -95,57(7) & 75,18 & -45,88 \\
& 20 & -142,72(12) & 89,20 & -58,62 \\
& 30 & -161,83(16) & -1118,51 & -75,19 \\
\bottomrule
\end{tabular}
\end{document}
2
  • by default I think it's centering on the decimal point, that's what it looks like from your image, the S column has assorted options to specify alignment though so you can change that Oct 6, 2014 at 19:15
  • @DavidCarlisle Edited op.
    – henry
    Oct 6, 2014 at 19:19

2 Answers 2

3

Incorporating the minus signs in table-format=… and choosing table-number-alignment=center (the default is center-decimal-marker) will give an acceptable result, in my opinion:

\documentclass[a4paper]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern,booktabs}

\usepackage[per-mode=fraction, locale=DE, separate-uncertainty=true, retain-explicit-plus, binary-units, table-number-alignment=center, ]{siunitx}

\begin{document}

\begin{tabular}{lcS[table-format=-3.2(2)]S[table-format=-4.2]S[table-format=-2.2]}%
\toprule
{ValueA} & {ValueB} & {AAA} & {BBB} & {CCC} \\
\cmidrule(lr){1-1}
\cmidrule(lr){2-2}
\cmidrule(lr){3-3}
\cmidrule(lr){4-4}
\cmidrule(lr){5-5}
20 & 10 & -95,57(7) & 75,18 & -45,88 \\
& 20 & -142,72(12) & 89,20 & -58,62 \\
& 30 & -161,83(16) & -1118,51 & -75,19 \\
\bottomrule
\end{tabular}

\end{document} 

enter image description here

1
  • Oops! Completely overlooked that point. I'll update my answer at once.
    – Bernard
    Oct 6, 2014 at 21:24
3

An S column needs refinements, the most common one is specifying the format of the numbers it contains; otherwise it does just some heuristics that usually don't work well.

\documentclass[
  a4paper
]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{
  lmodern,
  booktabs,
}


\usepackage[
  per-mode=fraction,
  locale=DE,
  separate-uncertainty=true,
  retain-explicit-plus,
  binary-units,
  %table-number-alignment=right,
]{siunitx}


\begin{document}

\begin{tabular}{
  l
  S[table-format=2.0]
  S[table-format=-3.2(2)]
  S[table-format=-4.2]
  S[table-format=-2.2]
}
\toprule
{ValueA} & {VALUEb} & {AAA} & {BBB} & {CCC} \\
\cmidrule(lr){1-1}
\cmidrule(lr){2-2}
\cmidrule(lr){3-3}
\cmidrule(lr){4-4}
\cmidrule(lr){5-5}
20 & 10 &   -95,57(7) &    75,18 & -45,88 \\
   & 20 & -142,72(12) &    89,20 & -58,62 \\
   & 30 & -161,83(16) & -1118,51 & -75,19 \\
\bottomrule
\end{tabular}

\end{document}

Note the uncertainty in column 3. If you don't specify it, the uncertainty will not be displayed.

enter image description here

Use S for the preliminary version and fine tune it when you know the data are definitive.

8
  • Giving Bernard the checkmark because he was 2 minutes faster. Besides, he really seems to need it with his mere \approx 22k magic points against your 320k. ;)
    – henry
    Oct 6, 2014 at 20:22
  • 1
    @henry No problem for me; but I wanted to point out the uncertainty bit.
    – egreg
    Oct 6, 2014 at 20:25
  • Noted that it is no problem and that you did not engage my joke. :( Also now I understand the little difference between your reply and Bernard's which actually makes you rreply better. And I would feel bad to take the magic points away from him and add them to your 320k.
    – henry
    Oct 6, 2014 at 20:31
  • @henry So feel good and leave them to him. ;-)
    – egreg
    Oct 6, 2014 at 20:33
  • It just dawned on me that (in regards to the first uncertainty value) the value (7) is interpreted as 0.07. Or 7 percent, which is equally wrong for my data. Also I get an error when writing table-format=4.2(2.2) and supplying the data accordingly. Can I not do that?
    – henry
    Oct 7, 2014 at 7:15

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.