# Aligning combination of numbers and parentheses in siunitx table

I have this table and would like to align the columns by the parentheses. Note that I want to have both the number and the percentages (in parentheses) in one column.

Input

\documentclass[12pt]{report}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
\begin{table}[]
\centering
\sisetup{
}
\caption{My caption}
\begin{tabular}{@{}S@{}}
\toprule
No \\ \midrule
55 (11\%) \\
47 (9\%) \\
1 (3\%) \\
1115 (22\%) \\
36 (7\%) \\
435 (9\%) \\
123 (25\%) \\
1438 (29\%) \\ \bottomrule
\end{tabular}
\end{table}
\end{document}


Output

I know the siunitx package is useful for aligning in tables, but I don't know what to use as the input in \sisetup{}.

Maybe something like this:

\documentclass[12pt]{report}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
\begin{table}
\centering
\sisetup{
table-figures-integer = 4                      ,
table-figures-decimal = 0                      ,
table-space-text-post = {~(\SI{99}{\percent})} ,
table-number-alignment = center
}
\def\x#1{~(\SI{#1}{\percent})}
\caption{My Caption}
\begin{tabular}{@{}S@{}}
\toprule
{No}        \\ \midrule
55   \x{11} \\
47   \x9    \\
1    \x3    \\
1115 \x{22} \\
36   \x7    \\
435  \x9    \\
123  \x{25} \\
1438 \x{29} \\
\bottomrule
\end{tabular}
\end{table}
\end{document}


I do not know another solution but tweaking around with two columns. Is there a reasons why you do not want to use two?

% arara: pdflatex

\documentclass[12pt]{report}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{caption}

\begin{document}
\begin{table}
\centering
\caption{My caption}
\begin{tabular}{@{}S[table-format=4.0]@{\ }l@{}}
\toprule
\multicolumn{2}{c}{No} \\
\midrule
55 &(\SI{11}{\percent}) \\
47 &(\SI{9}{\percent}) \\
1 &(\SI{3}{\percent}) \\
1115 &(\SI{22}{\percent}) \\
36 &(\SI{7}{\percent}) \\
435 &(\SI{9}{\percent}) \\
123 &(\SI{25}{\percent}) \\
1438 &(\SI{29}{\percent}) \\
\bottomrule
\end{tabular}
\end{table}
\end{document}


This is quite easy, I think.

I have added the package caption which gets the vertical spacing right. I would leave away the @{} infront and after the columns, but this is a matter of taste.

The table still looks bad as the percentage numbers are not aligned correctly. I would prefer something of the following:

% arara: pdflatex

\documentclass[12pt]{report}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{caption}

\begin{document}
\begin{table}
\centering
\caption{My caption}
\begin{tabular}{S[table-format=4.0]S[table-format=2.0]}
\toprule
\multicolumn{2}{c}{No} \\
\cmidrule(lr){1-2}
{Number of votes} & {Corr. in \si{\percent}} \\
\midrule
55 & 11 \\
47 & 9 \\
1 & 3 \\
1115 & 22 \\
36 & 7 \\
435 & 9 \\
123 & 25 \\
1438 & 29 \\
\bottomrule
\end{tabular}
\end{table}
\begin{table}
\centering
\caption{Summary of people saying "No"}
\begin{tabular}{S[table-format=4.0]S[table-format=2.0]}
\toprule
{Number of votes} & {Corr. in \si{\percent}} \\
\midrule
55 & 11 \\
47 & 9 \\
1 & 3 \\
1115 & 22 \\
36 & 7 \\
435 & 9 \\
123 & 25 \\
1438 & 29 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}