当前位置:   article > 正文

latex multirow学习

latex multirow

今天搞了一晚上的这个multirow,总算弄出来了几个比较好的例子,主要是这个multirow的语法我没看懂,这个逻辑我是没理解,就很尴尬,一改就报错,只能先弄几个例子,自己慢慢试

\documentclass{article}
\usepackage{multirow,booktabs}
\usepackage{ctex}
\begin{document}
	
%%%%%%%%%%%%%%%%%%%%%%%% 测试1 %%%%%%%%%%%%%%%%	
\begin{center}
	\begin{tabular}{@{} ll cccc r @{}}
		\toprule
		Student & Marker & \multicolumn{4}{c}{Essay} & Total \\
		\cmidrule(lr){3-6}
		& & Originality & Synthesis & Effort & Overall & \\
		\midrule
		\multirow{4}{*}{James}  & Alice  & 9 & 8 & 7 & 8.0 & \multirow{4}{*}{7.9}\\
		& Amelia & 8 & 9 & 7 & 8.0 & \\
		& Anton  & 9 & 7 & 7 & 7.7 & \\
		& Arthur & 7 & 8 & 8 & 7.7 & \\ 
		\addlinespace
		\multirow{4}{*}{Janice} & Alice  & 9 & 9 & 7 & 8.3 & \multirow{4}{*}{8.1}\\
		& Amelia & 9 & 8 & 8 & 8.3 & \\
		& Anton  & 8 & 8 & 8 & 8.0 & \\
		& Arthur & 7 & 9 & 7 & 7.7 & \\ 
		\addlinespace
		\multirow{4}{*}{Julie}  & Alice  &10 & 9 &10 & 9.7 & \multirow{4}{*}{8.8}\\
		& Amelia & 9 & 7 & 8 & 8.0 & \\
		& Anton  & 9 & 8 & 8 & 8.3 & \\
		& Arthur & 9 &10 & 9 & 9.3 & \\
		\bottomrule
	\end{tabular}
\end{center}
	
%%%%%%%%%%%%%%%%%%% 测试2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{center}
		\begin{tabular}{@{} ll cccc r @{}}
			\toprule
			Student & Marker & \multicolumn{4}{c}{Essay} & Total \\
			\cmidrule(lr){3-6}
			& & Originality & Synthesis & Effort & Overall & \\
			\midrule
			\multirow{4}{*}{James}  &  \multirow{4}{*}{Alice} & 9 & 8 & 7 & 8.0 & \multirow{4}{*}{7.9}\\
			  & &8 & 9 & 7 & 8.0 & \\
			  &  &9 & 7 & 7 & 7.7 & \\
			  &  &7 & 8 & 8 & 7.7 & \\ 
			\addlinespace
			\multirow{4}{*}{Janice} & Alice  & 9 & 9 & 7 & 8.3 & \multirow{4}{*}{8.1}\\
			& Amelia & 9 & 8 & 8 & 8.3 & \\
			& Anton  & 8 & 8 & 8 & 8.0 & \\
			& Arthur & 7 & 9 & 7 & 7.7 & \\ 
			\addlinespace
			\multirow{4}{*}{Julie}  & Alice  &10 & 9 &10 & 9.7 & \multirow{4}{*}{8.8}\\
			& Amelia & 9 & 7 & 8 & 8.0 & \\
			& Anton  & 9 & 8 & 8 & 8.3 & \\
			& Arthur & 9 &10 & 9 & 9.3 & \\
			\bottomrule
		\end{tabular}
	\end{center}
	
