3

I would like to have this kind of table

\begin{spreadtab}{{tabularx}{\linewidth}{XS[table-format=4.2]l}}
\toprule
@{Was}  & @{Betrag [\euro]} & @{Belegart} \\
\midrule
@Nice People Charity & 300 & Spendenbescheinigung @\\
\midrule
@Summe [\euro]  & \textbf{\numprint{:={sum(b2:[0,-1]) }}} & \\
\bottomrule
\end{spreadtab}

build with

\usepackage{spreadtab}
\usepackage{siunitx}

but the money amount in the second and last lines are not aligned as they should:

enter image description here

It seems to me that the last row does not get included by siunitx. How can I get this to work? Tinkering with table-format=4.2 does not really count, because then I have the same problem with another table somewhere (the whole thing is in a custom made command, but let's keep it simple for now).

Bonus if one can get me this to work with

\usepackage{tabu}

instead of tabularx. I'd like to use XS[...] or X[c]{S[...]} or whatever the current command is... ready through stackexchange got me a little confused... sorry.

I tried using

\usepackage{dcolumn}

which did not work, because it does not support \euro from

\usepackage{eurosym}

Edit: From siunitx: aligning numbers by decimal points in tables doesn't work for bolded or italicized numbers and siunitx: How to get bold, aligned entries and how to align when units differ in length? I got that the reason the numbers are not aligned are because of the boldness and \numprint. However, I have not been able to get the suggestions to work – propably because I am additionally using spreadtab.

2

I managed to find a solution after a lot of reasoning and trying out.

The reason for my problem is caused by the boldness and the letterspacing, but because something other than the number was put in the supposed-to-be-cell. In my example this "something other" is the \textbf{\numprint{:={ ... }. This seems to confuse the spreadtab-siunitx-combination. \robustify from siunitx: aligning numbers by decimal points in tables doesn't work for bolded or italicized numbers does not help either.

The solution is to make the entire row bold (giving the command at a different place – tabu is helping with that) and then un-bolding the cells which are not supposed to be bold:

\begin{spreadtab}{{tabu} to \linewidth{XS[table-format=4.2]l}}
\toprule
@{Was}  & @{Betrag [\euro]} & @{Belegart} \\
\midrule
@Nice People Charity & 300 & Spendenbescheinigung @\\
\midrule
\rowfont\bfseries
{\mdseries @Summe [\euro]}  & sum(b2:[0,-1]) & \\
\bottomrule
\end{spreadtab}

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.