乳胶表太宽了。如何使它适合?

时间:2010-05-08 15:50:50

标签: latex tabular

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

\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}

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

3 个答案:

答案 0 :(得分:33)

使用p{width}列说明符:例如\begin{tabular}{ l p{10cm} }会将列的内容放入10cm宽的parbox中,文本将被正确分解为多行,就像普通段落一样。

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

答案 1 :(得分:5)

您必须在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}

答案 2 :(得分:0)

您也可以使用这些选项,或者使用\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}