2

Following Table to fit the rest of the paper width my question, I use the amcs template amcs template and the following:

\documentclass{amcs}
\usepackage{booktabs,makecell,tabularx}
\renewcommand\theadfont{\small}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{siunitx}
%\documentclass{article}
\usepackage{adjustbox}
\usepackage{array,booktabs}

\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\documentclass{article}
    \usepackage{booktabs,makecell,tabularx}
    \renewcommand\theadfont{\small}
    \newcolumntype{L}{>{\raggedright\arraybackslash}X}
    \usepackage{siunitx}

\begin{document}
    \begin{table}[H]
    \centering
    \setlength{\tabcolsep}{1pt}
    \small
    \begin{tabularx}{\textwidth}{c L S[table-format=0.1]*{2}{S[table-format=0.1]}}
        \toprule
        \thead{ID}  &   \thead{UCI Dataset Name} 
        &   {\thead{Samples\\(number)}}
        &   {\thead{Attributes\\(number)}} 
        &   {\thead{Classes\\(number)}}           \\
        \midrule
        DS1 & Poker Hand                          & 1025010  & 11    & 9     \\
        DS2 & SUSY                                & 5000000  & 18    & 2     \\
        DS3 & Record Linkage Comparison  Patterns & 5749132  & 9     & 2     \\
        DS4 & KDD Cup 1999                        & 4898431  & 42    & 23    \\
        \bottomrule
    \end{tabularx}
    \caption{Datasets used for empirical evaluation}
    \label{table:1}
\end{table} 
 \end{document}

This is the result I get: enter image description here I need it to be in one column of the page. It is supposed to match into one column to the amcs format, like this:enter image description here How can I adjust the table to fit into one page column?

2 Answers 2

4

Replace first row of your table with:

\begin{tabularx}{\columnwidth}{@{}c L S[table-format=7.0]*{2}{S[table-format=2.0]}@{}}

Result will be something like this:

enter image description here

Edit: Slightly better result you will obtain with:

\begin{table}[htb]
\centering
\setlength{\tabcolsep}{2pt}
\small
\begin{tabularx}{\columnwidth}{@{}c L S[table-format=7.0]*{2}{S[table-format=2.0]}@{}}
    \toprule
    \thead{ID}  &   \thead{UCI Dataset Name}
    &   {\thead{Samples\\(num.)}}
    &   {\thead{Attributes\\(num.)}}
    &   {\thead{Classes\\(num.)}}           \\
    \midrule
    DS1 & Poker Hand                          & 1025010  & 11    & 9     \\
    DS2 & SUSY                                & 5000000  & 18    & 2     \\
    DS3 & Record Linkage Comparison  Patterns & 5749132  & 9     & 2     \\
    DS4 & KDD Cup 1999                        & 4898431  & 42    & 23    \\
    \bottomrule
\end{tabularx}
\caption{Datasets used for empirical evaluation}
\label{table:1}
\end{table}

enter image description here

-1

Or you can just use \resizebox like this:

\begin{table}[htb]
  \resizebox{\columnwidth}{!}{
    \begin{tabular}{|c|c|c|c|}
    column1 & column2 & column3 & column4 \\
    \hline
    data1 & data2 & data3 & data4 \\
    \hline 
    \end{tabular}
  }
\end{table}

Found it here: https://tex.stackexchange.com/a/595900/244690

3
  • Welcome to TeX.SE! Please make your code snippet be compilable for a fast proof ...
    – Mensch
    Commented Aug 19, 2022 at 16:53
  • BTW, it is very wise to avoid using \resizebox when writing tables. It lead to inconsistent font size in table ...
    – Zarko
    Commented Aug 19, 2022 at 17:53
  • Noted. Thank you so much. I am new to latex.
    – smmehrab
    Commented Aug 19, 2022 at 18:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .