# How can I align numerical and angle values in a table using siunitx?

As described in DIN 461, units such as "Degree", "Minute" or "Second" should stay with their numerical value when labeling the tics of a coordinate system. I have no proof, but I think that this rule also makes sense for tables. Normally, I always write the unit apart of the values but for angles, I would like to keep the unit in place.

My MWE shoes that case for the unit \degree.

\documentclass[]{scrreprt}
\usepackage{xltxtra}
\usepackage[
per-mode=symbol-or-fraction,
locale=DE,
sticky-per
]{siunitx}

\begin{document}
\begin{table}
\centering
\sisetup{table-number-alignment = center, }
\begin{tabular}{|r|S|S|}
\hline
\textbf{Test:} & {Test1} & {Test2}\\
\hline
\hline
$\alpha_1$&\ang{17.0}&\ang{18.0}\\
\hline
$\alpha_2$&\ang{17.00}&\ang{18.00}\\
\hline
$\alpha_3$&\ang{17} & \ang{18}\\
\hline
$T_{\text{t},0}/\si{\kelvin}$& 293.15 & 393.15\\
\hline
$p_{\text{t},0}/\si{\pascal}$& 80000,00 & 90000,00\\
\hline
\end{tabular}
\caption{Test table}\label{tab:tt}
\end{table}
\end{document}


For such tables, I can't get the numbers aligned properly. As you can see, the first three rows differ in their decimal alignment and non is equal to the last two rows (which work well). It should be a second question, but if anybody has an idea on getting the cell width automatically adjusted to big numbers, that would be great, too.

• I would advice 'dividing through': $\alpha_{1}/\si{degree}$, etc. You then only align numbers on decimal markers. Moreover, I've no idea wheat DIN 461 is on about: degrees are units like any other. – Joseph Wright Jun 25 '13 at 8:51
• I did that before but didn't like it. The dividing looks strange for angles and even more if angles like \ang{;;-3} appear. Same for 10^h for a time point which should be differed to \SI{10}{h} for a time range. DIN 461 is a German standardization mentioning exactly that case, which disturbs me in tables, as rule for coordinate systems. – LaRiFaRi Jun 25 '13 at 8:59

Is this what you mean? The trick is done with the table-space-text-post = \si{\degree} and table-align-text-post = false options. I had to split the \ang commands in the number and symbol part.

\documentclass[]{scrreprt}
\usepackage{xltxtra}
\usepackage[
per-mode=symbol-or-fraction,
locale=DE,
sticky-per
]{siunitx}
\usepackage{booktabs}

\begin{document}
\begin{table}
\centering
\sisetup{table-figures-decimal = 3,
table-figures-integer = 5,
table-space-text-post = \si{\degree}}
\begin{tabular}{l
S[table-number-alignment = right, table-align-text-post = false]
S[table-number-alignment = right, table-align-text-post = false]}
\toprule
\textbf{Test:} & {Test1} & {Test2}\\
\midrule
$\alpha_1$&17.0\si{\degree}&18.0\si{\degree}\\
$\alpha_2$&17.00\si{\degree}&18.00\si{\degree}\\
$\alpha_3$&17\si{\degree} & 18\si{\degree}\\
$T_{\text{t},0}/\si{\kelvin}$& 293.15 & 393.15\\
$p_{\text{t},0}/\si{\pascal}$& 80000,00 & 90000,00\\
\bottomrule
\end{tabular}
\caption{Test table}\label{tab:tt}
\end{table}
\end{document}

• Damn!, I was trying to be faster than Joseph :-) – TeXtnik Jun 25 '13 at 8:57
• That's beautiful and exactly what I meant. Just a pity, that I will have to edit a lot of angle values which I all typeset to \ang{}. It's a great work around but will always need adaption for the other mentioned cases. – LaRiFaRi Jun 25 '13 at 9:14
• Two more questions to your result. Can I move everything behind S to the sisetup{}-section? Why do I have to tell the length of mantissa and decimal? Isn't that quite uncomfortable especially when reading values out of a data file? – LaRiFaRi Jun 25 '13 at 9:17
• And one more: you changed my table-number-alignment = center to table-number-alignment = right. However, I can't see a difference between your and my case (when toggled in your MWE) – LaRiFaRi Jun 25 '13 at 9:24
• @LaRiFaRi: I think that the problem of overlapping was fixed when I tell the length of the numbers. I prefer to align numbers to the right, but aligning them to the decimal separators; I think makes them look centred. – TeXtnik Jun 25 '13 at 10:19