siunitx squashing columns
up vote
3
down vote
favorite
I have a table that I've formatted like this:
begin{table}[h!]
begin{center}
begin{tabular}[t]{cccc}
hline
{Combo} & {$|r|>0.5$} & {$n>100$} & {$r^2n$} \
hline
{U-V} & 0.558545 & 11640 & 3631.36 \
{U-R} & 0.567270 & 11632 & 3743.12 \
{U-I} & 0.579188 & 11626 & 3900.04 \
{U-J} & 0.536106 & 3709 & 1066 \
{U-K} & 0.535644 & 3730 & 1070.19 \
{B-V} & 0.580019 & 11884 & 3998.04 \
{B-R} & 0.574867 & 11763 & 3887.34 \
{B-I} & 0.591288 & 11749 & 4107.7 \
{V-U} & -0.558545 & 11640 & 3631.36 \
{V-B} & -0.580019 & 11884 & 3998.04 \
{R-U} & -0.567270 & 11632 & 3743.12 \
{R-B} & -0.574867 & 11763 & 3887.34 \
{R-W2} & -0.535443 & 4022 & 1153.1 \
{I-U} & -0.579188 & 11626 & 3900.04 \
{I-B} & -0.591288 & 11749 & 4107.7 \
{I-W2} & -0.574056 & 4020 & 1324.75 \
{J-U} & -0.536106 & 3709 & 1066 \
{J-W2} & -0.577232 & 1943 & 647.401 \
{K-U} & -0.535644 & 3730 & 1070.19 \
{K-W1} & -0.512554 & 1938 & 509.136 \
{K-W2} & -0.591156 & 1960 & 684.953 \
{W1-K} & 0.512554 & 1938 & 509.136 \
{W2-R} & 0.535443 & 4022 & 1153.1 \
{W2-I} & 0.574056 & 4020 & 1324.75 \
{W2-J} & 0.577232 & 1943 & 647.401 \
{W2-K} & 0.591156 & 1960 & 684.953 \
hline
end{tabular}
caption[Best photometric colours from the MgII dataset]{Photometric colours with highest r-value from the MgII dataset.}
label{table:MgII_colours}
end{center}
end{table}
to produce:

but I need the numerical columns aligned on the decimal points. From this question I tried formatting it as
begin{table}
centering
addtolength{tabcolsep}{-0.3pt}
begin{tabular}{
@{}
l
S[table-format=1.2]
S[table-format=1.2]
S[table-format=2.3]
@{}
}
hline
{Combo} & {$|r|>0.5$} & {$n>100$} & {$r^2n$} \
hline
{U-V} & 0.558545 & 11640 & 3631.36 \
{U-R} & 0.567270 & 11632 & 3743.12 \
{U-I} & 0.579188 & 11626 & 3900.04 \
{U-J} & 0.536106 & 3709 & 1066 \
{U-K} & 0.535644 & 3730 & 1070.19 \
{B-V} & 0.580019 & 11884 & 3998.04 \
{B-R} & 0.574867 & 11763 & 3887.34 \
{B-I} & 0.591288 & 11749 & 4107.7 \
{V-U} & -0.558545 & 11640 & 3631.36 \
{V-B} & -0.580019 & 11884 & 3998.04 \
{R-U} & -0.567270 & 11632 & 3743.12 \
{R-B} & -0.574867 & 11763 & 3887.34 \
{R-W2} & -0.535443 & 4022 & 1153.1 \
{I-U} & -0.579188 & 11626 & 3900.04 \
{I-B} & -0.591288 & 11749 & 4107.7 \
{I-W2} & -0.574056 & 4020 & 1324.75 \
{J-U} & -0.536106 & 3709 & 1066 \
{J-W2} & -0.577232 & 1943 & 647.401 \
{K-U} & -0.535644 & 3730 & 1070.19 \
{K-W1} & -0.512554 & 1938 & 509.136 \
{K-W2} & -0.591156 & 1960 & 684.953 \
{W1-K} & 0.512554 & 1938 & 509.136 \
{W2-R} & 0.535443 & 4022 & 1153.1 \
{W2-I} & 0.574056 & 4020 & 1324.75 \
{W2-J} & 0.577232 & 1943 & 647.401 \
{W2-K} & 0.591156 & 1960 & 684.953 \
hline
end{tabular}
caption[Best photometric colours from the MgII dataset]{Photometric colours with highest r-value from the MgII dataset.}
label{table:MgII_colours}
end{table}
but it made this:

