42

我刚开始学习乳胶,现在我正在尝试创建一个表格。这是我的代码:

\begin{table}
\caption{Top Scorers}
\begin{tabular}{ l l }
    \hline
    \bf Goals & \bf Players\\
    \hline
    4 & First Last, First Last, First Last, First Last\\
    3 & First Last\\
    2 & First Last\\
    1 & First Last, First Last, First Last, First Last, First Last, First Last, First Last, First Last, First Last, First Last, First Last, First Last, First Last\\
    \hline
\end{tabular}
\end{table}

问题是表格比页面宽。我希望它会像普通文本一样自动适应页面,但事实并非如此。我如何告诉乳胶使表格适合页面?

4

3 回答 3

42

使用p{width}列说明符:例如\begin{tabular}{ l p{10cm} }将列的内容放入 10 厘米宽的 parbox 中,文本将正确地分成几行,就像在正常段落中一样。

您还可以使用tabular*环境来指定整个表格的宽度。

于 2010-05-08T15:59:57.220 回答
27

您必须在 resizebox 下取整列。这段代码对我有用

\begin{table}[htbp]
\caption{Sample Table.}\label{tab1}
\resizebox{\columnwidth}{!}{\begin{tabular}{|l|l|l|l|l|}
\hline
URL &  First Time Visit & Last Time Visit & URL Counts & Value\\
\hline
https://web.facebook.com/ & 1521241972 & 1522351859 & 177 & 56640\\
http://localhost/phpmyadmin/ & 1518413861 & 1522075694 & 24 & 39312\\
https://mail.google.com/mail/u/ & 1516596003 & 1522352010 & 36 & 33264\\
https://github.com/shawon100& 1517215489 & 1522352266 & 37 & 27528\\
https://www.youtube.com/ & 1517229227 & 1521978502 & 24 & 14792\\
\hline
\end{tabular}}
\end{table}
于 2018-05-09T10:38:53.750 回答
4

您也可以使用这些选项,使用\footnotesize\tiny。这真的有助于安装大桌子。

\begin{table}[htbp]
\footnotesize
\caption{Information on making the table size small}
\label{table:table1}
\begin{tabular}{ll}
    \toprule
    S.No       & HMD           \\
    \midrule
    1          & HTC Vive \\
    2          & HTC Vive Pro   \\
    \bottomrule
\end{tabular}
\end{table}
于 2020-08-26T10:14:18.537 回答