I have a table where entries are two (rational/integer) numbers separated by a comma. Is it possible in each column to (a) keep the column labels $L$, $M$, and $R$ centered and (b) align the entries so that the commas are aligned?
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{table}
\centering
\setlength{\extrarowheight}{3pt}
\begin{tabular}{c|ccc|}
\multicolumn{1}{c}{} & \multicolumn{1}{c}{$L$} & \multicolumn{1}{c}{$M$} & \multicolumn{1}{c}{$R$} \\ \cline{2-4}
$T$ & $-1, \frac{3}{5}$ & $3,4$ & $0,-1$ \\
$B$ & $1,-8$ & $2,-4$ & $0,1$ \\ \cline{2-4}
\end{tabular}
\end{table}
\end{document}
Best Answer
The dcolumn package is your friend.
Addendum: In the code used here, no whitespace padding is inserted around the commas. If do you want the commas to be surrounded by, say,
\thinspace
(aka\,
), just change\newcolumntype{C}{D{,}{,}{2.2}}
to\newcolumntype{C}{D{,}{\,,\,}{2.2}}
.