Why has it squashed up the middle two columns? I'm quite new to LaTex, and very new to siunitx.
Also, is there any way to avoid having to put the braces around the textual column entries? It's kind of a pain when there are a lot of rows.
tables siunitx alignment
add a comment |
up vote
3
down vote
favorite
I have a table that I've formatted like this:
begin{table}[h!]
begin{center}
begin{tabular}[t]{cccc}
hline
{Combo} & {$|r|>0.5$} & {$n>100$} & {$r^2n$} \
hline
{U-V} & 0.558545 & 11640 & 3631.36 \
{U-R} & 0.567270 & 11632 & 3743.12 \
{U-I} & 0.579188 & 11626 & 3900.04 \
{U-J} & 0.536106 & 3709 & 1066 \
{U-K} & 0.535644 & 3730 & 1070.19 \
{B-V} & 0.580019 & 11884 & 3998.04 \
{B-R} & 0.574867 & 11763 & 3887.34 \
{B-I} & 0.591288 & 11749 & 4107.7 \
{V-U} & -0.558545 & 11640 & 3631.36 \
{V-B} & -0.580019 & 11884 & 3998.04 \
{R-U} & -0.567270 & 11632 & 3743.12 \
{R-B} & -0.574867 & 11763 & 3887.34 \
{R-W2} & -0.535443 & 4022 & 1153.1 \
{I-U} & -0.579188 & 11626 & 3900.04 \
{I-B} & -0.591288 & 11749 & 4107.7 \
{I-W2} & -0.574056 & 4020 & 1324.75 \
{J-U} & -0.536106 & 3709 & 1066 \
{J-W2} & -0.577232 & 1943 & 647.401 \
{K-U} & -0.535644 & 3730 & 1070.19 \
{K-W1} & -0.512554 & 1938 & 509.136 \
{K-W2} & -0.591156 & 1960 & 684.953 \
{W1-K} & 0.512554 & 1938 & 509.136 \
{W2-R} & 0.535443 & 4022 & 1153.1 \
{W2-I} & 0.574056 & 4020 & 1324.75 \
{W2-J} & 0.577232 & 1943 & 647.401 \
{W2-K} & 0.591156 & 1960 & 684.953 \
hline
end{tabular}
caption[Best photometric colours from the MgII dataset]{Photometric colours with highest r-value from the MgII dataset.}
label{table:MgII_colours}
end{center}
end{table}
to produce:

but I need the numerical columns aligned on the decimal points. From this question I tried formatting it as
begin{table}
centering
addtolength{tabcolsep}{-0.3pt}
begin{tabular}{
@{}
l
S[table-format=1.2]
S[table-format=1.2]
S[table-format=2.3]
@{}
}
hline
{Combo} & {$|r|>0.5$} & {$n>100$} & {$r^2n$} \
hline
{U-V} & 0.558545 & 11640 & 3631.36 \
{U-R} & 0.567270 & 11632 & 3743.12 \
{U-I} & 0.579188 & 11626 & 3900.04 \
{U-J} & 0.536106 & 3709 & 1066 \
{U-K} & 0.535644 & 3730 & 1070.19 \
{B-V} & 0.580019 & 11884 & 3998.04 \
{B-R} & 0.574867 & 11763 & 3887.34 \
{B-I} & 0.591288 & 11749 & 4107.7 \
{V-U} & -0.558545 & 11640 & 3631.36 \
{V-B} & -0.580019 & 11884 & 3998.04 \
{R-U} & -0.567270 & 11632 & 3743.12 \
{R-B} & -0.574867 & 11763 & 3887.34 \
{R-W2} & -0.535443 & 4022 & 1153.1 \
{I-U} & -0.579188 & 11626 & 3900.04 \
{I-B} & -0.591288 & 11749 & 4107.7 \
{I-W2} & -0.574056 & 4020 & 1324.75 \
{J-U} & -0.536106 & 3709 & 1066 \
{J-W2} & -0.577232 & 1943 & 647.401 \
{K-U} & -0.535644 & 3730 & 1070.19 \
{K-W1} & -0.512554 & 1938 & 509.136 \
{K-W2} & -0.591156 & 1960 & 684.953 \
{W1-K} & 0.512554 & 1938 & 509.136 \
{W2-R} & 0.535443 & 4022 & 1153.1 \
{W2-I} & 0.574056 & 4020 & 1324.75 \
{W2-J} & 0.577232 & 1943 & 647.401 \
{W2-K} & 0.591156 & 1960 & 684.953 \
hline
end{tabular}
caption[Best photometric colours from the MgII dataset]{Photometric colours with highest r-value from the MgII dataset.}
label{table:MgII_colours}
end{table}
but it made this:

