# siunitx: Appended currency symbol mispositioned with aligned negative values

I'm trying to do some LaTeX-table-magic for a friend, and I've run into a strange issue I haven't been able to find a solution for.

I'm using siunitx (along with booktabs) to align some values in a table. The values are actually amounts of money—so a currency symbol (namely, \,€) is appended to the number.

As you can see from the example provided, adding a negative value screws with the positioning of the currency symbol. Note that the alignment of the values is as expected (i.e., aligned at the decimal separator); just the appended symbol gets misplaced.

Here's the code:

\documentclass[a4paper]{article}

\usepackage{fontspec}
\usepackage{booktabs}
\usepackage{siunitx}

\sisetup{output-decimal-marker={,},group-separator ={.},group-minimum-digits=4,detect-all}

\begin{document}

\begin{table}
\centering
\begin{tabular}{@{}l*{2}{S}@{}}
\toprule
\multicolumn{1}{c}{\textbf{Col 1}} & \multicolumn{1}{c}{\textbf{Col 2}} & \multicolumn{1}{c}{\textbf{Col 3}} \\
\midrule
Some description.                  &                                    & 0,11\,€                            \\
Other stuff.                       &  18,00\,€                          & -123,45\,€                         \\
More things.                       &  -0,29\,€                          & 11,00\,€                           \\
Items.                             &  0,29\,€                           &                                    \\
\midrule
\multicolumn{1}{r}{\textbf{Sum:}}  &  9,99\,€                           & 11,11\,€                           \\
\bottomrule
\end{tabular}
\end{table}
\end{document}


And here's the result:

(Unfortunately, since not all the fields contain a number, I cannot specify S<{\,€} as a tabular-column, which does fix—suprisingly—one of the erroneous fields but not the other…)

I know that with my approach the decimal separator and the currency symbol will not necessarily be both aligned at the same time, but I can live with that. (I think I saw a solution where both the separator and a symbol were aligned; but even that solution didn't get me far at all—though maybe understanding and implementing that solution would solve my issue and be even 'more correct'?)

Any help would be greatly appreciated!

Thanks, Nicola

When you don't let siunitx 'know' otherwise, the strategy used for centring on a decimal marker is to put it at the centre of the column. That means that in your example you've got a lot of white space about in the output. The better approach is to tell siunitx exactly how much space you need, which ideally will include any 'post text' part. That might lead to a tabular header something like

{
@{}
l
S[table-format = -2.2, table-space-text-post = {\,€}]
S[table-format = -3.2, table-space-text-post = {\,€}]
@{}
}


(I'd also modify the first and s column headers to \multicolumn{1}{@{}l}{\textbf{Col 1}} and \multicolumn{1}{c@{}}{\textbf{Col 3}}, respectively: unrelated to the matter at hand but avoids some stray spacing.)

However, I'd usually move units from the table body to the header, so something more like

\begin{tabular}
{
@{}
l
S[table-format = -2.2]
S[table-format = -3.2]
@{}
}
\toprule
{Col 1} & \multicolumn{2}{c@{}}{Cost/€} \\
& {Col 2} & {Col 3}           \\
\midrule
Some description.                  &        &    0,11 \\
Other stuff.                       &  18,00 & -123,45 \\
More things.                       &  -0,29 &   11,00 \\
Items.                             &   0,29 &         \\
\cmidrule(l){2-3}
Sum                                &  9,99  & 11,11   \\
\bottomrule
\end{tabular}

• Thank you for your insightful reply! (With regards to moving the unit to the header: While I would normally do so, in this particular case it was requested to be in the table body.) – NicApicella Feb 18 '16 at 11:11