I am trying to construct some tables using the package siunitx. As you can see in the example below, the number in column D are nicely aligned in the first three rows (after the header). However, the last number (46.57%) in the last row is not aligned anymore. I somehow guess that is related to the usage of \itshape (I followed the advice giving here).
Do you have any idea how to correctly align the figures in the last row using an italic font shape?
MWE:
\documentclass[a4paper,11pt]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{
group-digits=true,
group-minimum-digits=4,
add-integer-zero=false,
}
\begin{document}
\begin{table}[htbp]
\begin{center}
\caption{Some Table}
\begin{tabular}{c
c
S[table-format = 2.0]
S[table-format = 2.2]}
\toprule
A & B & {C} & {D} \\ \midrule
1 & 24 & 12 & 50.00\% \\
2 & 22 & 4 & 18.18\% \\
3 & 85 & 45 & 52.94\% \\ \midrule
\emph{Total} & \emph{131} & {\itshape 61} & {\itshape 46.57\%}\\
\bottomrule
\end{tabular}
\end{center}
\end{table}
\end{document}
EDIT:
New MWE based on the comments and answers:
\documentclass{article}
\usepackage{booktabs}
\usepackage{etoolbox}
\robustify\itshape
\usepackage{siunitx}
\sisetup{
group-digits=true,
group-minimum-digits=4,
add-integer-zero=false,
}
\begin{document}
\begin{table}
\centering
\sisetup{detect-all = true, table-space-text-post = \%}
\begin{tabular}{@{}
c
c
S[table-format = 2.0]
S[table-format = 2.2]
@{}}
\toprule
A & B & {C} & {D} \\ \midrule
1 & 24 & 12 & 50.00\% \\
2 & 22 & 4 & 18.18\% \\
3 & 85 & 45 & 52.94\% \\ \midrule
\emph{Total} & \itshape 131 & \itshape 61 & \itshape 46.57\% \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
I guess I am missing something important here. However, this table (in particular column C and D) does not look right. The numbers in column C are shifted to the left. In addition, the percentage sign is still to close to the right column border. Any suggestions? (Sorry for the detailed and stupid-sounding questions. However, this table starts to steal my sanity.)


\itshapevs\bfseriesis the only real difference) – Joseph Wright Sep 25 '16 at 10:20\usepackage{etoolbox} \robustify\itshape. However, this did not change anything. Maybe I did not really understand the solution given in the link you just posted. – phx Sep 25 '16 at 10:24siunitxto detect shape (the standard settings force upright): I'd probablydetect-allhere. – Joseph Wright Sep 25 '16 at 10:25detect-alland later alsodetect-weight=trueanddetect-inline-weight=mathto my\sisetup. Still no changes... – phx Sep 25 '16 at 10:29table-space-text-post = \%global, i.e., apply to columns C and D. Make it apply only column D. – Mico Sep 25 '16 at 12:25