Why has it squashed up the middle two columns? I'm quite new to LaTex, and very new to siunitx.
Also, is there any way to avoid having to put the braces around the textual column entries? It's kind of a pain when there are a lot of rows.
tables siunitx alignment
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I have a table that I've formatted like this:
begin{table}[h!]
begin{center}
begin{tabular}[t]{cccc}
hline
{Combo} & {$|r|>0.5$} & {$n>100$} & {$r^2n$} \
hline
{U-V} & 0.558545 & 11640 & 3631.36 \
{U-R} & 0.567270 & 11632 & 3743.12 \
{U-I} & 0.579188 & 11626 & 3900.04 \
{U-J} & 0.536106 & 3709 & 1066 \
{U-K} & 0.535644 & 3730 & 1070.19 \
{B-V} & 0.580019 & 11884 & 3998.04 \
{B-R} & 0.574867 & 11763 & 3887.34 \
{B-I} & 0.591288 & 11749 & 4107.7 \
{V-U} & -0.558545 & 11640 & 3631.36 \
{V-B} & -0.580019 & 11884 & 3998.04 \
{R-U} & -0.567270 & 11632 & 3743.12 \
{R-B} & -0.574867 & 11763 & 3887.34 \
{R-W2} & -0.535443 & 4022 & 1153.1 \
{I-U} & -0.579188 & 11626 & 3900.04 \
{I-B} & -0.591288 & 11749 & 4107.7 \
{I-W2} & -0.574056 & 4020 & 1324.75 \
{J-U} & -0.536106 & 3709 & 1066 \
{J-W2} & -0.577232 & 1943 & 647.401 \
{K-U} & -0.535644 & 3730 & 1070.19 \
{K-W1} & -0.512554 & 1938 & 509.136 \
{K-W2} & -0.591156 & 1960 & 684.953 \
{W1-K} & 0.512554 & 1938 & 509.136 \
{W2-R} & 0.535443 & 4022 & 1153.1 \
{W2-I} & 0.574056 & 4020 & 1324.75 \
{W2-J} & 0.577232 & 1943 & 647.401 \
{W2-K} & 0.591156 & 1960 & 684.953 \
hline
end{tabular}
caption[Best photometric colours from the MgII dataset]{Photometric colours with highest r-value from the MgII dataset.}
label{table:MgII_colours}
end{center}
end{table}
to produce:

but I need the numerical columns aligned on the decimal points. From this question I tried formatting it as
begin{table}
centering
addtolength{tabcolsep}{-0.3pt}
begin{tabular}{
@{}
l
S[table-format=1.2]
S[table-format=1.2]
S[table-format=2.3]
@{}
}
hline
{Combo} & {$|r|>0.5$} & {$n>100$} & {$r^2n$} \
hline
{U-V} & 0.558545 & 11640 & 3631.36 \
{U-R} & 0.567270 & 11632 & 3743.12 \
{U-I} & 0.579188 & 11626 & 3900.04 \
{U-J} & 0.536106 & 3709 & 1066 \
{U-K} & 0.535644 & 3730 & 1070.19 \
{B-V} & 0.580019 & 11884 & 3998.04 \
{B-R} & 0.574867 & 11763 & 3887.34 \
{B-I} & 0.591288 & 11749 & 4107.7 \
{V-U} & -0.558545 & 11640 & 3631.36 \
{V-B} & -0.580019 & 11884 & 3998.04 \
{R-U} & -0.567270 & 11632 & 3743.12 \
{R-B} & -0.574867 & 11763 & 3887.34 \
{R-W2} & -0.535443 & 4022 & 1153.1 \
{I-U} & -0.579188 & 11626 & 3900.04 \
{I-B} & -0.591288 & 11749 & 4107.7 \
{I-W2} & -0.574056 & 4020 & 1324.75 \
{J-U} & -0.536106 & 3709 & 1066 \
{J-W2} & -0.577232 & 1943 & 647.401 \
{K-U} & -0.535644 & 3730 & 1070.19 \
{K-W1} & -0.512554 & 1938 & 509.136 \
{K-W2} & -0.591156 & 1960 & 684.953 \
{W1-K} & 0.512554 & 1938 & 509.136 \
{W2-R} & 0.535443 & 4022 & 1153.1 \
{W2-I} & 0.574056 & 4020 & 1324.75 \
{W2-J} & 0.577232 & 1943 & 647.401 \
{W2-K} & 0.591156 & 1960 & 684.953 \
hline
end{tabular}
caption[Best photometric colours from the MgII dataset]{Photometric colours with highest r-value from the MgII dataset.}
label{table:MgII_colours}
end{table}
but it made this:

Why has it squashed up the middle two columns? I'm quite new to LaTex, and very new to siunitx.
Also, is there any way to avoid having to put the braces around the textual column entries? It's kind of a pain when there are a lot of rows.
tables siunitx alignment
I have a table that I've formatted like this:
begin{table}[h!]
begin{center}
begin{tabular}[t]{cccc}
hline
{Combo} & {$|r|>0.5$} & {$n>100$} & {$r^2n$} \
hline
{U-V} & 0.558545 & 11640 & 3631.36 \
{U-R} & 0.567270 & 11632 & 3743.12 \
{U-I} & 0.579188 & 11626 & 3900.04 \
{U-J} & 0.536106 & 3709 & 1066 \
{U-K} & 0.535644 & 3730 & 1070.19 \
{B-V} & 0.580019 & 11884 & 3998.04 \
{B-R} & 0.574867 & 11763 & 3887.34 \
{B-I} & 0.591288 & 11749 & 4107.7 \
{V-U} & -0.558545 & 11640 & 3631.36 \
{V-B} & -0.580019 & 11884 & 3998.04 \
{R-U} & -0.567270 & 11632 & 3743.12 \
{R-B} & -0.574867 & 11763 & 3887.34 \
{R-W2} & -0.535443 & 4022 & 1153.1 \
{I-U} & -0.579188 & 11626 & 3900.04 \
{I-B} & -0.591288 & 11749 & 4107.7 \
{I-W2} & -0.574056 & 4020 & 1324.75 \
{J-U} & -0.536106 & 3709 & 1066 \
{J-W2} & -0.577232 & 1943 & 647.401 \
{K-U} & -0.535644 & 3730 & 1070.19 \
{K-W1} & -0.512554 & 1938 & 509.136 \
{K-W2} & -0.591156 & 1960 & 684.953 \
{W1-K} & 0.512554 & 1938 & 509.136 \
{W2-R} & 0.535443 & 4022 & 1153.1 \
{W2-I} & 0.574056 & 4020 & 1324.75 \
{W2-J} & 0.577232 & 1943 & 647.401 \
{W2-K} & 0.591156 & 1960 & 684.953 \
hline
end{tabular}
caption[Best photometric colours from the MgII dataset]{Photometric colours with highest r-value from the MgII dataset.}
label{table:MgII_colours}
end{center}
end{table}
to produce:

but I need the numerical columns aligned on the decimal points. From this question I tried formatting it as
begin{table}
centering
addtolength{tabcolsep}{-0.3pt}
begin{tabular}{
@{}
l
S[table-format=1.2]
S[table-format=1.2]
S[table-format=2.3]
@{}
}
hline
{Combo} & {$|r|>0.5$} & {$n>100$} & {$r^2n$} \
hline
{U-V} & 0.558545 & 11640 & 3631.36 \
{U-R} & 0.567270 & 11632 & 3743.12 \
{U-I} & 0.579188 & 11626 & 3900.04 \
{U-J} & 0.536106 & 3709 & 1066 \
{U-K} & 0.535644 & 3730 & 1070.19 \
{B-V} & 0.580019 & 11884 & 3998.04 \
{B-R} & 0.574867 & 11763 & 3887.34 \
{B-I} & 0.591288 & 11749 & 4107.7 \
{V-U} & -0.558545 & 11640 & 3631.36 \
{V-B} & -0.580019 & 11884 & 3998.04 \
{R-U} & -0.567270 & 11632 & 3743.12 \
{R-B} & -0.574867 & 11763 & 3887.34 \
{R-W2} & -0.535443 & 4022 & 1153.1 \
{I-U} & -0.579188 & 11626 & 3900.04 \
{I-B} & -0.591288 & 11749 & 4107.7 \
{I-W2} & -0.574056 & 4020 & 1324.75 \
{J-U} & -0.536106 & 3709 & 1066 \
{J-W2} & -0.577232 & 1943 & 647.401 \
{K-U} & -0.535644 & 3730 & 1070.19 \
{K-W1} & -0.512554 & 1938 & 509.136 \
{K-W2} & -0.591156 & 1960 & 684.953 \
{W1-K} & 0.512554 & 1938 & 509.136 \
{W2-R} & 0.535443 & 4022 & 1153.1 \
{W2-I} & 0.574056 & 4020 & 1324.75 \
{W2-J} & 0.577232 & 1943 & 647.401 \
{W2-K} & 0.591156 & 1960 & 684.953 \
hline
end{tabular}
caption[Best photometric colours from the MgII dataset]{Photometric colours with highest r-value from the MgII dataset.}
label{table:MgII_colours}
end{table}
but it made this:

