I am trying to align some numbers in a tabular on the decimal point. I have been using the dcolumn option but given that my column title is a year, it aligns also the year on the decimal point, which I do not want.
Here is my MWE :
\documentclass{beamer}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\begin{document}
\begin{frame}{title}
\begin{table}[H]
\centering
\begin{tabular}{|l|d{4.6}|c|c|} % I just did it for one to see the result
\hline
\textbf{Poste} & \textbf{2000} & \textbf{2005} & \textbf{2010} \\ \hline
Alimentation - b1 & -0.034*** & -0.036** & -0.016*** \\
Alcool et Tabac - b2 & -0.009*** & -0.006 & -0.011*** \\
Habillement - b3 & 0.004 & 0.001 & 0.001 \\
Logement - b4 & -0.067*** & -0.106*** & -0.073*** \\
Meuble/Entretien - b5 & 0.019*** & 0.016*** & 0.001*** \\
Santé - b6 & -0.001 & 0.005 & 0.036 \\
Transport - b7 & 0.066*** & 0.075*** & -0.015*** \\
Communication - b8 & -0.001 & -0.006*** & 0.028*** \\
Loisir/Culture - b9 & 0.017*** & 0.030*** & 0.012*** \\
Autres biens/services - b12 & -0.025 & -0.016 & -0.359 \\
\hline
\end{tabular}
\end{table}
\end{frame}
\end{document}
And here is a snapshot showing how the year (2000) is aligned. How can I keep the other numbers aligned but the year centered (like 2005 and 2010) ?
Best Answer
I'd suggest using
siunitx
(andbooktabs
for better horizontal rules).As you see, in order to center a cell's contents in a numeric column, it's sufficient to type it between braces.
There's no reason for using a
table
environment.You can certainly keep the vertical rules:
Now, compare the two renderings and take your pick. I believe you'll choose the “no vertical rule version”.
;-)