1

I have reviewed quite a few posts on here, yet everything seems to be breaking my table, so I figured I'd just post my probem and ask for help. I generated a table using https://www.tablesgenerator.com

I am having issues fitting my table to the width of the page without shrinking the text:

\documentclass[acmsmall]{acmart}
 \usepackage{graphicx}
   \usepackage[table,xcdraw]{xcolor}
      \begin{table}[]
        \resizebox{\textwidth}{!}{%
        \begin{tabular}{lcccccccccccc}
        \hline
        \rowcolor[HTML]{EFEFEF} 
        \multicolumn{13}{c}{\cellcolor[HTML]{EFEFEF}\textbf{Title}} \\ \hline
        \textit{\textbf{Hashtag}} & \multicolumn{3}{c}
        {\textit{\textbf{Service1}}} & \multicolumn{3}{c}
        {\textit{\textbf{Service2}}} & \multicolumn{3}{c}
        {\textit{\textbf{Service3}}} & \multicolumn{3}{c}
        {\textit{\textbf{Service4}}} \\ \hline
        \rowcolor[HTML]{EFEFEF} 
          \textit{} & \textit{True} & \textit{False} & \textit{Accuracy} & 
          \textit{True} & \textit{False} & \textit{Accuracy} & \textit{True} & 
          \textit{False} & \textit{Accuracy} & \textit{True} & \textit{False} & 
          \textit{Accuracy} \\ \hline
          \textit{\#1} & n & n & n\% & x & x & x & n & n & n\% & n & 
           n & n\% \\ \hline
        \rowcolor[HTML]{EFEFEF} 
          \textit{\#2} & n & n & n\% & x & x & x & n & n & n\% & n & 
           n & n\% \\ \hline
          \textit{\#3} & n & n & n\% & x & x & x & n & n & n\% & n & 
           n & n\% \\ \hline
        \rowcolor[HTML]{EFEFEF} 
          \textit{\#4} & n & n & n\% & x & x & x & n& 100 & n\% & n
          & n & n\% \\ \hline
          \begin{tabular}[c]{@{}l@{}}\#5, \\ \#6, \\ \#7\end{tabular} & n & n & 
          n\% & n & n & n\% & n & n & n\% & n & n & n\% \\ \hline
      \end{tabular}%
      }
 \end{table}
1
  • Welcome to TeX.SE. It would be helpful if you composed a fully compilable minimal working example (MWE) including \documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem. Mar 13, 2019 at 22:14

2 Answers 2

3

Here are two more possible solutions using a smaller \tabcolsep or abbreviated column headers:

enter image description here

\documentclass[acmsmall]{acmart}
\usepackage{graphicx}
\usepackage{colortbl}

\begin{document}

      \begin{table}
      \setlength{\tabcolsep}{4pt}
        \begin{tabular}{lcccccccccccc}
        \hline
        \rowcolor[HTML]{EFEFEF} 
        \multicolumn{13}{c}{\cellcolor[HTML]{EFEFEF}\textbf{Title}} \\ \hline
        \textit{\textbf{Hashtag}} & \multicolumn{3}{c}
        {\textit{\textbf{Service1}}} & \multicolumn{3}{c}
        {\textit{\textbf{Service2}}} & \multicolumn{3}{c}
        {\textit{\textbf{Service3}}} & \multicolumn{3}{c}
        {\textit{\textbf{Service4}}} \\ \hline
        \rowcolor[HTML]{EFEFEF} 
          \textit{} & \textit{True} & \textit{False} & \textit{Acc.} & 
          \textit{True} & \textit{False} & \textit{Acc.} & \textit{True} & 
          \textit{False} & \textit{Accuracy} & \textit{True} & \textit{False} & 
          \textit{Acc.} \\ \hline
          \textit{\#1} & n & n & n\% & x & x & x & n & n & n\% & n & 
           n & n\% \\ \hline
        \rowcolor[HTML]{EFEFEF} 
          \textit{\#2} & n & n & n\% & x & x & x & n & n & n\% & n & 
           n & n\% \\ \hline
          \textit{\#3} & n & n & n\% & x & x & x & n & n & n\% & n & 
           n & n\% \\ \hline
        \rowcolor[HTML]{EFEFEF} 
          \textit{\#4} & n & n & n\% & x & x & x & n& 100 & n\% & n
          & n & n\% \\ \hline
        \#5  &&&&&&&&&&&&\\                   
        \#6, & n & n & 
          n\% & n & n & n\% & n & n & n\% & n & n & n\% \\ 
        \#7  &&&&&&&&&&&&\\   
          \hline
          \end{tabular}
 \end{table}


      \begin{table}
        \begin{tabular}{lcccccccccccc}
        \hline
        \rowcolor[HTML]{EFEFEF} 
        \multicolumn{13}{c}{\cellcolor[HTML]{EFEFEF}\textbf{Title}} \\ \hline
        \textit{\textbf{Hashtag}} & \multicolumn{3}{c}
        {\textit{\textbf{Service1}}} & \multicolumn{3}{c}
        {\textit{\textbf{Service2}}} & \multicolumn{3}{c}
        {\textit{\textbf{Service3}}} & \multicolumn{3}{c}
        {\textit{\textbf{Service4}}} \\ \hline
        \rowcolor[HTML]{EFEFEF} 
          \textit{} & \textit{T} & \textit{F} & \textit{Acc.} & 
          \textit{T} & \textit{F} & \textit{Acc.} & \textit{T} & 
          \textit{F} & \textit{Acc.} & \textit{T} & \textit{F} & 
          \textit{Acc.} \\ \hline
          \textit{\#1} & n & n & n\% & x & x & x & n & n & n\% & n & 
           n & n\% \\ \hline
        \rowcolor[HTML]{EFEFEF} 
          \textit{\#2} & n & n & n\% & x & x & x & n & n & n\% & n & 
           n & n\% \\ \hline
          \textit{\#3} & n & n & n\% & x & x & x & n & n & n\% & n & 
           n & n\% \\ \hline
        \rowcolor[HTML]{EFEFEF} 
          \textit{\#4} & n & n & n\% & x & x & x & n& 100 & n\% & n
          & n & n\% \\ \hline
          \begin{tabular}[c]{@{}l@{}}\#5, \\ \#6, \\ \#7\end{tabular} & n & n & 
          n\% & n & n & n\% & n & n & n\% & n & n & n\% \\ \hline
          \multicolumn{13}{l}{T: True, F: False, Acc.: Accuracy}
      \end{tabular}%
 \end{table}

\end{document}
2

The table has too many columns to fit in the available text width at its normal size, but instead of using \resizebox you could manually select a smaller font size, e.g. \small, this will give you more appropriate letter shapes for the font size.

In addition you could safe some space by abbreviating some of the long words in the header.

\PassOptionsToPackage{table,xcdraw}{xcolor}
\PassOptionsToPackage{showframe}{geometry}
\documentclass[acmsmall]{acmart}
 \usepackage{graphicx}


%   \usepackage[table,xcdraw]{xcolor}

\begin{document}

      \begin{table}[]
%        \resizebox{\textwidth}{!}{%
\small
        \begin{tabular}{lcccccccccccc}
        \hline
        \rowcolor[HTML]{EFEFEF} 
        \multicolumn{13}{c}{\cellcolor[HTML]{EFEFEF}\textbf{Title}} \\ \hline
        \textit{\textbf{Hashtag}} & \multicolumn{3}{c}
        {\textit{\textbf{Service1}}} & \multicolumn{3}{c}
        {\textit{\textbf{Service2}}} & \multicolumn{3}{c}
        {\textit{\textbf{Service3}}} & \multicolumn{3}{c}
        {\textit{\textbf{Service4}}} \\ \hline
        \rowcolor[HTML]{EFEFEF} 
          \textit{} & \textit{True} & \textit{False} & \textit{Acc.} & 
          \textit{True} & \textit{False} & \textit{Acc.} & \textit{True} & 
          \textit{False} & \textit{Accuracy} & \textit{True} & \textit{False} & 
          \textit{Acc.} \\ \hline
          \textit{\#1} & n & n & n\% & x & x & x & n & n & n\% & n & 
           n & n\% \\ \hline
        \rowcolor[HTML]{EFEFEF} 
          \textit{\#2} & n & n & n\% & x & x & x & n & n & n\% & n & 
           n & n\% \\ \hline
          \textit{\#3} & n & n & n\% & x & x & x & n & n & n\% & n & 
           n & n\% \\ \hline
        \rowcolor[HTML]{EFEFEF} 
          \textit{\#4} & n & n & n\% & x & x & x & n& 100 & n\% & n
          & n & n\% \\ \hline
        \#5  &&&&&&&&&&&&\\                   
        \#6, & n & n & 
          n\% & n & n & n\% & n & n & n\% & n & n & n\% \\ 
        \#7  &&&&&&&&&&&&\\   
          \hline
      \end{tabular}%
%      }
 \end{table}

 \end{document}

You must log in to answer this question.

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