代码之家  ›  专栏  ›  技术社区  ›  Erik B

桌子太宽了。如何使之合身?

  •  15
  • Erik B  · 技术社区  · 16 年前

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

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

    2 回复  |  直到 9 年前
        1
  •  38
  •   n00begon Priidu Neemre    13 年前

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

    tabular* 环境来指定整个表的宽度。

        2
  •  22
  •   shawon    8 年前

    您必须在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
  •  3
  •   Ashutosh Singla    6 年前

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