2

How do I align the cell contents of a dcolumn-Type central at a specified point other than the decimal point (e.g. the second decimal place)?

I have a table of the following structure:

\begin{table}[!htbp] \centering 
\begin{tabular}{l*{2}{D{.}{.}{-1}}} 
\hline
  & \multicolumn{1}{c}{This is centered text . This is centered text} & \multicolumn{1}{c}{Narrow} \\
\hline 
 \textit{Measure1} & 0.001 & 0.001\\ 
  & (0.001) & (0.001) \\ 
 \textit{Measure2} &  -0.006^{**} &  -0.006^{**}\\ 
\hline
\end{tabular} 
\end{table}

enter image description here

The multicolumn content is aligned center while the dcolumn content is aligned centered around the ".", which is perfectly fine. However, if I have a Narrow column as shown, the content of the dcolumn-cell looks weirdly aligned due to its three decimal places (and potential **, (), etc.)

Do you have and idea how to resolve this issue? Workarounds like adding extra-spaceholders may also help.

Thanks in advance

1

I think the real solution (as opposed to just treating some symptoms) is not to use D{.}{.}{-1} for all columns for which alignment on the decimal markers is supposed to be performed. Instead, taylor the argument of the D column type to the properties of the numbers actually encountered in the respective columns.

enter image description here

\documentclass{article}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}} % d{2.5}: reserve 2 digits before and 5 digits after decimal marker

\begin{document}
\begin{table}[!htbp] 
\centering
\begin{tabular}{l d{-1} d{2.5} }
\hline
  & \multicolumn{1}{c}{This is centered text. This is centered text.}
  & \multicolumn{1}{c}{Narrow} \\
\hline
 \textit{Measure 1} & 0.001 & 0.001\\
  & (0.001) & (0.001) \\
 \textit{Measure 2} &  -0.006^{**} &  -0.006^{**}\\
\hline
\end{tabular}
\end{table}
\end{document} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.