3

I have a table which contains numbers and their percentages. Because the numbers and percentages length is different, they become unaligned. The following figure illustrates:

enter image description here

As shown in the table, I want the numbers to be aligned. Note that this table is much smaller just to show the problem than the actual table.

The script is:

\documentclass[10pt]{llncs}
\usepackage{graphicx}
\usepackage{sistyle} 
\SIthousandsep{,} 
\usepackage{booktabs} 
\usepackage{array, makecell} 
\usepackage{adjustbox} 

\begin{document}
\title{Test}
\maketitle

\begin{table*}[!tp]
    \centering
    \caption{Summary}
    \label{tab:inspection}
    \begin{adjustbox}{max width=\textwidth}
        \begin{tabular}{lrrr}
            \toprule
            & \multicolumn{3}{c}{\thead{Row}} \\
            \cline{2-4}
            & \texttt{Col \#1} & \texttt{Col \#2}   & \texttt{Col \#3} \\
            \midrule
            Feature \#1             
            & \num{55555}              & \num{222222}           & \num{1111111} \\
            \midrule 
            \quad Feature \#2       
            & \num{44444} (22.11\%)    & \num{222222} (11.11\%) & \num{1111111} (44.44\%) \\
            \midrule            
            \quad \quad Feature \#3     
            & \num{44444} (55.55\%)    & \num{222222} (33.33\%) & \num{1111111} (22.22\%)\\
            \quad \quad \quad Feature \#4      
            & \num{33333} (55.55\%)    & \num{66666} (22.22\%)  & \num{1111111} (100\%) \\
            \bottomrule
        \end{tabular}
    \end{adjustbox}
    \vspace{-10pt}
\end{table*}


\end{document} 
  • Use the l column type, not r. – Bernard Feb 23 at 9:50
  • 1
    siunitx or dcolumn packages provide numeric columns that will align, also don't scale tables!!! ` \begin{adjustbox}{max width=\textwidth}` – David Carlisle Feb 23 at 9:51
  • @Bernard I need right alignment as I want to show the number category (thousands, hundreds, tens). I do not want left alignment. – user9371654 Feb 23 at 9:57
  • @David Carlisle Plz can you clarify. How to use the packages you noted? Will they do? – user9371654 Feb 23 at 9:57
  • In this case, how can they start from the same point? – Bernard Feb 23 at 9:59
3

Here is an example using the siunitx package. I have split up the numbers and the corresponding percent values into two columns. (Since I did not have the documentclass you used, I replaced it with article).

enter image description here

\documentclass[10pt]{article}
\usepackage{geometry}

\usepackage{siunitx} 
\sisetup{group-separator = {,}}
\usepackage{booktabs} 


\begin{document}

\begin{table*}[!tp]
    \centering
    \caption{Summary}
    \label{tab:inspection}
        \begin{tabular}{l
                        S[table-format=5]
                        r
                        S[table-format=6]
                        r
                        S[table-format=7]
                        r}
            \toprule
            & \multicolumn{6}{c}{Row} \\
            \cmidrule{2-7}
            & \multicolumn{2}{c}{\texttt{Col \#1}} & \multicolumn{2}{c}{\texttt{Col \#2}}   & \multicolumn{2}{c}{\texttt{Col \#3}} \\
            \midrule
            Feature \#1             
            & 55555&              & 222222  &         & 1111111 \\
            \midrule 
            \quad Feature \#2       
            & 44444& (22.11\%)    & 222222 &(11.11\%) &1111111& (44.44\%) \\
            \midrule            
            \quad \quad Feature \#3     
            & 44444 &(55.55\%)    & 222222 &(33.33\%) & 1111111& (22.22\%)\\
            \quad \quad \quad Feature \#4      
            & 33333& (55.55\%)    & 66666& (22.22\%)  & 1111111 &(100\%) \\
            \bottomrule
        \end{tabular}
\end{table*}


\end{document} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.