Decimal alignment in a table with math mode
You are probably looking for \multicolumn
:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{ctable}
\usepackage{tabularx}
\usepackage{graphicx}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1} }
\begin{document}
\begin{table}[]
\centering
\begin{tabular}{@{}lc*{4}{d{1.5}}@{}}
\toprule
{} & {} & \multicolumn{2}{c}{Group A} & \multicolumn{2}{c}{Group B} \\
\cmidrule(lr){3-4} \cmidrule(l){5-6}
Types & Character & \multicolumn{1}{c}{Results A} & \multicolumn{1}{c}{Results B} & \multicolumn{1}{c}{Results A} & \multicolumn{1}{c}{Results B} \\
\midrule
\multirow{3}{*}{Main}
{} & The Good & .111 & .789_{b}^{b} & .520 & .555_{b}^{a} \\
{} & The Bad & .111 & .636_{b}^{al} & .520 & .730_{b}^{al} \\
{} & The Ugly & .111 & .525_{b} & .520 & .696_{b} \\
\bottomrule
\end{tabular}
\caption{Caption}
\label{tab:my_label}
\end{table}
\end{document}
However, as mentioned in the comments, I think you should reconsider the case against siunitx
. More important than being a "basic package" is the fact that it is very well crafted and zealously maintained, besides being widely used. (This is not a judgement on dcolumn
of which I'm not an user). You should, of course, decide that along with your work group.
The same table done with siunitx
would be something like:
\documentclass{article}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{siunitx}
\begin{document}
\begin{table}
\centering
\sisetup{table-format = 0.3}
\begin{tabular}{@{}
lc
S
S[table-space-text-post = {$_{b}^{al}$}] % make it the largest post-number element
S
S[table-space-text-post = {$_{b}^{al}$}]
@{}}
\toprule
& & \multicolumn{2}{c}{Group A} & \multicolumn{2}{c}{Group B} \\
\cmidrule(lr){3-4} \cmidrule(l){5-6}
Types & Character & {Results A} & {Results B} & {Results A} & {Results B} \\
\midrule
\multirow{3}{*}{Main}
& The Good & .111 & .789{$_{b}^{b}$} & .520 & .555{$_{b}^{a}$} \\
& The Bad & .111 & .636{$_{b}^{al}$} & .520 & .730{$_{b}^{al}$} \\
& The Ugly & .111 & .525{$_{b}$} & .520 & .696{$_{b}$} \\
\bottomrule
\end{tabular}
\caption{Caption}
\label{tab:my_label}
\end{table}
\end{document}
It does automatically take care of the leading zero, emphasized by @Denis in the comments.
You can (should, in my opinion) use siunitx
; here I show also how to have real note markers upright that leave the exact space for them.
If you want to set some of the entries bold, there is a trick adapted from https://tex.stackexchange.com/a/352028/4427
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{siunitx}
\NewDocumentCommand{\bs}{}{\fontseries{b}\selectfont}
\makeatletter
\NewDocumentCommand{\tss}{mm}{%
{\m@th\ensuremath{%
^{\mbox{\fontsize\sf@size\z@\selectfont #1}}%
_{\mbox{\fontsize\sf@size\z@\selectfont #2}}%
}}%
}
\makeatother
\begin{document}
\begin{table}[htp]
\centering
\sisetup{detect-weight,mode=text}
\DeclareDocumentCommand{\bfseries}{}{\bs}
\begin{tabular}{
@{}
l
c
S[table-format=1.3]
S[table-format=1.3,table-space-text-post=\tss{al}{b}]
S[table-format=1.3]
S[table-format=1.3,table-space-text-post=\tss{al}{b}]
@{}
}
\toprule
& & \multicolumn{2}{c}{Group A} & \multicolumn{2}{c}{Group B} \\
\cmidrule(lr){3-4} \cmidrule(l){5-6}
Types & Character & {Results A} & {Results B} & {Results A} & {Results B} \\
\midrule
Main & The Good & \bs .111 & .789\tss{b}{b} & .520 & .555\tss{a}{b} \\
& The Bad & .111 & .636\tss{al}{b} & .520 & .730\tss{al}{b} \\
& The Ugly & .111 & .525\tss{}{b} & .520 & .696\tss{}{b} \\
\bottomrule
\end{tabular}
\caption{Caption}
\label{tab:my_label}
\end{table}
\end{document}
I wouldn't use \multirow
: blank space below “Main” means repetition. Shifting it down makes quite unclear whether “Main” refers to all rows or just the middle one.