当我在表格中同时使用多列和多行时,文本不会在多列内换行,并且列大小会自动变得很长。有问题的代码附后:
\begin{table}[htbp]
\centering
% \resizebox{\textwidth}{!}{%
\begin{tabular}{| C{2cm} | C{2cm} | C{2cm} |} \hline
\multirow{2}{4em} {Crack length(a)} & \multicolumn{2}{c}{Geometric (and loading) parameter in SIF}\\\cline{2-3}
& Present & From ~\cite{RC2}\\\hline
0.200 & 1.297 & 1.313 \\\hline
0.300 & 1.426 & 1.431 \\\hline
0.400 & 1.565 & 1.567 \\\hline
\end{tabular}
如何使列大小固定并在其中换行?如果多列文本需要 2 行,那也可以。但如何嵌套多行和多列?
答案1
下面的内容能满足您的目标吗?
\documentclass{article}
\usepackage{array} % no need for 'multirow' package, really
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}} % is this right?
\begin{document}
\begin{table}[htbp]
\setlength\extrarowheight{2pt} % for a more "open" look
\centering
\begin{tabular}{| C{2cm} | C{2cm} | C{2cm} |}
\hline
Crack length (a) &
\multicolumn{2}{C{\dimexpr4cm+2\tabcolsep\relax}|}{Geometric (and loading) parameter in SIF}\\
\cline{2-3}
& Present & From \cite{RC2}\\\hline
0.200 & 1.297 & 1.313 \\\hline
0.300 & 1.426 & 1.431 \\\hline
0.400 & 1.565 & 1.567 \\\hline
\end{tabular}
\end{table}
\end{document}
答案2
我会使用简单的c
列并手动拆分标题。该表似乎主要包含数字数据,因此我觉得文本换行不是真正的要求。
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{table}[htbp]
\setlength\extrarowheight{2pt} % for a more "open" look
\centering
\begin{tabular}{ |*3{c|} }
\hline
Crack length & \multicolumn{2}{c|}{Geometric (and loading)} \\ [-2pt]
(a) & \multicolumn{2}{c|}{parameter in SIF} \\ \cline{2-3}
& Present & From~[ref] \\ \hline
0.200 & 1.297 & 1.313 \\ \hline
0.300 & 1.426 & 1.431 \\ \hline
0.400 & 1.565 & 1.567 \\ \hline
\end{tabular}
\end{table}
\end{document}