2

I have the table shown below. Due to the fact that the titles in Rown#2 are long, the numbers and their percentages become so distant from each other and made the table unreadable.

enter image description here

Q: How to reduced the space between the columns which contains numbers and percentage so the distance becomes reasonable and the number and its percentage become close to each other.

I have a shorter titles in another table and the problem did not arise and it looks good to me. I would like my big table above to look like this in terms of columns spaces between the number and its percentage.

enter image description here

Note that I need to separate the number from its percentage because of alignment issue that could not be solved otherwise.

Here is the sample script:

\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{Table}
    \begin{tabular}{lrrrrrr}
        \toprule
        & \multicolumn{6}{c}{\thead{Title}} \\
        \cline{2-7}
        & \multicolumn{2}{r}{\texttt{Col\#1 title starts here}} & \multicolumn{2}{r}{\texttt{Col\#2 title starts here}}     & \multicolumn{2}{r}{\texttt{Col\#3 title starts here}} \\
        \midrule
        Title \#1               
        & \multicolumn{2}{r}{\num{44444}} & \multicolumn{2}{r}{\num{222222}} & \multicolumn{2}{r}{\num{1111111}} \\
        \midrule 
        \quad Title\#2 is Here      
        & \num{44444}&(99.99\%) & \num{222222}&(99.99\%) & \num{1111111}&(99.99\%) \\
        \midrule            
        \quad \quad Title\#3 is Here (brackets)     
        & \num{44444}&(99.99\%)   & \num{222222}&(99.99\%)  & \num{1111111}&(99.99\%)\\
        \quad \quad \quad Title \#4 is Here      
        & \num{33333}&(77.77\%)  & \num{666666}&(22.22\%)   & \num{1111111}&(111\%) \\
        \quad \quad \quad \quad \% Title\#4 is Here 
        & \num{77}&(2.22\%)      & \num{361}&(0.59\%)       & \num{444444}&(33.33\%) \\
        \bottomrule
    \end{tabular}
    \vspace{-10pt}
\end{table}

\end{document}
4

You need to allow line breaks. One way to do so is to employ a tabularx environment.

enter image description here

\documentclass[10pt]{llncs}
\usepackage{sistyle} 
\SIthousandsep{,} 
\usepackage{booktabs} 
\usepackage{tabularx, ragged2e, makecell} 
\newcolumntype{R}{>{\RaggedLeft\arraybackslash}X}
\newcolumntype{C}{>{\Centering\arraybackslash}X}
\newcommand\myhsize{\dimexpr2\hsize+2\tabcolsep\relax}
\begin{document}

\begin{table}[!th]
\setlength\tabcolsep{2pt} % default: 6pt
\caption{Table}
\begin{tabularx}{\textwidth}{@{} l *{6}{R} @{}}
\toprule
& \multicolumn{6}{c@{}}{Title} \\
\cmidrule(l){2-7}
& \multicolumn{2}{>{\hsize=\myhsize}C}{\texttt{Col\#1 title starts here}} 
& \multicolumn{2}{>{\hsize=\myhsize}C}{\texttt{Col\#2 title starts here}}     
& \multicolumn{2}{>{\hsize=\myhsize}C@{}}{\texttt{Col\#3 title starts here}}\\
\midrule
Title \#1               
& \multicolumn{2}{r}{\num{44444}} 
& \multicolumn{2}{r}{\num{222222}} 
& \multicolumn{2}{r@{}}{\num{1111111}} \\
\midrule 
\quad Title\#2 here      
    & \num{44444}   & (99.99\%) 
    & \num{222222}  & (99.99\%) 
    & \num{1111111} & (99.99\%) \\
\midrule            
\qquad Title\#3 here      
    & \num{44444}   & (99.99\%)   
    & \num{222222}  & (99.99\%)  
    & \num{1111111} & (99.99\%)\\
\qquad\quad Title \#4 here      
    & \num{33333}   &  (77.77\%)  
    & \num{666666}  &  (22.22\%)   
    & \num{1111111} & (111\%)\\
\qquad\qquad Title\#5 here 
    & \num{77}      &  (2.22\%)
    & \num{361}     &  (0.59\%)
    & \num{444444}  & (33.33\%)\\
\bottomrule
\end{tabularx}
\end{table}

\end{document}
  • I see you made the first column just wide enough to make the other columns look minimal. – John Kormylo Feb 23 at 15:39
  • @JohnKormylo - Yeah, that's pretty much what I did. :-) Since the OP's real table will presumably not feature the numbers 44444, 222222, 1111111, etc, I didn't think it made much sense coming up with a more refined solution for these sample numbers. – Mico Feb 23 at 16:33

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.