Why has it squashed up the middle two columns? I'm quite new to LaTex, and very new to siunitx.
Also, is there any way to avoid having to put the braces around the textual column entries? It's kind of a pain when there are a lot of rows.
tables siunitx alignment
tables siunitx alignment
asked Nov 13 at 20:31
Jim421616
1306
1306
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
You just need to set appropriate values in your table-formats. In your case, you have to worry about the number of digits before and after the decimal separator and, in the second column, the presence of the sign.
documentclass{article}
usepackage{siunitx}
usepackage{booktabs}
begin{document}
begin{table}
centering
addtolength{tabcolsep}{-0.3pt}
sisetup{group-digits=integer}
begin{tabular}{
@{}
l
S[table-format=+1.6]
S[table-format=5.0]
S[table-format=4.3]
@{}
}
toprule
Combo & {$|r|>0.5$} & {$n>100$} & {$r^2n$} \
midrule
U-V & 0.558545 & 11640 & 3631.36 \
U-R & 0.567270 & 11632 & 3743.12 \
U-I & 0.579188 & 11626 & 3900.04 \
U-J & 0.536106 & 3709 & 1066 \
U-K & 0.535644 & 3730 & 1070.19 \
B-V & 0.580019 & 11884 & 3998.04 \
B-R & 0.574867 & 11763 & 3887.34 \
B-I & 0.591288 & 11749 & 4107.7 \
V-U & -0.558545 & 11640 & 3631.36 \
V-B & -0.580019 & 11884 & 3998.04 \
R-U & -0.567270 & 11632 & 3743.12 \
R-B & -0.574867 & 11763 & 3887.34 \
R-W2 & -0.535443 & 4022 & 1153.1 \
I-U & -0.579188 & 11626 & 3900.04 \
I-B & -0.591288 & 11749 & 4107.7 \
I-W2 & -0.574056 & 4020 & 1324.75 \
J-U & -0.536106 & 3709 & 1066 \
J-W2 & -0.577232 & 1943 & 647.401 \
K-U & -0.535644 & 3730 & 1070.19 \
K-W1 & -0.512554 & 1938 & 509.136 \
K-W2 & -0.591156 & 1960 & 684.953 \
W1-K & 0.512554 & 1938 & 509.136 \
W2-R & 0.535443 & 4022 & 1153.1 \
W2-I & 0.574056 & 4020 & 1324.75 \
W2-J & 0.577232 & 1943 & 647.401 \
W2-K & 0.591156 & 1960 & 684.953 \
bottomrule
end{tabular}
caption[Best photometric colours from the MgII dataset]{Photometric colours with highest r-value from the MgII dataset.}
label{table:MgII_colours}
end{table}
end{document}

Ah that's better! Is there any way to avoid having to put the braces around the text values in the first column? Maybe a column format specifier or something?
– Jim421616
Nov 13 at 20:41
1
@Jim421616 Your first column is anltype column, so as far as I know, you don't need the brace protection there already.
– gusbrs
Nov 13 at 20:43
@Jim421616 I've added some small improvements (booktabs, in particular, but also better digit groupint).
– gusbrs
Nov 13 at 20:57
Ok, so what does the linesisetup{group-digits=integer}do exactly?
– Jim421616
Nov 13 at 23:38
1
@Jim421616 It introduces grouping for larger numbers, but only for the integer part.siunitx's default is to put a thin space between groups and to group by three digits, but doesn't separate a single digit (that is, you must have at least five numbers for the grouping to take place). Notice the five digit numbers in your third column, and you'll see what's going on.
– gusbrs
Nov 13 at 23:47
|
show 1 more comment
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You just need to set appropriate values in your table-formats. In your case, you have to worry about the number of digits before and after the decimal separator and, in the second column, the presence of the sign.
documentclass{article}
usepackage{siunitx}
usepackage{booktabs}
begin{document}
begin{table}
centering
addtolength{tabcolsep}{-0.3pt}
sisetup{group-digits=integer}
begin{tabular}{
@{}
l
S[table-format=+1.6]
S[table-format=5.0]
S[table-format=4.3]
@{}
}
toprule
Combo & {$|r|>0.5$} & {$n>100$} & {$r^2n$} \
midrule
U-V & 0.558545 & 11640 & 3631.36 \
U-R & 0.567270 & 11632 & 3743.12 \
U-I & 0.579188 & 11626 & 3900.04 \
U-J & 0.536106 & 3709 & 1066 \
U-K & 0.535644 & 3730 & 1070.19 \
B-V & 0.580019 & 11884 & 3998.04 \
B-R & 0.574867 & 11763 & 3887.34 \
B-I & 0.591288 & 11749 & 4107.7 \
V-U & -0.558545 & 11640 & 3631.36 \
V-B & -0.580019 & 11884 & 3998.04 \
R-U & -0.567270 & 11632 & 3743.12 \
R-B & -0.574867 & 11763 & 3887.34 \
R-W2 & -0.535443 & 4022 & 1153.1 \
I-U & -0.579188 & 11626 & 3900.04 \
I-B & -0.591288 & 11749 & 4107.7 \
I-W2 & -0.574056 & 4020 & 1324.75 \
J-U & -0.536106 & 3709 & 1066 \
J-W2 & -0.577232 & 1943 & 647.401 \
K-U & -0.535644 & 3730 & 1070.19 \
K-W1 & -0.512554 & 1938 & 509.136 \
K-W2 & -0.591156 & 1960 & 684.953 \
W1-K & 0.512554 & 1938 & 509.136 \
W2-R & 0.535443 & 4022 & 1153.1 \
W2-I & 0.574056 & 4020 & 1324.75 \
W2-J & 0.577232 & 1943 & 647.401 \
W2-K & 0.591156 & 1960 & 684.953 \
bottomrule
end{tabular}
caption[Best photometric colours from the MgII dataset]{Photometric colours with highest r-value from the MgII dataset.}
label{table:MgII_colours}
end{table}
end{document}

Ah that's better! Is there any way to avoid having to put the braces around the text values in the first column? Maybe a column format specifier or something?
– Jim421616
Nov 13 at 20:41
1
@Jim421616 Your first column is anltype column, so as far as I know, you don't need the brace protection there already.
– gusbrs
Nov 13 at 20:43
@Jim421616 I've added some small improvements (booktabs, in particular, but also better digit groupint).
– gusbrs
Nov 13 at 20:57
Ok, so what does the linesisetup{group-digits=integer}do exactly?
– Jim421616
Nov 13 at 23:38
1
@Jim421616 It introduces grouping for larger numbers, but only for the integer part.siunitx's default is to put a thin space between groups and to group by three digits, but doesn't separate a single digit (that is, you must have at least five numbers for the grouping to take place). Notice the five digit numbers in your third column, and you'll see what's going on.
– gusbrs
Nov 13 at 23:47
|
show 1 more comment
up vote
2
down vote
accepted
You just need to set appropriate values in your table-formats. In your case, you have to worry about the number of digits before and after the decimal separator and, in the second column, the presence of the sign.
documentclass{article}
usepackage{siunitx}
usepackage{booktabs}
begin{document}
begin{table}
centering
addtolength{tabcolsep}{-0.3pt}
sisetup{group-digits=integer}
begin{tabular}{
@{}
l
S[table-format=+1.6]
S[table-format=5.0]
S[table-format=4.3]
@{}
}
toprule
Combo & {$|r|>0.5$} & {$n>100$} & {$r^2n$} \
midrule
U-V & 0.558545 & 11640 & 3631.36 \
U-R & 0.567270 & 11632 & 3743.12 \
U-I & 0.579188 & 11626 & 3900.04 \
U-J & 0.536106 & 3709 & 1066 \
U-K & 0.535644 & 3730 & 1070.19 \
B-V & 0.580019 & 11884 & 3998.04 \
B-R & 0.574867 & 11763 & 3887.34 \
B-I & 0.591288 & 11749 & 4107.7 \
V-U & -0.558545 & 11640 & 3631.36 \
V-B & -0.580019 & 11884 & 3998.04 \
R-U & -0.567270 & 11632 & 3743.12 \
R-B & -0.574867 & 11763 & 3887.34 \
R-W2 & -0.535443 & 4022 & 1153.1 \
I-U & -0.579188 & 11626 & 3900.04 \
I-B & -0.591288 & 11749 & 4107.7 \
I-W2 & -0.574056 & 4020 & 1324.75 \
J-U & -0.536106 & 3709 & 1066 \
J-W2 & -0.577232 & 1943 & 647.401 \
K-U & -0.535644 & 3730 & 1070.19 \
K-W1 & -0.512554 & 1938 & 509.136 \
K-W2 & -0.591156 & 1960 & 684.953 \
W1-K & 0.512554 & 1938 & 509.136 \
W2-R & 0.535443 & 4022 & 1153.1 \
W2-I & 0.574056 & 4020 & 1324.75 \
W2-J & 0.577232 & 1943 & 647.401 \
W2-K & 0.591156 & 1960 & 684.953 \
bottomrule
end{tabular}
caption[Best photometric colours from the MgII dataset]{Photometric colours with highest r-value from the MgII dataset.}
label{table:MgII_colours}
end{table}
end{document}

