I have a special problem concerning the column alignment of values which are an error range (separated by $\pm$
or ±
). Since it usually does a great job at typesetting numbers and units, I'm using the siunitx
package.
What I got:
Now I have two approaches to my problem divided here into Table 1
and Table 2
(see code). While Tab. 1
gets the centering but not the spacing right, it is reversed for Tab. 2
. Tab. 1
is close to a solution, but I still prefer the Tab. 2
way, since it is better readable code, is less tweaking of options and I can directly see in SI{x.xx(xxx)}{}
which values belong together. And since the data input works automated from R
, I don't have to write SI{x.xx(xxx)}{}
or actually the customized \ErrRange{x}{y}
every time.
What I want:
1. If I use the S[table-format=x.x] @{\,\( \pm \)\,} S[table-format=x.x]
to format my columns, I get the centering right. But how do I control space between values consistently? It is not straight forward and needs a lot of tweaking to get right. (See Tab. 1
)
2. If I use SI{x.xx(xxx)}{}
as an entry type, how do I get it to center primary around ±
and secondary around x.xx
as well as xxx
? For this question, I got the impression that I have to tell siunitx
somehow that I'm using a S
column here even if I do!? (See Tab. 2
)
What I found:
I tried to get more information on the siunitx
package and its usage, but neither the manual nor other questions could help me (1,2,3). There was another question which discussed the spacing for the S
column, but this adds nothing new to my solution. They always discuss exclusively one of both points but never both together.
The closest to my question came this post, from which I tried to add some \sisetup
options like table-number-alignment=center
and some S
column options like S[separate-uncertainty,table-figures-uncertainty=1]
. They did not change a thing. When I added table-figures-integer = 1
& table-figures-decimal = 2
(with respective values), this even made the alignment in Tab. 1
worse.
Please note in the picture below, how the first table has this weird space problem and how the second ignores the SI-centering:
My code:
\documentclass[]{article}
\usepackage{siunitx}
\usepackage{longtable}
\sisetup{separate-uncertainty, multi-part-units=single, bracket-numbers=false, range-phrase=--, range-units=single}
\newcommand{\ErrRange}[2]{\SI{#1(#2)}{}}
\begin{document}
%%%%%%%%%%%%%% TABLE 1 %%%%%%%%%%%%%%
\section*{Table with $\pm$ as column separator }
\begin{longtable}{
>{\itshape}p{3.5cm}
S[table-format=2.2]@{\,\( \pm \)\,}
S[table-format=1.1]%
S[table-format=3.2]@{\,\( \pm \)\,}
S[table-format=2.2]%
S[table-format=2.1]@{\,\( \pm \)\,}
S[table-format=2.1]%
}
\caption{The entries of this table are centered nicely, but the distances are awful to get right!}%
\\
\multicolumn{1}{l}{\textbf{Taxon}} &
\multicolumn{2}{c}{\textbf{Height (m)}} &
\multicolumn{2}{c}{\textbf{DBH (cm)}} &
\multicolumn{2}{c}{\textbf{Moss Cover (\%)}}\\
\endfirsthead
Acer pseudoplatanus & 14.8 & 4.1 & 35.33 & 20.19 & 11.5 & 16.8 \\
Acer platanoides & 14.4 & 4.2 & 100.33 & 15.28 & 18.0 & 20.8 \\
Picea abies & 14.8 & 3.8 & 32.44 & 13.37 & 0.3 & 0.8 \\
\end{longtable}
%%%%%%%%%%%%%% TABLE 2 %%%%%%%%%%%%%%
\section*{Table with SI-range multicolumns}
\begin{longtable}{
>{\itshape}p{3.5cm}
*{3}S}
\caption{Here the table's code is better readable, but the centering is incorrect.}%
\\
\multicolumn{1}{l}{\textbf{Taxon}} &
\textbf{Height (m)} &
\textbf{DBH (cm)} &
\textbf{Moss Cover (\%)}\\
Acer pseudoplatanus & \ErrRange{14.8}{41} & \ErrRange{35.33}{2019} & \ErrRange{11.5}{168} \\
Acer platanoides & \ErrRange{14.4}{42} & \ErrRange{100.33}{1528} & \ErrRange{18.0}{208} \\
Picea abies & \ErrRange{14.8}{38} & \ErrRange{32.44}{1337} & \ErrRange{0.3}{8} \\
\end{longtable}
\end{document}
EDIT:
Based on the solutions by Zarko
and samcarter
, my problem now is clearer to me. After Zarko's
explanation in the comments, one additional problem could be that the smallest value of a column is smaller than the errors of some other value of that column.
However, contrary to the implication in the comments, some/most of these are realistic values.
As a short background information:
These are data on different tree species of which I estimated the height, dbh (diameter at breast height) and the moss cover. Since I did this for well over a hundred individuals per species (disregarding the size and age), the variation should be quite large. And while it is true that I overemphasized some values, the moss cover values are all my real values. So, both Acer species are supposed to have way more mosses (and more variation in it) than the Picea species. That means that I probably cannot use the answer of Zarko
but have to take a workaround like samcarter's
EDIT 2:
I guess you're right about one thing: I did not mean the standard error but the standard deviation. However, I need the same format and this should therefore not change anything.