带多列的乳胶表格文字包装-保持间距的方法?

时间:2019-03-26 16:22:59

标签: latex

我正在尝试固定列长,但是在表中使用multicolumn命令。当我使用多列时,它似乎覆盖了列间距。

我尝试使用这些答案Wrong column spacing due to multicolumn in latex,但这是我要寻找的更具体的答案。寻找更一般的答案。某些软件包可以做到这一点(即tabularx),但正在寻找一种“基本”的方式来做到这一点。

\begin{table}[]
\centering
\begin{tabular}{|p{1cm}|p{1cm}|p{3cm}|}
\hline 
\multicolumn{2}{c}{Test Test Test Test Test Test Test Test} & \multicolumn{1}{c}{Test} \\
Test & Test & Test \\
\hline 
     5555 & 5555 & 5555\\
     5555 & 5555 & 5555 \\
     \multicolumn{2}{c}{5555} & 5555 \\
     \hline 
\end{tabular}
\caption{Caption}
\label{tab:my_label}
\end{table}

在表格中使用多列时,我试图使第1列和第2列的宽度为1cm,第3列的宽​​度为cm。任何提示或帮助,将不胜感激。

1 个答案:

答案 0 :(得分:1)

您可以使用\parbox{width}{text}来限制多列单元格的宽度。

\documentclass[11pt]{article}
\begin{document}
\begin{table}[]
  \centering
  \begin{tabular}{|p{1cm}|p{1cm}|p{3cm}|}
    \hline 
    \multicolumn{2}{|c|}{\parbox{2cm}{Test Test Test Test Test Test Test Test}} & \multicolumn{1}{c|}{Test} \\
    Test & Test & Test \\
    \hline 
    5555 & 5555 & 5555\\
    5555 & 5555 & 5555 \\
    \multicolumn{2}{|c}{5555} & 5555 \\
    \hline 
  \end{tabular}
  \caption{Caption}
  \label{tab:my_label}
\end{table}
\end{document}