latex中设置复杂表格

latex中,整个table是由大小一致的单元格组成,在这个基础上,通过合并单元格(行/列)的方式,实现整个table的设计。分割符号:竖线用“|”,横线用“\cline“。行列合并方法:列合并用”\multicolumn“,行合并用”\multirow“。

 1 \documentclass[a4paper, 12pt]{ctexbook}
 2 \usepackage{multirow}
 3 
 4 \begin{document}
 5     灵活表格制作的过程:
 6 \begin{table*}[h]
 7     \centering
 8     \caption{正规表格}
 9     \begin{tabular}{|c|l|l|l|}
10         \hline
11         1 & 2 & 3 & 4\\ \hline
12         5 & 6 &7 &8 \\ \hline
13         9 & 10 &11 &12 \\ \hline
14     \end{tabular}
15 \end{table*}
16 \begin{table}[h]
17     \centering
18     \caption{合并列表格}
19     \begin{tabular}{|c|l|l|l|}
20         \hline
21         1 & 2 & 3 & 4\\ \hline
22         5 & 6 &7 &8 \\ \hline
23         9 & \multicolumn{2}{|c|}{10} &12 \\ \hline
24     \end{tabular}
25 \end{table}
26 \begin{table}[h]
27     \centering
28     \caption{合并行表格}
29     \begin{tabular}{|c|l|l|l|}
30         \hline
31         1 & 2 & 3 & 4\\ \hline
32         \multirow{2}{*}{5} & 6 &7 &8 \\ \cline{2-4}
33          & 10 &11 &12 \\ \hline
34     \end{tabular}
35 \end{table}
36 \begin{table}[h]
37     \centering
38     \caption{合并行和列表格}
39     \begin{tabular}{|c|l|l|l|}
40         \hline
41         1 & 2 & 3 & 4\\ \hline
42         \multirow{2}{*}{5} & 6 &7 &8 \\ \cline{2-4}
43         & \multicolumn{2}{|c|}{10} &12 \\ \hline
44     \end{tabular}
45 \end{table}
46 \begin{table}[h]
47     \centering
48     \caption{成绩表}
49     \begin{tabular}{|c|l|l|l|}
50         \hline
51         \multirow{2}{*}{科目} & \multicolumn{2}{|c|}{科学} &课外 \\ \cline{2-4}
52         & 数学 &英语 &其他 \\ \hline
53         成绩 & 95 & 93 & 78\\ \hline
54     \end{tabular}
55 \end{table}
56 
57 \end{document}

 具体操作:

1. \multirow{2}{*}{科目}:2合并的行数,*默认的不用管,科目是合并后用科目填充行内容;

2. 行合并后,行的结尾用\cline{begin-end},cline画合并的行之间的分割线,begin开始的列,end结束的列;

3. \multicolumn{2}{|c|}{科学}:合并的列数为2,合并与未合并列的分隔符|,合并后内容的分布方式c为居中,科学是合并后的列中填入的内容;

 

posted @ 2026-07-10 10:18  叕叒双又  阅读(13)  评论(0)    收藏  举报