Ah that's better! Is there any way to avoid having to put the braces around the text values in the first column? Maybe a column format specifier or something?
– Jim421616
Nov 13 at 20:41
1
@Jim421616 Your first column is anltype column, so as far as I know, you don't need the brace protection there already.
– gusbrs
Nov 13 at 20:43
@Jim421616 I've added some small improvements (booktabs, in particular, but also better digit groupint).
– gusbrs
Nov 13 at 20:57
Ok, so what does the linesisetup{group-digits=integer}do exactly?
– Jim421616
Nov 13 at 23:38
1
@Jim421616 It introduces grouping for larger numbers, but only for the integer part.siunitx's default is to put a thin space between groups and to group by three digits, but doesn't separate a single digit (that is, you must have at least five numbers for the grouping to take place). Notice the five digit numbers in your third column, and you'll see what's going on.
– gusbrs
Nov 13 at 23:47
|
show 1 more comment
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You just need to set appropriate values in your table-formats. In your case, you have to worry about the number of digits before and after the decimal separator and, in the second column, the presence of the sign.
documentclass{article}
usepackage{siunitx}
usepackage{booktabs}
begin{document}
begin{table}
centering
addtolength{tabcolsep}{-0.3pt}
sisetup{group-digits=integer}
begin{tabular}{
@{}
l
S[table-format=+1.6]
S[table-format=5.0]
S[table-format=4.3]
@{}
}
toprule
Combo & {$|r|>0.5$} & {$n>100$} & {$r^2n$} \
midrule
U-V & 0.558545 & 11640 & 3631.36 \
U-R & 0.567270 & 11632 & 3743.12 \
U-I & 0.579188 & 11626 & 3900.04 \
U-J & 0.536106 & 3709 & 1066 \
U-K & 0.535644 & 3730 & 1070.19 \
B-V & 0.580019 & 11884 & 3998.04 \
B-R & 0.574867 & 11763 & 3887.34 \
B-I & 0.591288 & 11749 & 4107.7 \
V-U & -0.558545 & 11640 & 3631.36 \
V-B & -0.580019 & 11884 & 3998.04 \
R-U & -0.567270 & 11632 & 3743.12 \
R-B & -0.574867 & 11763 & 3887.34 \
R-W2 & -0.535443 & 4022 & 1153.1 \
I-U & -0.579188 & 11626 & 3900.04 \
I-B & -0.591288 & 11749 & 4107.7 \
I-W2 & -0.574056 & 4020 & 1324.75 \
J-U & -0.536106 & 3709 & 1066 \
J-W2 & -0.577232 & 1943 & 647.401 \
K-U & -0.535644 & 3730 & 1070.19 \
K-W1 & -0.512554 & 1938 & 509.136 \
K-W2 & -0.591156 & 1960 & 684.953 \
W1-K & 0.512554 & 1938 & 509.136 \
W2-R & 0.535443 & 4022 & 1153.1 \
W2-I & 0.574056 & 4020 & 1324.75 \
W2-J & 0.577232 & 1943 & 647.401 \
W2-K & 0.591156 & 1960 & 684.953 \
bottomrule
end{tabular}
caption[Best photometric colours from the MgII dataset]{Photometric colours with highest r-value from the MgII dataset.}
label{table:MgII_colours}
end{table}
end{document}

You just need to set appropriate values in your table-formats. In your case, you have to worry about the number of digits before and after the decimal separator and, in the second column, the presence of the sign.
documentclass{article}
usepackage{siunitx}
usepackage{booktabs}
begin{document}
begin{table}
centering
addtolength{tabcolsep}{-0.3pt}
sisetup{group-digits=integer}
begin{tabular}{
@{}
l
S[table-format=+1.6]
S[table-format=5.0]
S[table-format=4.3]
@{}
}
toprule
Combo & {$|r|>0.5$} & {$n>100$} & {$r^2n$} \
midrule
U-V & 0.558545 & 11640 & 3631.36 \
U-R & 0.567270 & 11632 & 3743.12 \
U-I & 0.579188 & 11626 & 3900.04 \
U-J & 0.536106 & 3709 & 1066 \
U-K & 0.535644 & 3730 & 1070.19 \
B-V & 0.580019 & 11884 & 3998.04 \
B-R & 0.574867 & 11763 & 3887.34 \
B-I & 0.591288 & 11749 & 4107.7 \
V-U & -0.558545 & 11640 & 3631.36 \
V-B & -0.580019 & 11884 & 3998.04 \
R-U & -0.567270 & 11632 & 3743.12 \
R-B & -0.574867 & 11763 & 3887.34 \
R-W2 & -0.535443 & 4022 & 1153.1 \
I-U & -0.579188 & 11626 & 3900.04 \
I-B & -0.591288 & 11749 & 4107.7 \
I-W2 & -0.574056 & 4020 & 1324.75 \
J-U & -0.536106 & 3709 & 1066 \
J-W2 & -0.577232 & 1943 & 647.401 \
K-U & -0.535644 & 3730 & 1070.19 \
K-W1 & -0.512554 & 1938 & 509.136 \
K-W2 & -0.591156 & 1960 & 684.953 \
W1-K & 0.512554 & 1938 & 509.136 \
W2-R & 0.535443 & 4022 & 1153.1 \
W2-I & 0.574056 & 4020 & 1324.75 \
W2-J & 0.577232 & 1943 & 647.401 \
W2-K & 0.591156 & 1960 & 684.953 \
bottomrule
end{tabular}
caption[Best photometric colours from the MgII dataset]{Photometric colours with highest r-value from the MgII dataset.}
label{table:MgII_colours}
end{table}
end{document}

edited Nov 13 at 21:36
answered Nov 13 at 20:36
gusbrs
6,0492838
6,0492838
Ah that's better! Is there any way to avoid having to put the braces around the text values in the first column? Maybe a column format specifier or something?
– Jim421616
Nov 13 at 20:41
1
@Jim421616 Your first column is anltype column, so as far as I know, you don't need the brace protection there already.
– gusbrs
Nov 13 at 20:43
@Jim421616 I've added some small improvements (booktabs, in particular, but also better digit groupint).
– gusbrs
Nov 13 at 20:57
Ok, so what does the linesisetup{group-digits=integer}do exactly?
– Jim421616
Nov 13 at 23:38
1
@Jim421616 It introduces grouping for larger numbers, but only for the integer part.siunitx's default is to put a thin space between groups and to group by three digits, but doesn't separate a single digit (that is, you must have at least five numbers for the grouping to take place). Notice the five digit numbers in your third column, and you'll see what's going on.
– gusbrs
Nov 13 at 23:47
|
show 1 more comment
Ah that's better! Is there any way to avoid having to put the braces around the text values in the first column? Maybe a column format specifier or something?
– Jim421616
Nov 13 at 20:41
1
@Jim421616 Your first column is anltype column, so as far as I know, you don't need the brace protection there already.
– gusbrs
Nov 13 at 20:43
@Jim421616 I've added some small improvements (booktabs, in particular, but also better digit groupint).
– gusbrs
Nov 13 at 20:57
Ok, so what does the linesisetup{group-digits=integer}do exactly?
– Jim421616
Nov 13 at 23:38
1
@Jim421616 It introduces grouping for larger numbers, but only for the integer part.siunitx's default is to put a thin space between groups and to group by three digits, but doesn't separate a single digit (that is, you must have at least five numbers for the grouping to take place). Notice the five digit numbers in your third column, and you'll see what's going on.
– gusbrs
Nov 13 at 23:47
Ah that's better! Is there any way to avoid having to put the braces around the text values in the first column? Maybe a column format specifier or something?
– Jim421616
Nov 13 at 20:41
Ah that's better! Is there any way to avoid having to put the braces around the text values in the first column? Maybe a column format specifier or something?
– Jim421616
Nov 13 at 20:41
1
1
@Jim421616 Your first column is an
l type column, so as far as I know, you don't need the brace protection there already.– gusbrs
Nov 13 at 20:43
@Jim421616 Your first column is an
l type column, so as far as I know, you don't need the brace protection there already.– gusbrs
Nov 13 at 20:43
@Jim421616 I've added some small improvements (booktabs, in particular, but also better digit groupint).
– gusbrs
Nov 13 at 20:57
@Jim421616 I've added some small improvements (booktabs, in particular, but also better digit groupint).
– gusbrs
Nov 13 at 20:57
Ok, so what does the line
sisetup{group-digits=integer} do exactly?– Jim421616
Nov 13 at 23:38
Ok, so what does the line
sisetup{group-digits=integer} do exactly?– Jim421616
Nov 13 at 23:38
1
1
@Jim421616 It introduces grouping for larger numbers, but only for the integer part.
siunitx's default is to put a thin space between groups and to group by three digits, but doesn't separate a single digit (that is, you must have at least five numbers for the grouping to take place). Notice the five digit numbers in your third column, and you'll see what's going on.– gusbrs
Nov 13 at 23:47
@Jim421616 It introduces grouping for larger numbers, but only for the integer part.
siunitx's default is to put a thin space between groups and to group by three digits, but doesn't separate a single digit (that is, you must have at least five numbers for the grouping to take place). Notice the five digit numbers in your third column, and you'll see what's going on.– gusbrs
Nov 13 at 23:47
|
show 1 more comment
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459842%2fsiunitx-squashing-columns%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown