-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathhynuexam2024.cls
580 lines (513 loc) · 21.5 KB
/
hynuexam2024.cls
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
\NeedsTeXFormat{LaTeX2e}
%The command \NeedsTeXFormat{LaTeX2e} sets the LATEX version for the class to work. Additionally, a date can be added within brackets to specify the minimal release date required.
\ProvidesClass{hynuexam2024}[2019/12/15 HengYang Normal University Exam Document Class]
%2019/05/27 version 1.1 能自己用,但编译慢
%2019/06/15 version 1.2
%2019/09/29 version 1.3 (迟到)国庆节前完成可用的初稿
%2019/10/7 version 2.0 将抬头的表格自动生成,采用LaTeX3方式。
%2019/10/17 version 2.1 将\makepart{}[]{}命令写成了可选参数形式
%2019/12/15 version 3.0 将试卷前面的信息有些字体加粗了,判断题设置为括号且放置在最前面。
%2019/12/19 version 3.1 将不连续题序标号为新的一个文件,可按照需要选择不同的文件模拟来出题。
%2021/01/03 version 4.0 加入装订线
%2021/06/27 version 4.1 将表格中的阿拉伯数字替换成中文的
%2022/04/22 version 5.0 加入课程目标
%2024/06/09 version 6.0 zhlineskip中文里面公式间距太大;或者使用scheme=plain; 设置了可以手动调整矩阵大小的选项公式
%https://github.com/CTeX-org/ctex-kit/issues/549
%https://www.zhihu.com/question/633580715/answer/3315967687
%https://tex.stackexchange.com/questions/14071/how-can-i-increase-the-line-spacing-in-a-matrix
%The command ProvidesClass{exampleclass}[...] identifies this class as exampleclass and, inside the brackets, the release date and some additional information is included. The date should be in the form YYYY/MM/DD
\LoadClass{exam}
\RequirePackage{amsmath,amssymb,amsthm} %美国数学学会系列
\RequirePackage{mathtools} %amsmath增强包
\RequirePackage{tikz} %tikz用于画图包
%\RequirePackage[scheme=plain]{ctex} %支持中文, 英文环境的公式不变
\RequirePackage{ctex} %支持中文, 英文环境的公式不变
\RequirePackage{zhlineskip} %恢复公式行距
\RestoreTextEnvironmentLeading{tabular} %表格也设置恢复成西文的方式
\RestoreTextEnvironmentLeading{tabu}
\RequirePackage{zhnumber} %中文数字包
\RequirePackage{geometry} %设置页边距等
\RequirePackage{indentfirst} %设置首段缩进
\RequirePackage{xhfill,xcolor} %评分标准右对齐,颜色包
\RequirePackage{expl3,xparse} %LaTeX3
\RequirePackage{etoolbox,xinttools,xfp,totcount} %一些有用的宏包
\RequirePackage{multirow,makecell,tabu,diagbox,ragged2e} %表格包,表格多行合并包
\RequirePackage{bbding,pifont} %对错符号包
\RequirePackage{siunitx} % 国际单位制宏包(典型的一个LaTeX3实现的宏包)
\RequirePackage{nicematrix,extarrows,enumerate} % 增广矩阵等矩阵扩展
\RequirePackage{bm}%加粗包
\RequirePackage{pgfplots}
\RequirePackage{derivative,tcolorbox}
\RequirePackage{comment,siunitx}
%\RequirePackage is very similar to the well-known \usepackage
\DeclareOption{answer}{\printanswers}
\newif\ifny\nyfalse
\DeclareOption{ny}{\nytrue}
\DeclareOption{addtable}{\addpoints}
%The command \DeclareOption{}{} handles a given option. It takes two parameters, the first one is the name of the option and the second one is the code to execute if the option is passed.
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
%\PassOptionsToClass{}{}. Passes the option inside the first pair of braces to the document class set inside the second pair of braces.
\PassOptionsToPackage{tbtags}{amsmath}
\ProcessOptions\relax
%The command \ProcessOptions\relax executes the code fore each option and must be inserted after all the option-handling commands were typed. There's a starred version of this command that will execute the options in the exact order specified by the calling commands.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%宏包前言%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%中英文字体设置%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 中文字体设置
\setCJKfamilyfont{zhsong}[AutoFakeBold = {2.17}]{SimSun}
% 英文字体设置
% 设置英文主字体
\setmainfont{Times New Roman}
% 设置英文无衬线字体
\setsansfont{Arial}
% 定义默认字体大小和行距
\renewcommand{\normalsize}{\fontsize{12pt}{\baselineskip}\selectfont}
% 其它比较常见的字体字号设置
\newcommand{\chuhao}{\fontsize{42pt}{\baselineskip}\selectfont}
\newcommand{\xiaochuhao}{\fontsize{36pt}{\baselineskip}\selectfont}
\newcommand{\yihao}{\fontsize{28pt}{\baselineskip}\selectfont}
\newcommand{\erhao}{\fontsize{21pt}{\baselineskip}\selectfont}
\newcommand{\xiaoerhao}{\fontsize{18pt}{\baselineskip}\selectfont}
\newcommand{\sanhao}{\fontsize{15.75pt}{\baselineskip}\selectfont}
\newcommand{\sihao}{\fontsize{14pt}{\baselineskip}\selectfont}
%\newcommand{\sihao}{\fontsize{14pt}{14pt}\selectfont}
\newcommand{\xiaosihao}{\fontsize{12pt}{\baselineskip}\selectfont}
\newcommand{\wuhao}{\fontsize{10.5pt}{\baselineskip}\selectfont}
\newcommand{\xiaowuhao}{\fontsize{9pt}{\baselineskip}\selectfont}
\newcommand{\liuhao}{\fontsize{7.875pt}{\baselineskip}\selectfont}
\newcommand{\qihao}{\fontsize{5.25pt}{\baselineskip}\selectfont}
% 试卷纸张设置,A4纸(两页合成一个大页的方式)
\geometry{paperheight=297mm,paperwidth=210mm}
% 设置试卷的页眉页脚与页边距的距离
\geometry{vmargin={2cm,2.54cm},footskip=0.79cm,marginparsep=0.5cm}
\geometry{inner=2.17cm,outer=1cm}
%\geometry{bindingoffset=0.1cm}
% 设置试卷的页眉页脚与页边距的距离
%\geometry{vmargin={2.54cm,2.54cm},footskip=0.79cm,marginparsep=0.5cm}
%\geometry{inner=2.17cm,outer=1cm}
%\geometry{bindingoffset=0.1cm}
%\geometry{ignorehead}
% 设置首行缩进
\setlength{\parindent}{0em}
% 重新设置表格放缩为1
\renewcommand\arraystretch{1}
% 新版装订线
\reversemarginpar
\newsavebox{\zdx}%装订线
\newcommand{\putzdx}{\marginpar{
\rotatebox{90}{\hspace{1cm}\usebox{\zdx}}
}
}
\AtBeginDocument{%
\sbox{\zdx}{
\parbox{\textheight}{
\begin{center}
\ifny 系别 \else 学院\fi \underline{\hspace{15ex}} \quad
专业 \underline{\hspace{15ex}} \quad
班级 \underline{\hspace{15ex}} \quad
学号 \underline{\hspace{15ex}} \quad
姓名 \underline{\hspace{15ex}} \quad\\
\vspace{1mm}
\dotfill{} 密 \dotfill{} 封 \dotfill{} 线 \dotfill{}
\end{center}%
}%
}%
\putzdx%
}
% 打印右边学生信息命令
\newcommand{\studentTable}{%
\smash{\makebox[0pt][r]{%
\sihao\songti\textbf{% 五号宋体加粗
\begin{tabular}[t]{|p{2cm}<{\centering}|}
\multicolumn{1}{c}{} \\[2in] % lower the box
\hline
\phantom{text}学\hfil 院\\
\hline
\\[2\normalbaselineskip]
\hline
专\hfil 业\\
\hline
\\[2\normalbaselineskip]
\hline
班\hfil 级\\
\hline
\\[2\normalbaselineskip]
\hline
学\hfil 号\\
\hline
\\[2\normalbaselineskip]
\hline
姓\hfil 名\\
\hline
\\[2\normalbaselineskip]
\hline
\end{tabular}\hspace{0.5em}
\normalsize
}}}%
\gdef\studentTable{}%
}
% 打印右边学生信息命令
\newcommand{\NstudentTable}{%
\smash{\makebox[0pt][r]{%
\wuhao\songti\textbf{% 五号宋体加粗
\begin{tabular}[t]{|p{2cm}<{\centering}|}
\multicolumn{1}{c}{} \\[2in] % lower the box
\hline
系\hfil 别\\
\hline
\\[2\normalbaselineskip]
\hline
专\hfil 业\\
\hline
\\[2\normalbaselineskip]
\hline
班\hfil 级\\
\hline
\\[2\normalbaselineskip]
\hline
学\hfil 号\\
\hline
\\[2\normalbaselineskip]
\hline
姓\hfil 名\\
\hline
\\[2\normalbaselineskip]
\hline
\end{tabular}\hspace{0.5em}
\normalsize
}}}%
\gdef\NstudentTable{}%
}
% 衡阳师范学院试卷开头信息
\newcommand{\examinformation}[5]{%
\begin{center}%
{\fontsize{18pt}{1.2\baselineskip}\selectfont\heiti\bfseries #1\\
#2\\
#3\\
\ifprintanswers
参考答案及评分标准\\
\fi
}
{\wuhao\songti \vspace*{0.1cm} 考核类型:~#4\hspace{1cm}考核时量:#5~分钟}
\end{center}
}
% 课程目标指示器
\newtotcounter{Courseindex}
\setcounter{Courseindex}{0}
\newcommand{\qnum}{\zhnum{Courseindex}、}
% 定义大题、总分计数器并初始化为0
\newtotcounter{examSection} % 一共有几个大题的计数器
\newtotcounter{sumpoints} % 总分计数器
\newtotcounter{sumCoursepoints} % 总分计数器
%%%%%%%%%%%%%%%%%%%%%%%%% LaTeX3 部分
% 开启LaTeX3语法
\ExplSyntaxOn
\clist_new:N \g_grades_clist %
\clist_new:N \g_grades_aux_clist %
\clist_new:N \g_coursegrades_clist %
\clist_new:N \g_coursegrades_aux_clist %
% 课程目标命令
\NewDocumentCommand{\CourseObjective}{m}{
\addtocounter{sumCoursepoints}{#1} % 统计总分
\__add_to_coursegrades_list:n { #1 }
\stepcounter{Courseindex}
\begin{EnvFullwidth}
\setcounter{examSection}{0}
\begin{tabu}{|[1.2pt]c|[1.2pt]p{1.2cm}|[1.2pt]l}
\tabucline[1.2pt]{1-2}
\makebox[1.2cm][s]{\xiaowuhao 课程目标} & \phantom{100} & \multirowcell{2}{\textbf{\sihao \qnum 课程目标\arabic{Courseindex}\quad (共 #1 分)}} \\
\makebox[1.2cm][s]{\xiaowuhao 得\hspace{\fill}分} & & \\
\tabucline[1.2pt]{1-2}
\end{tabu}
\normalsize % 将字体变成默认的
\vspace{0.2em} % 下面留白一点点
\end{EnvFullwidth}
}%课程目标命令结束
%% 开始一个大题的命令
\str_set:Nn \g_tmpa_str{判断题} %如果是判断题,添加一些文字描述,打勾或打叉!!
\NewDocumentCommand{\makepart}{ m o m }{
% 使用举例 \makepart{选择题}[3]{15}表示3分一个选择题,共5个选择题,分总共是15分;其中5个题目不需要指明
% #1:题型,如“选择题”
% #2:当分值一样时,每小题多少分,是可选参数,使用方括号。如果每小题的分值不同,则这个参数省略。
% #3:这个大题的总分是多少,显示写出来,没有使用自动计算。
\vskip 0pt % 插入0pt的垂直间距来确保垂直模式 %你的命令
\setcounter{question}{0}
\stepcounter{examSection} % 每开始一个大题,将大题计数器加一
\addtocounter{sumpoints}{#3} % 统计总分
% 由于要在开头展示出每个大题的总分,所以需要将每个大题的总分写出辅助文件,我们采用的方式是先写入到一个“列表”这样的数据结构中。最后在文档结束时,写入辅助文件。
\__add_to_grades_list:n { #3 } % 将参数3的分值加到\g_grades_clist这个列表变量右边去。
% exam文档类中定义的EnvFullwidth环境
\str_set:Nn \g_tmpb_str{#1} % 将大题的题型置入LaTeX3系统自带的临时变量里。
%%%%%%%%%%%%%%%%% 以上是前期准备
%%%%%%%%%%%%%%%%% 以下是正式输出大题题头:
\begin{EnvFullwidth}
\sihao % 四号字体
\renewcommand\arraystretch{1.2} % 表格缩放2倍
\begin{tabular}{|c|c|c}
\cline{1-2}
得分 & \phantom{100} & ({\heiti\bfseries\zhnum{examSection})#1(
\str_if_eq:NNTF{\g_tmpa_str}{\g_tmpb_str}{正确打\cmark,错误打\xmark,}{}% 通过判定是不是判断题来决定是不是多输出一些文字。
\IfNoValueF {#2} {每小题~#2~分,} 共~#3~分)} \\% 判断是否每个题分值一样,通过看是否有可选参数来实现~
\cline{1-2}
\end{tabular}
\normalsize % 将字体变成默认的
%\vspace{0.5em} % 下面留白一点点
\end{EnvFullwidth}
}% \makepart{}[]{}命令结束
% 在新增一个大题时将这个大题的总分写入\g_grades_clist这个列表数据结构变量
\cs_new:Nn \__add_to_grades_list:n {
\clist_gput_right:Nx \g_grades_clist { #1 }
% 第四大题时会产生这样的效果(15,15,10)->(15,15,10,60)
}
% 在新增一个课程目标时将这个课程目标的总分写入\g_coursegrades_clist这个列表数据结构变量
\cs_new:Nn \__add_to_coursegrades_list:n {
\clist_gput_right:Nx \g_coursegrades_clist { #1 }
% 第四个课程目标的时候会产生这样的效果(15,15,10)->(15,15,10,60)
}
% 按题型打印表格(目前的实现方式是一定要有表格,可以修改为不一定要有表格)
\NewDocumentCommand{\sectiongradetable}{}{
\if@addpoints
\@ifundefined{exam@numpoints}{%
\ClassWarning{exam}{%
You~must~run~LaTeX~again~to~produce~the~table.\MessageBreak
}%
\fbox{Please Run \LaTeX{} again to produce the table}%
}%
{\constructionTable}%
\else
\ClassError{exam}{%
You must give the command \protect\addpoints\MessageBreak
\space\space in order to create a grade table.\MessageBreak
}{%
If you don't give the command \protect\addpoints\MessageBreak
\space\space then we're not keeping track of point values.
\MessageBreak
}%
\fi
}
% 按课程目标打印表格(目前的实现方式是一定要有表格,可以修改为不一定要有表格)
\NewDocumentCommand{\CourseObjectivegradetable}{}{
\if@addpoints
\@ifundefined{exam@numpoints}{%
\ClassWarning{exam}{%
You~must~run~LaTeX~again~to~produce~the~table.\MessageBreak
}%
\fbox{Please Run \LaTeX{} again to produce the table}%
}%
{\constructionCourseGradeTable}%
\else
\ClassError{exam}{%
You must give the command \protect\addpoints\MessageBreak
\space\space in order to create a grade table.\MessageBreak
}{%
If you don't give the command \protect\addpoints\MessageBreak
\space\space then we're not keeping track of point values.
\MessageBreak
}%
\fi
}
% 新建这个与大题分数列表相关的命令,在第二次运行时由于将执行命令定入了辅助文件,所以第二次会执行
\NewDocumentCommand\SetGradeList{m}{ % set grade list from the aux file
\clist_gset:Nn \g_grades_aux_clist {#1}
}
% 新建这个与课程目标分数列表相关的命令,在第二次运行时由于将执行命令定入了辅助文件,所以第二次会执行
\NewDocumentCommand\SetCourseGradeList{m}{ % set grade list from the aux file
\clist_gset:Nn \g_coursegrades_aux_clist {#1}
}
% 写入辅助文件,在结束文档时写入
\AtEndDocument{
\iow_now:cx { @auxout } { %LaTeX3的读写文件的函数
\token_to_str:N \SetCourseGradeList { \g_coursegrades_clist } ^^J
\token_to_str:N \SetGradeList { \g_grades_clist } ^^J
% ^^J表示一个回车。
}
}
% 实际输出表格的命令,使用xinittools包来循环
\NewDocumentCommand{\constructionTable}{}{
\begin{table}[h] %表格输入实体部分,可以不用浮动体,用h表示强制要放在抬头部分
\centering
{\heiti\bfseries\xiaowuhao %表格内文字字体设置
\begin{tabular}{|*{\inteval{2+\totvalue{examSection}}}{p{1.5cm}<{\centering}|}}
\hline
题\quad 号 \xintFor* ##1 in {\xintSeq {1}{\totvalue{examSection}}} \do {&\,\zhnumber{##1}\,} & 总分\\
\hline
分\quad 值 \xintFor ##1 in \g_grades_aux_clist \do {& ##1} & \total{sumpoints}\\
\cline{1-\inteval{2+\totvalue{examSection}}}
得\quad 分 \xintFor* ##1 in {\xintSeq {1}{\inteval{1+\totvalue{examSection}}}} \do{&}\\
\hline
\end{tabular}}
\end{table}
%\renewcommand\arraystretch{1.2}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 一个实际的表格的样子
% \begin{tabular}{|c|c|c|c|c|c|}
% \hline
% 题 号 & 一 & 二 & 三 & 四 & 总分 \\
% \hline
% 分 值 & 15 & 15 & 10 & 60 & 100\\
% \cline{1-6}
% 得 分 & & & & & \\
% \hline
% \end{tabular}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 实际输出带课程目标分数表格的命令,使用xinittools包来循环
\NewDocumentCommand{\constructionCourseGradeTable}{}{
\begin{table}[h] %表格输入实体部分,可以不用浮动体,用h表示强制要放在抬头部分
\centering
{\xiaowuhao %表格内文字字体设置 \renewcommand\arraystretch{2}
%调试用的 \theCourseindex、\theexamSection、\inteval{\totvalue{Courseindex}}、
\begin{tabular}{|*{\inteval{2+\totvalue{Courseindex}}}{p{2.5cm}<{\centering}|}}
\hline
题\quad 号 \xintFor* ##1 in {\xintSeq {1}{\totvalue{Courseindex}}} \do {&\,\zhnumber{##1}、课程目标##1\,} & 总分\\
\hline
分\quad 值 \xintFor ##1 in \g_coursegrades_aux_clist \do {& ##1} & \total{sumCoursepoints}\\
\cline{1-\inteval{2+\totvalue{Courseindex}}}
得\quad 分 \xintFor* ##1 in {\xintSeq {1}{\inteval{1+\totvalue{Courseindex}}}} \do{&}\\
\hline
\end{tabular}}%局部五号字体
\end{table}
%\renewcommand\arraystretch{1}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%如果课程目标数量不一致,删除一列即可,分数值也相应修改
% \begin{table}[h!]
% \centering
% {\wuhao
% \begin{tabular}{|p{2cm}<{\centering}|c|c|c|p{2cm}<{\centering}|}
% \hline
% 题号 & 一、课程目标1 & 二、课程目标2 & 三、课程目标3 & 总分 \\\hline
% 分值 & 10 & 70 & 20 & 100 \\\hline
% 得分 & & & & \\\hline
% \end{tabular}}
% \end{table}
%%% 判断题(按是不是设置了答案选项来执行)
\NewDocumentCommand{\tfblank}{}{(\qquad)} %正式试卷的判断题输出
\NewDocumentCommand{\tfans}{m}{(#1)} %参考答案的判断题输出
\NewDocumentCommand {\torf} { o }{
\IfNoValueTF {#1}
{\tfblank}
{
\ifprintanswers
\tfans{#1}
\else
\tfblank
\fi
}
}
%%% 选择题右对齐的括号
\newlength\mylen
\settowidth\mylen{\qquad}
\NewDocumentCommand{\chblank}{}{\hfill (\qquad)}
\NewDocumentCommand{\chans}{m}{\hfill (\makebox[\mylen]{#1})}
\NewDocumentCommand {\chABCD} { o }{
\IfNoValueTF {#1}
{\chblank}
{
\ifprintanswers
\chans{#1}
\else
\chblank
\fi
}
}
\ExplSyntaxOff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LaTeX3部分结束
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LaTeX3部分结束
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LaTeX3部分结束
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LaTeX3部分结束
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LaTeX3部分结束
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LaTeX3部分结束
% 表,分,页等中文个性化输出
\renewcommand{\tablename}{表}
\pointname{分}
\renewcommand{\thepartno}{\Roman{partno}}
\cfoot{第\thepage~页~,~共\numpages~页}
\renewcommand{\solutiontitle}{\noindent\textbf{解:}\noindent}
\newcommand{\cdotfill}{\leavevmode\xleaders\hbox to 0.5em{\hss$\cdot$\hss}\hfill\kern0pt\relax}
% 显示分数
\newcommand{\myscore}[1]{\textcolor{blue}{#1\kern0.2em 分}}
% 非数学环境使用此文本环境输出评分标准
\newcommand{\scoretext}[1]{\cdotfill\myscore{#1}\par\noindent\ignorespaces }
% 数学环境使用此输出评分标准
\newcommand{\scoreeqno}[1]{\eqno{\cdots\cdots\text{\myscore{#1}}}}
\newcommand{\scoretag}[1]{\tag*{$\cdots\cdots$\myscore{#1}}}
\newrobustcmd{\score}[1]{%
\ifbool{mmode}{%
\ifdefstrequal{\tag}{\dft@tag}{\scoreeqno{#1}}{\scoretag{#1}}%
}{%
\scoretext{#1}%
}%
}
% 判断题的答案输出(exam包自带的方式,以修改为上面的。)
\newcommand{\tf}[1][{}]{%
\fillin[#1][0.25in]%
}
% 定义输出大小写罗马数字的命令
\newcommand{\rmnum}[1]{\romannumeral #1}
\newcommand{\Rmnum}[1]{\expandafter\@slowromancap\romannumeral #1@}
% 重定义勾叉符号
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
% 答案显示相关
\shadedsolutions %设置答案显示在阴影区域
\definecolor{SolutionColor}{rgb}{0.8,0.9,1} % 设置阴影的颜色
% |v|,绝对值 ,范数等符号(利用mathtools宏包构造)
\DeclarePairedDelimiter\abs{\lvert}{\rvert}
%\DeclarePairedDelimiter\norm{\lVert}{\rVert}
\DeclarePairedDelimiterX\norm[1]\lVert\rVert{
\ifblank{#1}{\:\cdot\:}{#1}
}
\DeclarePairedDelimiterX\innerp[2]{\langle}{\rangle}{#1,#2}
% 定义数学符号
\DeclareMathOperator{\Pro}{Pro}
\DeclareMathOperator{\Corr}{\rho}
\DeclareMathOperator{\Cov}{Cov}
\DeclareMathOperator{\grad}{grad}
\DeclareMathOperator{\Prj}{Prj}
\DeclareMathOperator{\Var}{Var}
% 向量相关的简写命令(参考自jnu)
\newcommand{\va}{\vec{a}}
\newcommand{\vb}{\vec{b}}
\newcommand{\vc}{\vec{c}}
\newcommand{\vd}{\vec{d}}
\newcommand{\ve}{\vec{e}}
\newcommand{\vi}{\vec{i}}
\newcommand{\vj}{\vec{j}}
\newcommand{\vk}{\vec{k}}
\newcommand{\vn}{\vec{n}}
\newcommand{\vs}{\vec{s}}
\newcommand{\vv}{\vec{v}}
\newcommand\vect[1]{\bm{#1}}
\let\ov=\overrightarrow
% 三角形三条边上添加箭头
\usetikzlibrary {decorations.markings}
\usetikzlibrary{datavisualization.formats.functions}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{intersections,patterns}
\usetikzlibrary{arrows,arrows.meta}
\usetikzlibrary{matrix,decorations.pathmorphing}
\usetikzlibrary{snakes}
\usepgflibrary{shadings}
\usepgfplotslibrary{patchplots}
\pgfplotsset{width=7cm,compat=1.17}
% 最开始输出左边学生需要填写信息的表格
%\lhead{\databox}
% 到最右的下划线
\newcommand{\ulfrule}{\xleaders\hbox{\underline{ }}\hfill\kern0pt}
\newif\ifteacher % starts out false
\newcommand{\fillanswer}[2][\fill]{%
\unskip\ \lhrulefill{#1}%
\ifteacher\makebox[0pt]{#2}\fi
\lhrulefill{#1}\ \ignorespaces{}}
\newcommand{\lhrulefill}[1]{%
\leavevmode
\leaders\hrule height -.3ex depth \dimexpr .3ex+.4pt\relax % define the leader
\hskip\glueexpr#1/2\relax\relax % how much it should extend
\kern0pt
}
% 矩阵放缩
\renewcommand*\env@matrix[1][\arraystretch]{%
\edef\arraystretch{#1}%
\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{*\c@MaxMatrixCols c}}