Formatting *** in a Regression Result Table

formattingtables

I have a code as given below:

\documentclass[10pt]{article}

\usepackage{ltablex}

\begin{document}
\begin{tabularx}{\textwidth}{@{}rr@{}} 
A & $0.11^{***}$\\   & (-12.112) \\    B & $0.15^{*}$\\   & (-8.452)\\
C & $0.76^{}$\\   & (12.452)\\     
\end{tabularx}

\end{document}

This produces a result as given below:

enter image description here

However, I want "stars (***/*) etc. to be formatted differently as given in the picture below:

enter image description here

Please let me know how to format the table. Thanks.

Best Answer

You may want to use the dcolumn package for this purpose: It provides a column type called D which serves to align numbers in a column on the decimal marker without need for further intervention to handle symbols such as (, ), and *.

Because the contents of a D column are automatically typeset in math mode, there's also no need to specify opening and closing $ markers. However, if you have a cell -- say, in the header row -- in a D-type column that contains some text or other mostly non-numeric material, be sure to encase it in a \mulicolumn{1}{c}{<some text>} macro.

In the MWE below, I've modified the numbers relative to your code to make them conform to the structure of the numbers in the screenshot you posted.

enter image description here

\documentclass{article}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}} % for alignment of numbers on decimal marker
\begin{document}
\begin{tabular}{@{} r d{4.6} @{}} 
\hline  % just to mark width of tabular env.
A & 0.123^{***}\\   & (-12.11)\\    
B & 0.456^{*}  \\   &  (-8.45)\\
C & 0.789^{**} \\   &  (12.34)\\     
\end{tabular}
\end{document}