latex中不规则表格合并multirow、multicolumn的使用
multirowmultirow 宏包提供了 \multirow 命令可以在表格中排版横跨两行以上的文本。命令的格式如下: \multirow{nrows}[bigstructs]{width}[fixup]{text}
下面是几个例子: | ||||||||||
\newcommand{\minitab}[2][l]{\begin{tabular}{#1}#2\end{tabular}} \begin{tabular}{|c|c|} \hline \multirow{4}{1in}{Common g text} & Column g2a\\ & Column g2b \\ & Column g2c \\ & Column g2d \\ \hline \multirow{3}[6]*{Common g text} & Column g2a\bigstrut\\\cline{2-2} & Column g2b \bigstrut\\\cline{2-2} & Column g2c \bigstrut\\ \hline \multirow{4}[8]{1in}{Common g text} & Column g2a\bigstrut\\\cline{2-2} & Column g2b \bigstrut\\\cline{2-2} & Column g2c \bigstrut\\\cline{2-2} & Column g2d \bigstrut\\ \hline \multirow{4}*{\minitab[c]{Common \\ g text}} & Column g2a\\ & Column g2b \\ & Column g2c \\ & Column g2d \\ \hline \end{tabular} | ||||||||||
结果如图所示: | ||||||||||
更多的例子: | ||||||||||
\renewcommand{\multirowsetup}{\centering} \begin{tabular}{|l|l|l|l|} \hline \multirow{4}{2cm}{This is a demo table} & C2a & \multirow{4}{2cm}{This is another one} & C4a\\ & C2b & & C4b\\ & C2c & & C4c\\ & C2d & & C4d\\ \hline \end{tabular} \bigstrutjot=1pt% \begin{tabular}{|l|l|l|l|} \hline \multirow{4}{2cm}{This is a demo table} & C2a & \multirow{4}{2cm}{This is another one} & C4a\\ & C2b & & C4b\\ & C2c & & C4c\\ & C2d & & C4d\\ \hline \end{tabular} \begin{tabular}{|l|l|l|l|} \hline \multirow{4}{2cm}{This is a demo table} & C2a & \multirow{4}[30]{2cm}{This is another one} & C4a\\ & C2b & & C4b\\ & C2c & & C4c\\ & C2d & & C4d\\ \hline \end{tabular} \begin{tabular}{|l|l|l|l|} \hline \multirow{4}{2cm}{This is a demo table} & C2a & \multirow{4}{2cm}[30pt]{This is another one} & C4a\\ & C2b & & C4b\\ & C2c & & C4c\\ & C2d & & C4d\\ \hline \end{tabular} \begin{tabular}{|l|l|l|l|} \hline \multirow{4}{2cm}{This is a demo table} & C2a & \multirow{4}[30]{2cm}[-30pt]{This is another one} & C4a\\ & C2b & & C4b\\ & C2c & & C4c\\ & C2d & & C4d\\ \hline \end{tabular} | ||||||||||
有关 multirow 宏包更详细的说明,可参见它的说明文档(英文 PDF 格式)。 |