Euro sign in table with siunitx
I would like to suggest an alternative solution: put the euro sign in the column headers.
And egreg suggests to use eurosym
without the gen
option, this way the euro symbol is more beautiful.
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[locale = DE]{siunitx}
\usepackage{eurosym}
\usepackage{booktabs}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{SSSS}
\toprule
{A (\euro)} & {B (\euro)} & {C (\euro)} & {D (\euro)} \\
\midrule
-199,37 & 0,00 & 33,27 & 166,10 \\
252,56 & 0,00 & -409,58 & 157,02 \\
104,67 & 0,00 & -40,18 & -64,48 \\
0,17 & 0,00 & -2,52 & 2,35 \\
0,00 & 0,00 & 0,00 & 0,00 \\
\bottomrule
\end{tabular}
\end{table}
Or:
\begin{table}[h]
\centering
\begin{tabular}{SSSS}
\toprule
{A} & {B} & {C} & {D} \\
{(\euro)} & {(\euro)} & {(\euro)} & {(\euro)} \\
\midrule
-199,37 & 0,00 & 33,27 & 166,10 \\
252,56 & 0,00 & -409,58 & 157,02 \\
104,67 & 0,00 & -40,18 & -64,48 \\
0,17 & 0,00 & -2,52 & 2,35 \\
0,00 & 0,00 & 0,00 & 0,00 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
What about this?
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[locale = DE]{siunitx}
\usepackage{textcomp}
\usepackage{booktabs, makecell}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\begin{document}
\begin{table}[h]
\centering
\setcellgapes{3pt}
\makegapedcells
\sisetup{table-space-text-post={\,€},
table-align-text-post=false}
\begin{tabular}{S[table-format=-3.2]<{\,€}
S[table-format= 1.2]<{\,€}
*{2}{S[table-format=-3.2]<{\,€}}
}
\toprule
\mc{A} & \mc{B} & \mc{C} & \mc{D} \cr
\midrule
-199,37 & 0,00 & 33,27 & 166,10 \cr
252,56 & 0,00 & -409,58 & 157,02 \cr
104,67 & 0,00 & -40,18 & -64,48 \cr
0,17 & 0,00 & -2,52 & 2,35 \cr
0,00 & 0,00 & 0,00 & 0,00 \cr
\bottomrule
\end{tabular}
\end{table}
\end{document}
With the appropriate table-format
option for the individual cells as well as with table-space-text-post=€
and table-align-text-post=true
you can get the following output:
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[locale = DE]{siunitx}
\usepackage[gen]{eurosym}
\begin{document}
\begin{table}[h]
\sisetup{table-space-text-post=€, table-align-text-post=true}
\centering
\begin{tabular}{|S[table-format=-3.2]|
S[table-format=1.2]|
S[table-format=-3.2]
|S[table-format=-3.2]|}
\hline
{A} & {B} & {C} & {D} \\
\hline
-199,37 € & 0,00 € & 33,27 € & 166,10 € \\
252,56 € & 0,00 € & -409,58 € & 157,02 € \\
104,67 € & 0,00 € & -40,18 € & -64,48 € \\
0,17 € & 0,00 € & -2,52 € & 2,35 € \\
0,00 € & 0,00 € & 0,00 € & 0,00 € \\
\hline
\end{tabular}
\end{table}
\end{document}
To avoid repeating the € symbol over and over again, I'd either put it into the column header of the corresponding columns or even into the caption of the table.