1

This question already has an answer here:

I want to make the number and percentage in the last column well aligned to the right in every row. Separating them into two columns is the solution that worked for me because the number and percentage length is not fixed.

I have a very large other table (this is only a small sample) so please try to solve my problem with the way I use (multi columns to separate the number and percentage) without coming with completely new solutions as this way is used in many large tables.

The problem: in my method to achieve the right alignment I want, the space between the number and its percentage is large.

I want to reduce this space (see the red rectangle in the figure below).

enter image description here

The script in ACM conference template (2 columns template):

\documentclass[sigconf]{acmart}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{booktabs}
\usepackage{array, makecell} 
\usepackage[font={small}]{caption} 
\usepackage{multicol} 
\usepackage{multirow} 
\usepackage{adjustbox} 
\usepackage{paralist}
\usepackage{mathptmx} 
\usepackage[compact]{titlesec}
\usepackage{sistyle} 
\SIthousandsep{,} 
\pagestyle{plain}

\begin{document}

\title{Title}

\begin{abstract}
Abstract
\end{abstract}

\maketitle
\section{Sample}

\begin{table}[!tp]
    \centering
    \caption{Results}
    \label{tab:results} 
    \begin{adjustbox}{max width=\columnwidth}
        \begin{tabular}{llllrr}
            \toprule
            \thead{Col 1}& \thead{Col 2} & \thead{Col3} &\thead{Col 4} & \multicolumn{2}{r}{\thead{Col 5}} \\
            \midrule
            \multirow{4}{*}{\texttt{program 1}}&
            \multirow{2}{*}{\texttt{dataset 1}} & \multirow{2}{*}{\num{\#\#\#\#\#\#}} 
            & type 1 & \num{\#\#\#\#\#}&(\#\#.\#\%)\\
            \cline{4-6}
            & & & type 2  & \num{\#\#\#\#} & (\#\#.\#\#\%)\\ 
            \cline{2-6}

            & \multirow{2}{*}{\texttt{dataset 2}} & \multirow{2}{*}{\num{\#\#\#\#}}    
            & type 1 & \num{\#\#\#\#}&(\#.\#\%)\\
            \cline{4-6}
            & & & type 2  & \num{\#\#\#}& (\#\#\.\#\%) \\

            \midrule
            \multirow{4}{*}{\texttt{program 2}}&
            \multirow{2}{*}{\texttt{dataset 1}} & \multirow{2}{*}{\num{\#\#\#}} 
            & type 1 & \num{\#\#\#}& (\#.\#\%)\\
            \cline{4-6}
            & & & type 2  & \num{\#\#\#}& (\#.\#\%)\\ 
            \cline{2-6}

            & \multirow{2}{*}{\texttt{dataset 2}} & \multirow{2}{*}{\num{\#\#\#}}      
            &type 1 & \num{\#\#} & (\#.\#\%)\\
            \cline{4-6}
            & & & type 2  & \num{\#\#\#\#} & (\#\#\.\#\%) \\
            \bottomrule
        \end{tabular}
    \end{adjustbox}
\end{table}

\end{document}

EDIT:

Please note, I just want to reduce the spaces between columns in the last column (which is a multicolumn) (Col 5 in the provided figure).

marked as duplicate by Raaja, Stefan Pinnow, barbara beeton, JouleV, user36296 Mar 26 at 17:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

You can simply add @{} between columns in the table declaration to reduce the space between them to 0. Alternatively you can specify a certain non-zero distance with @{\hspace{2pt}} (you can put whatever you wish instead of 2pt: 1cm, 5em,...).

So in your example: \begin{tabular}{llllr@{\hspace{2pt}}r}

enter image description here

\documentclass[sigconf]{acmart}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{booktabs}
\usepackage{array, makecell} 
\usepackage[font={small}]{caption} 
\usepackage{multicol} 
\usepackage{multirow} 
\usepackage{adjustbox} 
\usepackage{paralist}
\usepackage{mathptmx} 
\usepackage[compact]{titlesec}
\usepackage{sistyle} 
\SIthousandsep{,} 
\pagestyle{plain}

\begin{document}

\title{Title}

\begin{abstract}
Abstract
\end{abstract}

\maketitle
\section{Sample}

\begin{table}[!tp]
    \centering
    \caption{Results}
    \label{tab:results} 
    \begin{adjustbox}{max width=\columnwidth}
        \begin{tabular}{llllr@{\hspace{2pt}}r}
            \toprule
            \thead{Col 1}& \thead{Col 2} & \thead{Col3} &\thead{Col 4} & \multicolumn{2}{r}{\thead{Col 5}} \\
            \midrule
            \multirow{4}{*}{\texttt{program 1}}&
            \multirow{2}{*}{\texttt{dataset 1}} & \multirow{2}{*}{\num{\#\#\#\#\#\#}} 
            & type 1 & \num{\#\#\#\#\#}&(\#\#.\#\%)\\
            \cline{4-6}
            & & & type 2  & \num{\#\#\#\#} & (\#\#.\#\#\%)\\ 
            \cline{2-6}

            & \multirow{2}{*}{\texttt{dataset 2}} & \multirow{2}{*}{\num{\#\#\#\#}}    
            & type 1 & \num{\#\#\#\#}&(\#.\#\%)\\
            \cline{4-6}
            & & & type 2  & \num{\#\#\#}& (\#\#\.\#\%) \\

            \midrule
            \multirow{4}{*}{\texttt{program 2}}&
            \multirow{2}{*}{\texttt{dataset 1}} & \multirow{2}{*}{\num{\#\#\#}} 
            & type 1 & \num{\#\#\#}& (\#.\#\%)\\
            \cline{4-6}
            & & & type 2  & \num{\#\#\#}& (\#.\#\%)\\ 
            \cline{2-6}

            & \multirow{2}{*}{\texttt{dataset 2}} & \multirow{2}{*}{\num{\#\#\#}}      
            &type 1 & \num{\#\#} & (\#.\#\%)\\
            \cline{4-6}
            & & & type 2  & \num{\#\#\#\#} & (\#\#\.\#\%) \\
            \bottomrule
        \end{tabular}
    \end{adjustbox}
\end{table}

\end{document}

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