我已经查看了这里的很多帖子,但似乎所有帖子都破坏了我的表格,所以我想我应该发布我的问题并寻求帮助。我使用https://www.tablesgenerator.com
我在不缩小文本的情况下将表格调整到页面宽度时遇到了问题:
\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
\tabcolsep
以下是使用较小或缩写的列标题的另外两种可能的解决方案:
\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
表格中的列太多,无法以其正常大小容纳在可用的文本宽度中,但\resizebox
您可以手动选择较小的字体大小,而不是使用,例如\small
,这将为您提供更适合字体大小的字母形状。
此外,您可以通过缩写标题中的某些长单词来节省一些空间。
\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}