多列仅使用第一列的宽度

多列仅使用第一列的宽度

我正在使用multicolumn命令覆盖表格中的四列,但出于某种原因,列中的文本在单个列宽内换行,而列的其余部分为空。我可以看到列仍然是我想要的宽度,因为单元格的右侧支柱位于它应该在的位置。我认为这可能与我对环境的使用有关tabularx,但我需要它来允许表格移动以适应不同的可能单元格值。

\documentclass{article}
\usepackage{fullpage}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{graphicx}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[none]{hyphenat}
\usepackage{array}
\usepackage{bigstrut}
\begin{document}
\begin{center}
\begin{tabularx}{\textwidth}{|l|X|X|X|X|X|}
\hline
\textbf{Meeting Date:} & 2009/08/01 & \textbf{Type:} & Party & \textbf{Today's date:} & 2014/01/14 \bigstrut \tabularnewline 
\hline
\textbf{Meeting Location:} & \multicolumn{4}{X|}{This is the long string of text that I would like to break but when it has filled four columns rather than one.} & \bigstrut \tabularnewline
\hline 
\textbf{Current Weather:} & \multicolumn{5}{l|}{Cloudy and sunny} \bigstrut \tabularnewline
\hline 
\textbf{Sector:} & \multicolumn{5}{l|}{Food and Produce} \bigstrut \tabularnewline
\hline 
\end{tabularx}
\end{center}
\end{document}

答案1

文档tabularx明确指出:

不要使用\multicolumn跨越任何X列的条目。

您可以替换

\multicolumn{4}{X|}{This is the long string...}

\multicolumn{4}{p{4in}|}{This is the long string...}

完整代码:

\documentclass{article}
\usepackage{fullpage}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{graphicx}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[none]{hyphenat}
\usepackage{array}
\usepackage{bigstrut}
\begin{document}
\begin{center}
\begin{tabularx}{\textwidth}{|l|X|X|X|X|X|}
\hline
\textbf{Meeting Date:} & 2009/08/01 & \textbf{Type:} & Party & \textbf{Today's date:} & 2014/01/14 \bigstrut \tabularnewline
\hline
\textbf{Meeting Location:} & \multicolumn{4}{p{4in}|}{This is the long string of text that I would like to break but when it has filled four columns rather than one.} & \bigstrut \tabularnewline
\hline
\textbf{Current Weather:} & \multicolumn{5}{l|}{Cloudy and sunny} \bigstrut \tabularnewline
\hline
\textbf{Sector:} & \multicolumn{5}{l|}{Food and Produce} \bigstrut \tabularnewline
\hline
\end{tabularx}
\end{center}
\end{document} 

输出:

在此处输入图片描述

相关内容