3

I have a table with one index column and three columns of data. I would like the table have the data aligned using the decimal point. Following the answer to this question I try the following code:

\documentclass{article}
\usepackage{booktabs,subcaption,amsfonts,dcolumn} 
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}

\begin{table}
\centering\small
\begin{tabular}[t]{@{} l c *{3}{d{1.11}} @{}}
\toprule
 \mc{$n$} & \mc{$\nu=1/3$} & \mc{$\nu=1/5$} & \mc{$\nu=1/7$} \\
\midrule
   1 &         -2.6448(2) &         -3.5613(2) &         -3.7317(2) \\
   2 &          1.0022(1) &          2.8438(1) &          3.4644(1) \\
   3 &          0.0613(4) &         -1.8256(4) &         -3.0903(4) \\
   4 &         -0.4103(4) &          0.7144(4) &          2.4534(4) \\
   5 &          0.3928(6) &          0.1675(6) &         -1.5920(6) \\
   6 &         -0.2573(5) &         -0.6854(5) &          0.6627(5) \\
   7 &          0.1225(5) &          0.8790(5) &          0.1630(5) \\
\bottomrule
\end{tabular}
\caption{Expansion coefficients for various filling factors.}
\label{tab:LaughlinScaledPairCorrCoeffs}
\end{table}

However there are a couple of problems: the header row is not aligned with the data rows, the numbers in the first data column are not aligned following the decimal point, and the third data column has more space than the others.

2 Answers 2

4

Some suggestions

  • Use d{2.7} instead of d{1.11} for the numerical columns. Don't forget to set aside some space for the - (minus) symbols -- hence the number 2 ahead of the decimal marker. The widths of ( and ) are about half that of the numerals; hence the suggestion to use 7 for the number of digits after the decimal marker.

  • Don't encase $n$ in the very first header cell in \mc, as its column type is l.

  • Get rid of the unused c column

enter image description here

\documentclass{article}
\usepackage{booktabs,dcolumn} 
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}

\begin{table}
\centering
%\small
\begin{tabular}{@{} l *{3}{d{2.7}} @{}}
\toprule
 $n$ & \mc{$\nu=1/3$} & \mc{$\nu=1/5$} & \mc{$\nu=1/7$} \\
\midrule
   1 &         -2.6448(2) &         -3.5613(2) &         -3.7317(2) \\
   2 &          1.0022(1) &          2.8438(1) &          3.4644(1) \\
   3 &          0.0613(4) &         -1.8256(4) &         -3.0903(4) \\
   4 &         -0.4103(4) &          0.7144(4) &          2.4534(4) \\
   5 &          0.3928(6) &          0.1675(6) &         -1.5920(6) \\
   6 &         -0.2573(5) &         -0.6854(5) &          0.6627(5) \\
   7 &          0.1225(5) &          0.8790(5) &          0.1630(5) \\
\bottomrule
\end{tabular}
\caption{Expansion coefficients for various filling factors.}
\label{tab:LaughlinScaledPairCorrCoeffs}
\end{table}

\end{document}
1
  • 1
    For the utmost in alignment precision, replace \mc{$\nu=1/7$} with \multicolumn{1}{c@{}}{$\nu=1/7$}...
    – Mico
    Feb 21, 2016 at 10:56
1

Same code with minor modification

\documentclass{article}
\usepackage{booktabs,subcaption,amsfonts,dcolumn} 
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{r}{#1}} % handy shortcut macro

\begin{document}
\begin{table}
\centering\small
\begin{tabular}[t]{r l r*{3}{d{1.11}}}
\toprule
\mc{$n$} & \mc{$\nu=1/3$} & \mc{$\nu=1/5$} & \mc{$\nu=1/7$} \\
\midrule
 1 &    \mc{-2.6448(2) } &   \mc{ -3.5613(2)} &    \mc{ -3.7317(2)} \\
 2 &     \mc{1.0022(1) } &   \mc{  2.8438(1) }&     \mc{ 3.4644(1) }\\
 3 &    \mc{ 0.0613(4)} &    \mc{ -1.8256(4) }&    \mc{  -3.0903(4) }\\
 4 &    \mc{ -0.4103(4) } &    \mc{ 0.7144(4)} &    \mc{    2.4534(4) }\\
 5 &     \mc{ 0.3928(6) } &    \mc{ 0.1675(6) }&     \mc{  -1.5920(6)} \\
 6 &     \mc{0.2573(5) } &  \mc{  -0.6854(5) }&    \mc{  0.6627(5)} \\
 7 &     \mc{ 0.1225(5)}  &     \mc{ 0.8790(5)} &    \mc{ 0.1630(5) }\\
 \bottomrule
 \end{tabular}
\caption{Expansion coefficients for various filling factors.}
\label{tab:LaughlinScaledPairCorrCoeffs}
\end{table}
\end{document}

alignedtbl

1
  • 1
    By encasing all numbers in \mc wrappers, the - symbols won't be rendered as mathematical minus symbols but, instead, as short dashes. One might as well replace all d{1.11} column specifiers with r and remove all \mc wrappers.
    – Mico
    Feb 21, 2016 at 13:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .