# Help Fixing a Table

I am trying to create a table using the code provided here for decimal alignment and the code provided here to have two lines for some headers. Since I'm not sure exactly what each line does, I had trouble applying it to my table. As shown below, the first and second column formats the year intervals differently and the second column is not centered.

Further, could someone explain what \begin{tabular}{l*{4}{d{3.3}} }does?

Any help with fixing these issues, and any other possible improvements you see, would be greatly appreciated.

\documentclass{article}

\usepackage{dcolumn,booktabs}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\multicolumn{1}{c}{\bfseries\begin{tabular}{@{}c@{}}#1\end{tabular}}}

\begin{document}

\begin{table}
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{l*{4}{d{3.3}} }
\toprule
\midrule
2001-05&    1980-85 &0.08&  (-0.46,0.62)\\
2016-20 &1980-85    &-0.21& (-0.76,0.33)\\
2011-15&    2006-10&    0.04    &(-0.06,0.14)\\

\bottomrule
\end{tabular}
\end{table}

\end{document}


Here is a solution, with some improvements (in particular, loading the caption package yields a more sensible spacing between caption table). Note the d column type is really useful only in the third column.

\documentclass{article}

\usepackage{dcolumn,booktabs, caption}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\multicolumn{1}{c}{\begin{tabular}{@{}>{\bfseries}c@{}}#1\end{tabular}}}

\begin{document}

\begin{table}
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{ccd{1.2}>{$}c<{$}}
\toprule
\midrule
2001--05& 1980--85 &0.08& (-0.46,0.62)\\
2016--20 &1980--85 &-0.21& (-0.76,0.33)\\
2011--15& 2006--10& 0.04 &(-0.06,0.14)\\
\bottomrule
\end{tabular}
\end{table}

\end{document}


• This looks great, thanks! Could you explain what \begin{tabular}{cc >{\arraybackslash}d{1.2}>{$}c<{$}*{4}{d{3.3}} } does? – Remy Jul 10 '19 at 15:40
• The first two columns are centred. You actually can remove >{\arraybackslash} – it is used in fixed width columns (such as p{some length}) to stipulate that \\ is used to go to the next row. I was not too sure of the status of the d column type. As to *{4}{d{3.3}}, which you can delete (I forgot to clean the preamble) it means repeating 4 times a column of type d{3.3}, the latter denoting a column centred on the decimal dot, with 3 digits in the integer part, and 3 digits in the decimal part. – Bernard Jul 10 '19 at 15:55

You should change the preamble l*{4}{d{3.3}} and put ccd{3.3}d{3.3} and you will have the following result.

In ccd{3.3}d{3.3}, the two first c are for the two first columns centered and the two d{3.3} are for the other columns (alignment on the decimal point).