![使用模板将表格调整到页面的一半](https://linux22.com/image/343435/%E4%BD%BF%E7%94%A8%E6%A8%A1%E6%9D%BF%E5%B0%86%E8%A1%A8%E6%A0%BC%E8%B0%83%E6%95%B4%E5%88%B0%E9%A1%B5%E9%9D%A2%E7%9A%84%E4%B8%80%E5%8D%8A.png)
下列的 适合其余纸张宽度的表格 我的问题,我使用 amcs 模板amcs模板 以及以下内容:
\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}
答案1
将表格的第一行替换为:
\begin{tabularx}{\columnwidth}{@{}c L S[table-format=7.0]*{2}{S[table-format=2.0]}@{}}
结果将会是这样的:
编辑: 使用以下方法可以获得稍微好一点的结果:
\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}
答案2
或者你可以像\resizebox
这样使用:
\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}