%%%%%%%%%%%%%%%%%%%%%%%%% 测试3 %%%%%%%%%%%%%%%%%%%%
	\begin{center}
	\begin{tabular}{@{} ll cccc r @{}}
		\toprule
		Student & Marker & \multicolumn{4}{c}{Essay} & Total \\
		\cmidrule(lr){3-6}
		& & Originality & Synthesis & Effort & Overall & \\
		\midrule
		\multirow{4}{*}{James}  &  \multirow{4}{*}{Alice} & \multirow{4}{*}{Mike} & 8 & 7 & 8.0 & \multirow{4}{*}{7.9}\\
		& & & 9 & 7 & 8.0 & \\
		&  & & 7 & 7 & 7.7 & \\
		&  &  & 8 & 8 & 7.7 & \\ 
		\addlinespace
		\multirow{4}{*}{Janice} & Alice  & 9 & 9 & 7 & 8.3 & \multirow{4}{*}{8.1}\\
		& Amelia & 9 & 8 & 8 & 8.3 & \\
		& Anton  & 8 & 8 & 8 & 8.0 & \\
		& Arthur & 7 & 9 & 7 & 7.7 & \\ 
		\addlinespace
		\multirow{4}{*}{Julie}  & Alice  &10 & 9 &10 & 9.7 & \multirow{4}{*}{8.8}\\
		& Amelia & 9 & 7 & 8 & 8.0 & \\
		& Anton  & 9 & 8 & 8 & 8.3 & \\
		& Arthur & 9 &10 & 9 & 9.3 & \\
		\bottomrule
	\end{tabular}
\end{center}

%%%%%%%%%%%%%%%%%%%%%%%%% 测试4 %%%%%%%%%%%%%%%%%%%%
\begin{center}
	\begin{tabular}{@{} ll cccc r @{}}
		\toprule
		Student & Marker & \multicolumn{4}{c}{Essay} & Total \\
		\cmidrule(lr){3-6}
		& & Originality & Synthesis & Effort & Overall & \\
		\midrule
		\multirow{4}{*}{James}  &  \multirow{4}{*}{Alice} & \multirow{4}{*}{Mike} &  \multirow{4}{*}{Lily} & 7 & 8.0 & \multirow{4}{*}{7.9}\\
		& & &  & 7 & 8.0 & \\
		&  & &  & 7 & 7.7 & \\
		&  &  &  & 8 & 7.7 & \\ 
		\addlinespace
		\multirow{4}{*}{Janice} & Alice  & 9 & 9 & 7 & 8.3 & \multirow{4}{*}{8.1}\\
		& Amelia & 9 & 8 & 8 & 8.3 & \\
		& Anton  & 8 & 8 & 8 & 8.0 & \\
		& Arthur & 7 & 9 & 7 & 7.7 & \\ 
		\addlinespace
		\multirow{4}{*}{Julie}  & Alice  &10 & 9 &10 & 9.7 & \multirow{4}{*}{8.8}\\
		& Amelia & 9 & 7 & 8 & 8.0 & \\
		& Anton  & 9 & 8 & 8 & 8.3 & \\
		& Arthur & 9 &10 & 9 & 9.3 & \\
		\bottomrule
	\end{tabular}
\end{center}


%%%%%%%%%%%%%%%%%%%%%%%%% 测试5 %%%%%%%%%%%%%%%%%%%%
\begin{center}
	\begin{tabular}{@{} ll cccc r @{}}
		\toprule
		Student & Marker & \multicolumn{4}{c}{Essay} & Total \\
		\cmidrule(lr){3-6}
		& & Originality & Synthesis & Effort & Overall & \\
		\midrule
		\multirow{4}{*}{James}  &  \multirow{4}{*}{Alice} & \multirow{4}{*}{Mike} &  \multirow{4}{*}{Lily} &  \multirow{4}{*}{nonotreply} & 8.0 & \multirow{4}{*}{7.9}\\
		& & &  &  & 8.0 & \\
		&  & &  &  & 7.7 & \\
		&  &  &  &  & 7.7 & \\ 
		\addlinespace
		\multirow{4}{*}{Janice} & Alice  & 9 & 9 & 7 & 8.3 & \multirow{4}{*}{8.1}\\
		& Amelia & 9 & 8 & 8 & 8.3 & \\
		& Anton  & 8 & 8 & 8 & 8.0 & \\
		& Arthur & 7 & 9 & 7 & 7.7 & \\ 
		\addlinespace
		\multirow{4}{*}{Julie}  & Alice  &10 & 9 &10 & 9.7 & \multirow{4}{*}{8.8}\\
		& Amelia & 9 & 7 & 8 & 8.0 & \\
		& Anton  & 9 & 8 & 8 & 8.3 & \\
		& Arthur & 9 &10 & 9 & 9.3 & \\
		\bottomrule
	\end{tabular}
\end{center}	


%%%%%%%%%%%%%%%%%%%%%%%%% 测试5 %%%%%%%%%%%%%%%%%%%%
\begin{center}
	\begin{tabular}{@{} ll cccc r @{}}
		\toprule
		Student & Marker & \multicolumn{4}{c}{Essay} & Total \\
		\cmidrule(lr){3-6}
		& & Originality & Synthesis & Effort & Overall & \\
		\midrule
		\multirow{4}{*}{James}  &  \multirow{4}{*}{Alice} & \multirow{4}{*}{Mike} &  \multirow{4}{*}{Lily} &  \multirow{4}{*}{nonotreply} & 8.0 & \multirow{4}{*}{7.9}\\
		& & &  &  & 8.0 & \\
		&  & &  &  & 7.7 & \\
		&  &  &  &  & 7.7 & \\ 
		\addlinespace
		\multirow{4}{*}{Janice} & Alice  & 9 & 9 & 7 & 8.3 & \multirow{4}{*}{8.1}\\
		& Amelia & 9 & 8 & 8 & 8.3 & \\
		& Anton  & 8 & 8 & 8 & 8.0 & \\
		& Arthur & 7 & 9 & 7 & 7.7 & \\ 
		\addlinespace
		\multirow{4}{*}{Julie}  & Alice  &10 & 9 &10 & 9.7 & \multirow{4}{*}{8.8}\\
		& Amelia & 9 & 7 & 8 & 8.0 & \\
		& Anton  & 9 & 8 & 8 & 8.3 & \\
		& Arthur & 9 &10 & 9 & 9.3 & \\
		\bottomrule
	\end{tabular}
\end{center}	


%%%%%%%%%%%%%%%%%%%%%%%%%%%% 测试6%%%%%%%%%%%%%%%%%%%%%%
	\begin{center}
	\begin{tabular}{@{} ll cccc r @{}}
		\toprule
		Student & Marker & \multicolumn{4}{c}{Essay} & Total \\
		\cmidrule(lr){3-6}
		& & Originality & Synthesis & Effort & Overall & \\
		\midrule
		\multirow{4}{*}{James}  &  \multirow{4}{*}{Alice} & 9 & 8 & 7 & 8.0 & 79\\
		& &8 & 9 & 7 & 8.0 & 790 \\
		&  &9 & 7 & 7 & 7.7 & 7900\\
		&  &7 & 8 & 8 & 7.7 & 79000 \\ 
		\addlinespace
		\multirow{4}{*}{Janice} & Alice  & 9 & 9 & 7 & 8.3 & \multirow{4}{*}{8.1}\\
		& Amelia & 9 & 8 & 8 & 8.3 & \\
		& Anton  & 8 & 8 & 8 & 8.0 & \\
		& Arthur & 7 & 9 & 7 & 7.7 & \\ 
		\addlinespace
		\multirow{4}{*}{Julie}  & Alice  &10 & 9 &10 & 9.7 & \multirow{4}{*}{8.8}\\
		& Amelia & 9 & 7 & 8 & 8.0 & \\
		& Anton  & 9 & 8 & 8 & 8.3 & \\
		& Arthur & 9 &10 & 9 & 9.3 & \\
		\bottomrule
	\end{tabular}
\end{center}


aaaa\\
aaaa\\
aaaa\\
表格6\\
%%%%%%%%%%%%%%%%%%%%%%%%%%% 测试6%%%%%%%%%%%%%%%%%%%%%%
\begin{tabular}{|c|c|c|c|c|}
	\hline
	\multicolumn{5}{|c|}{学生个人信息} \\
	\hline
	\multirow{2}*{姓名} & 
	\multirow{2}*{学号} & 
	\multicolumn{3}{c|}{成绩} \\ \cline{3-5} 
	\multicolumn{1}{|c|}{} &
	\multicolumn{1}{|c|}{} & 
	\multicolumn{1}{|c|}{语文} & 数学 & 英语 \\ \hline
	张三 & 006 & 91 & 98 & 99 \\ \hline
	李四 & 009 & 87 & 88 & 79 \\ \hline
	王五 & 007 & 81 & 79 & 77 \\ \hline
\end{tabular}

aaaa\\
aaaa\\
aaaa\\
表格7\\
%%%%%%%%%%%%%%%%%%%%%%%%%%%% 测试7%%%%%%%%%%%%%%%%%%%%%%
\begin{tabular}{|c|c|c|c|c|}
	\hline
	\multicolumn{5}{|c|}{学生个人信息} \\
	\hline
	\multirow{2}*{姓名} & \multirow{2}*{学号} &科目1 & 科目2 & 科目3  \\
	\cline{3-5}
	& & 语文  & 数学& 英语  \\
    \cline{1-5}
	张三 & 006 & 91 & 98 & 99 \\ \hline
	李四 & 009 & 87 & 88 & 79 \\ \hline
	王五 & 007 & 81 & 79 & 77 \\ \hline
\end{tabular}

aaaa\\
aaaa\\
aaaa\\

%%%%%%%%%%%%%%%%%%%%%%%%%%%% 测试8%%%%%%%%%%%%%%%%%%%%%%
\begin{table}
\centering	
	\caption{测试表格
	\label{Table:测试}}
\begin{tabular}{|c|c|c|c|c|}
	\hline
	\multicolumn{5}{|c|}{学生个人信息} \\
	\hline
	\multirow{2}*{姓名} & \multirow{2}*{学号} &科目1 & 科目2 & 科目3  \\
	\cline{3-5}
	& & 语文  & 数学& 英语  \\
	\cline{1-5}
	张三 & 006 & 91 & 98 & 99 \\ \hline
	李四 & 009 & 87 & 88 & 79 \\ \hline
	王五 & 007 & 81 & 79 & 77 \\ \hline
\end{tabular}
\end{table}



\end{document}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255

结果如下
在这里插入图片描述在这里插入图片描述
在这里插入图片描述在这里插入图片描述在这里插入图片描述
根据这几个表格,我大概能把语法看懂

在这里插入图片描述

multirow 逻辑

分析这个代码和结果的对应关系,首先使用语法\multirow 其中后面的2是代表这个位置是合并2行,后面的星星符号我目前也不知道干嘛的,我看到的例子全带这个,可以先不管,后面的{姓名}是最终合并两行所填写的一个元素的内容,同理\multirow{2}*{学号}也是这个道理,就是第二列的两行需要合并,从这里就可以看到一个逻辑,这个语法就是从左到右,一行一行写的,而不是先按列来的,到了这一步,假设需要合并的内容已经写完了,从第三列开始就是不需要合并的,按照一行一行的逻辑,那么接下来我就写 &科目1 & 科目2 & 科目3,把后面三列占满,但是此时需要注意,这里的&科目1 & 科目2 & 科目3仅仅占了一行的,要知道我们开始的两列是两行合并成一行的,所以元素必然还有缺失的,但是这个不影响这个逻辑,此时我们第一行其实已经写完了,然后输入换行\, 这里表格其实就已经输出到了第二行的第一列,记住第一列和第二列是合并了的,之前已经填过了,所以不需要再填了,所以需要使用& 把位置给占住,因为输入& & ,到这里其实表格已经输出到了第二行第三列了,从这里开始我就正常填充元素了,因此输入语文 & 数学& 英语 ,然后换行,一个多行合并的表格就被输出了,剩下的就依葫芦画瓢了

补充学习

\documentclass{article}
\usepackage{multirow,booktabs}
\usepackage{ctex}

\begin{document}
	\begin{table}
		%%%%%%%%%%%%%%%%%%%%%%%%%%%% 测试6%%%%%%%%%%%%%%%%%%%%%%
		\begin{center}
			\begin{tabular}{@{} ll cccc r @{}}
				\toprule
				Student & Marker & \multicolumn{4}{c}{Essay} & Total \\
				\cmidrule(lr){3-6}
				
				& & Originality & Synthesis & Effort & Overall & \\
				\midrule
				\multirow{4}{*}{James}  &  \multirow{4}{*}{Alice} & 9 & 8 & 7 & 8.0 & 79\\
				& &8 & 9 & 7 & 8.0 & 790 \\
				&  &9 & 7 & 7 & 7.7 & 7900\\
				&  &7 & 8 & 8 & 7.7 & 79000 \\ 
				\cline{1-7}
				\addlinespace
				\multirow{4}{*}{Janice} & Alice  & 9 & 9 & 7 & 8.3 & \multirow{4}{*}{8.1}\\
				& Amelia & 9 & 8 & 8 & 8.3 & \\
				& Anton  & 8 & 8 & 8 & 8.0 & \\
				& Arthur & 7 & 9 & 7 & 7.7 & \\ 
				
				\cline{1-7}
				\addlinespace
				\multirow{4}{*}{Julie}  & Alice  &10 & 9 &10 & 9.7 & \multirow{4}{*}{8.8}\\
				& Amelia & 9 & 7 & 8 & 8.0 & \\
				& Anton  & 9 & 8 & 8 & 8.3 & \\
				& Arthur & 9 &10 & 9 & 9.3 & \\
				\bottomrule
			\end{tabular}
		\end{center}
		
	\end{table}
	
	
\begin{table}[hp] %%参数: h:放在此处 t:放在顶端 b:放在底端 p:在本页
	\renewcommand\arraystretch{1.2}
	%\setlength{\abovecaptionskip}{0.cm}
	%\setlength{\belowcaptionskip}{-0.cm}
	\centering  % 显示位置为中间
	\textbf{Table 2}~~Parameters description.\\  %%表的标题
	\begin{tabular}{p{45pt}l|ll|l} %第一列设置宽度为45pt 全为左对齐 没有分割线
		%\setlength{\tabcolsep}{20mm}
		\hline  % 表格的横线
		%\toprule % 顶部线
		Parameters & & Definitions & Value & Source \\%[3pt]只改一行    %%表格第一行标题 % 表格中的内容,用&分开,\\表示下一行
		\hline  % 表格的横线
		%\midrule % 中部线
		$\beta_{1}$   & & xxxxabcdxxx           & 1 &  Estimation \\    %%表格内容
		%\midrule
		\multirow{2}[2]{*}{$\alpha_{3}$} & & aaa1 & \multirow{2}[2]{*}{1} &  \multirow{2}[2]{*}{Estimation} \\
		& & bbb2                  &   &             \\
		$d_{1}$       & & xxxxabcdxxx           & 1 &  Estimation \\
		\multirow{3}[2]{*}{$1/\theta(t)$}& $\theta_{0}$ & 1aaa            & 1 &  Estimation \\
		& $\theta_{1}$ & 2bbb            & 1 &  Estimation \\
		& $\theta_{2}$ & 3ccc            & 1 &  Estimation \\
		%\bottomrule % 底部线
		\hline  % 表格的横线
	\end{tabular}
\end{table}

	
\end{document}	

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68

结果如下
在这里插入图片描述在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/965363
推荐阅读
  

闽ICP备14008679号