【问题标题】:LaTeX table too wide. How to make it fit?LaTeX 表格太宽。如何使它合身?
【发布时间】:2011-02-17 04:34:31
【问题描述】:

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

\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 使表格适合页面?

【问题讨论】:

标签: latex tabular


【解决方案1】:

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

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

【讨论】:

  • 我是否必须为 p{} 设置一个固定大小,或者我可以告诉它使用剩余的空间吗?
  • @Erik:AFAIK 你需要一个固定的尺寸。
  • 对于tabular*,实现如下:\begin{tabular*}{\textwidth}{|r|}
  • 你能添加一个例子来展示这个吗?它似乎对我不起作用
【解决方案2】:

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

【讨论】:

  • 这会改变表格中的字体大小,很难阅读。
【解决方案3】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-27
    • 1970-01-01
    • 2011-04-10
    • 2021-12-26
    • 2011-02-16
    • 1970-01-01
    • 2013-05-06
    相关资源
    最近更新 更多