在制作LaTex表格的时候,常常需要合并行和列,本文介绍的是使用 multirow 包里面的命令完成合并行列的方法。
\begin{table*} %\usepackage{multirow} \center \begin{tabular}{|c|c|c|c|c|} \hline % horizontal line \multirow{2}{*}{1 \& 2} & \multicolumn{2}{l|}{ 3 \& 4 } & 5 & 6\\ %end line \cline{2-5} %short partial horizontal lines from column 2 to column 5 & 7 & 8 & 9 & 10\\ %first cell is occupied by the multirow \hline \hline $ s_{1} $ & 2 & 3 & 4 & 5\ $ s_{2} $ & 2 & 3 & 4 & 5\ \hline \hline $ s_{3} $ & 2 & 3 & 4 & 5\\ $ s_{4} $ & 2 & 3 & 4 & 5\ \hline \end{tabular} \end{table*}
效果
\begin{table}[h] \caption{Optimization summary.} \label{tab:summary} \begin{tabular}{cccc} \toprule \multirow{2}{*}{Design} & \multicolumn{2}{c}{Problem size} & \multirow{2}{*}{CPU time(s)} \ \cline{2-3} & Binary variables & Constraints\ \midrule OM1 & 199 & 13,017 & 000 \ OM2 & 199 & 1,525 & 000 \ \bottomrule \end{tabular} \label{tab:my_label} \end{table}
效果