我有一张包含多列的表格,其中有一列是“序列号”。显然,这是宽度最小的列,但默认情况下,Latex 会为该列分配相对较大的宽度。因此,表格超出了页面列的宽度。
我怎样才能仅调整此列的宽度(保持其他列宽度不变)?
我正在上传代码和表格图像。
\begin{table}[h]
\centering
\begin{tabular}{|c |c |c |}
\hline
\textbf{Serial Number} & \textbf{Key} & \textbf{Value} \\[0.5ex]
\hline \hline
(1) & State/Province & Uttar Pradesh \\
\hline
(2) & Number of districts & 75 \\
\hline
(3) & Number of speakers & 1500 \\
\hline
(4) & Data content & names of crops, fruits markets \& districts; yes/no \\
\hline
(5) & Duration of an utterance & 3-5 seconds \\
\hline
(6) & Background enviroment & silent, noisy, extremely noisy \\
\hline
(7) & Speaker composition & male \& female (age group: 18-76 years) \\
\hline
(8) & Speaker-gender ratio & M:F = 4:1 \\
\hline
(9) & Other variations & different mobile brands, mobile/landline \\
\hline
\end{tabular}
\caption{Statistics of Data Collection Phase}
\label{table:1}
\end{table}
这是图片
问题仍然存在
答案1
即使你将标题字符串“序列号”拆分为两行(你应该做顺便说一下,除非允许在第 2 列和/或第 3 列中换行,否则表格可能仍然太宽而无法放入文本块中。对于手头的表格,允许在第 2 列中换行似乎不是一个好主意。但是,在第 3 列中换行似乎是可以的。因此,我建议您使用环境tabularx
和(修改后的)X
第 3 列的列类型,以允许根据需要进行换行。
我还建议您删除所有垂直线和大多数水平线,并不使用粗体用于标题文本。
\documentclass{article}
\usepackage{tabularx,booktabs}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newlength\mylen
\settowidth\mylen{Number} % store width of string "Number"
\begin{document}
\begin{table}
\begin{tabularx}{\textwidth}{@{} p{\mylen} l L @{}}
\toprule
Serial Number & Key & Value \\
\midrule
(1) & State/Province & Uttar Pradesh \\
(2) & Number of districts & 75 \\
(3) & Number of speakers & 1500 \\
(4) & Data content & names of crops, fruits markets and districts; yes/no \\
(5) & Duration of an utterance & 3--5 seconds \\
(6) & Background environment & silent, noisy, extremely noisy \\
(7) & Speaker composition & male \& female (age group: 18--76 years) \\
(8) & Speaker-gender ratio & M:F = 4:1 \\
(9) & Other variations & different mobile brands, mobile/landline \\
\bottomrule
\end{tabularx}
\caption{Statistics of Data Collection Phase}
\label{table:stats}
\end{table}
\end{document}
附录:原作者在评论中透露,他的文档采用双列布局。在这种情况下,可以使用全宽table*
环境(并将tabular
材料置于table*
环境的中心),也可以在第 2 列和第 3 列中允许换行。以下示例说明了这两种可能性。
\documentclass{IEEEconf} % example of a two-column document class
\usepackage{tabularx,booktabs,ragged2e,lipsum}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\newlength\mylen
\settowidth\mylen{Number} % find and store width of "Number" string
\begin{document}
\lipsum[1] % filler text
\begin{table*} % full-width environment
\centering
\begin{tabular}{@{} p{\mylen} ll @{}} % use two "l" columns, no line breaks needed
\toprule
Serial Number & Key & Value \\
\midrule
(1) & State/Province & Uttar Pradesh \\
(2) & Number of districts & 75 \\
(3) & Number of speakers & 1500 \\
(4) & Data content & names of crops, fruits markets \& districts; yes/no \\
(5) & Duration of an utterance & 3--5 seconds \\
(6) & Background environment & silent, noisy, extremely noisy \\
(7) & Speaker composition & male \& female (age group: 18--76 years) \\
(8) & Speaker-gender ratio & M:F = 4:1 \\
(9) & Other variations & different mobile brands, mobile\slash landline \\
\bottomrule
\end{tabular}
\caption{Statistics of Data Collection Phase}
\label{table:stats-wide}
\end{table*}
\lipsum[2-9] % more filler text
\begin{table} % column-width environment
\setlength\tabcolsep{3pt} % default value: 6pt
\begin{tabularx}{\columnwidth}{@{} p{\mylen} LL @{}} % use *two* "L" columns
\toprule
Serial Number & Key & Value \\
\midrule
(1) & State/Province & Uttar Pradesh \\
(2) & Number of districts & 75 \\
(3) & Number of speakers & 1500 \\
(4) & Data content & names of crops, fruits markets \& districts; yes/no \\
(5) & Duration of an utterance & 3--5 seconds \\
(6) & Background environment & silent, noisy, extremely noisy \\
(7) & Speaker composition & male \& female (age group: 18--76 years) \\
(8) & Speaker-gender ratio & M:F = 4:1 \\
(9) & Other variations & different mobile brands, mobile\slash land\-line \\
\bottomrule
\end{tabularx}
\caption{Statistics of Data Collection Phase}
\label{table:stats-narrow}
\end{table}
\lipsum[9-12] % still more filler text
\end{document}