I have tried for about an hour and a half now to get my table data to align by the decimal places and I am beginning to lose my mind a bit. I am aware of the siunitx
and dcolumn
packages but cannot get either to work for my table. Could someone please help? Thanks! Below is the code for my table:
\begin{table}
\begin{center}
\begin{tabular}{p{2.3cm}p{2.3cm}p{2.3cm}p{2.3cm}p{2.3cm}p{1.5cm}} \hline \hline
Radius \newline ($R/R_\odot$) & Luminosity \newline ($L/L_\odot$) & Mass \newline ($M/M_\odot$) & Temperature \newline ($10^6$ K) & Density \newline (kg/m$^3$) & Pressure \newline ($P/P_c$) \\ \hline
0.0 & 0.00 & 0.00 & 15.5 & 160000 & 1.00 \\
0.1 & 0.42 & 0.07 & 13.0 & 90000 & 0.46 \\
0.2 & 0.94 & 0.35 & 9.5 & 40000 & 0.15 \\
0.3 & 0.99 & 0.64 & 6.7 & 13000 & 0.04 \\
0.4 & 0.99 & 0.85 & 4.8 & 4000 & 0.007 \\
0.5 & 0.99 & 0.94 & 3.4 & 1000 & 0.001 \\
0.6 & 0.99 & 0.98 & 2.2 & 400 & 0.0003 \\
0.7 & 0.99 & 0.99 & 1.2 & 80 & 4$\times10^{-5}$ \\
0.8 & 0.99 & 1.00 & 0.7 & 20 & 5$\times10^{-6}$ \\
0.9 & 0.99 & 1.00 & 0.3 & 2 & 3$\times10^{-7}$\\
1.0 & 0.99 & 1.00 & 0.006 & 0.0003 & 4$\times10^{-13}$ \\ \hline
\end{tabular}
\end{center}
\end{table}
And here is what the current table looks like. Note that the decimal points are not aligned (see Temperature column):
Best Answer
It's easy with
siunitx
:Tables with heterogeneous data are always difficult to typeset. If you don't want the space before the times sign in the last column, change the table preamble into
and the output will be