我正在寻找制作相同的表但使用环境tabularx
而不是tabular
。
无论单元格的内容是什么,它们都应具有相同的宽度 (50% 50%)。
这是我的尝试:
\documentclass[a4paper]{report}
\usepackage{multirow}
\usepackage{array}
\usepackage{tabularx}
\begin{document}
\begin{table}[h]
\begin{center}
\renewcommand{\arraystretch}{2}
\begin{tabularx}{\textwidth}{|X|X|X|X|X|}
\hline
\multirow{2}{1cm}{longlonglong line long} & \multirow{2}{3,5cm}{longlong text} & \multirow{2}{3cm}{a very longgggggggg line here} & \multicolumn{2}{c|}{A very longlong long line here longgggg}\\
\cline{4-5}
& & & should be equal 50\% & should be equal 50\%\\
\hline
\end{tabularx}
\end{center}
\end{table}
\end{document}
答案1
我用 拆分了两个太长的列\\
。然后我手动将列的新定义设置为Z
页面大小的约 20%。我也曾经用 来RaggedRight
做得更好booktabs
。但我仍然觉得它很丑
\documentclass[a4paper]{report}
\usepackage{multirow}
\usepackage{array,booktabs,ragged2e}
\newcolumntype{Z}{>{\RaggedRight}p{0.18\textwidth}}
\begin{document}
\begin{table}[h]
\begin{center}
\renewcommand{\arraystretch}{2}
\begin{tabular}{@{}ZZZZZ@{}}
\toprule
\multirow{2}{1cm}{longlonglong line long} & \multirow{2}{3cm}{longlong text} & \multirow{2}{3cm}{a very longgggggggg\\ line here} & \multicolumn{2}{c}{A very longlong long line here longgggg}\\
\cmidrule{4-5}
& & & should be equal 50\% & should be equal 50\%\\
\bottomrule
\end{tabular}
\end{center}
\end{table}
\end{document}