Align position of decimal point within table of numbers, text and percentage values
It's probably better to use siunitx
; the \sisetup
settings will be local to this table, since the command appears in the table
environment.
\documentclass[a4paper,12pt]{scrreprt}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{table}[htpb]
\sisetup{
table-space-text-post=\%, % leave space for a ‘%’
table-align-text-post=false, % push ‘%’ next to the number
}
\centering
\begin{tabular}{
l
S[table-format=6.4] % six integer digits, four decimal ones
S[table-format=4.0]
S[table-format=3.4]
S[table-format=3.3]
}
\toprule
\multicolumn{1}{l}{Test 1} & \multicolumn{2}{c}{Test 2} & \multicolumn{2}{c}{Test 3} \\
\cmidrule{1-1}\cmidrule(lr){2-3}\cmidrule(l){4-5}
Observations successful &
\multicolumn{1}{c}{no} &
\multicolumn{1}{c}{yes} &
\multicolumn{1}{c}{maybe} &
\multicolumn{1}{c}{no} \\
\midrule
adsadad & 546546.546 & 4646 & 45.646 & 456.456 \\
\% AAA & 235.25\% & 22\% & 232.34\% & 234.25\% \\
\% CCC3 & 0.0033 & 0 & 0.0031 & 23 \\
\% CCC4 & 0.0033 & 0\% & 0.0031 & 0 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
\documentclass[a4paper, 12pt]{scrreprt}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{floatrow}
\floatsetup[table]{capposition=top}
\usepackage{dcolumn}
\newcolumntype{Y}{D..{6.4}}
\newcommand\pct{\rlap{$\%$}}
\begin{document}
\begin{table}[htpb]
\begin{tabular}{lYYYY}
\toprule
\multicolumn{1}{l}{Test 1} & \multicolumn{2}{c}{Test 2} & \multicolumn{2}{c}{Test 3} \\
Observations successful &
\multicolumn{1}{c}{no} &
\multicolumn{1}{c}{yes} &
\multicolumn{1}{c}{maybe} &
\multicolumn{1}{c}{no} \\
adsadad & 546546.546 & 4646 & 45.646 & 456.456 \\
AAA & 235.25\pct & 22\pct & 232.34\pct & 234.25\pct \\
CCC3 & 0.0033 & 0 & 0.0031 & 23 \\
CCC4 & 0.0033 & 0\pct & 0.0031 & 0 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}