-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcauthesis.cls
346 lines (346 loc) · 13 KB
/
cauthesis.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
%% cauthesis.cls
%% Copyright 2018 阎彧萱
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% https://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainer of this work is 阎彧萱.
%%
%% This work consists of the file cauthesis.cls
%% and the derived files:
%% Logo.jpg
%% CAU_Course_Thesis_Template.tex
%% CAU_Course_Thesis_Template.pdf
%% gb7714-2015.bbx
%% 中国农业大学课程论文写作格式.doc
%% ---------------------------------------------------------------------------
%% Class Name : cauthesis
%% Description : China Agricultural University Course Thesis LaTeX Template
%% Repository : https://github.com/Cdmium/CAUTemplate
%% Version : 1.2
%% Copyright : 2018 阎彧萱
%% E-mail : [email protected]
%% License : LaTeX Project Public License v1.3c or later
%% License URI : https://www.latex-project.org/lppl.txt
%% Files : cauthesis.cls
%% Logo.jpg
%% CAU_Course_Thesis_Template.tex
%% CAU_Course_Thesis_Template.pdf
%% 中国农业大学课程论文写作格式.doc
%% ---------------------------------------------------------------------------
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{cauthesis}%
[2018/12/24 v1.2 China Agricultural University Course Thesis LaTeX Template]
\newif\if@oneside\@onesidefalse
\newif\if@twoside\@twosidefalse
\newif\if@clearaftp\@clearaftpfalse
\newif\if@maketable\@maketablefalse
\DeclareOption{oneside}{%
\@onesidetrue%
}
\DeclareOption{twoside}{%
\@twosidetrue%
}
\DeclareOption{maketable}{%
\@maketabletrue%
}
\DeclareOption*{%
\ClassWarning{cauthesis}%
{Unknown option `\CurrentOption'}%
}
\ProcessOptions\relax
\if@oneside%
\if@twoside%
\@clearaftpfalse%
\ClassWarning{You can only choose one of the oneside and twoside options.%
Automatically set to oneside.}%
\fi%
\else%
\if@twoside%
\@clearaftptrue%
\fi%
\fi%
\LoadClass[a4paper]{article}%加载article类型
%% ---------------------------------------------------------------------------
%页面布局调节
\RequirePackage{geometry}
\geometry{left=2.5cm,right=2.5cm,top=3.5cm,bottom=2.5cm,footskip=0.8cm}
\pagestyle{plain}
\linespread{1.25}\selectfont
%% ---------------------------------------------------------------------------
\RequirePackage{graphicx}%图片插入
\RequirePackage[section]{placeins}
\def\@captype{figure}
%% ---------------------------------------------------------------------------
\RequirePackage{etoolbox}%编程辅助
\RequirePackage{ifthen}%编程辅助
\RequirePackage[normalem]{ulem}%下划线
\RequirePackage{array}%数学
%% ---------------------------------------------------------------------------
%书签功能,选项去掉链接红色方框,
\RequirePackage[CJKbookmarks,%
%debug=true,%
colorlinks=true,%
bookmarksnumbered=true,%
pdfstartview=FitH,%
linkcolor=magenta,%
anchorcolor=magenta,%
citecolor=magenta,%
linkcolor=black,]{hyperref}
%linkcolor=green,blue,red,cyan, magenta,
%yellow, black, gray,white, darkgray, lightgray, brown,
%lime, olive, orange, red,purple, teal, violet.
%下面这两句保证多篇文章一起排时的超链接正确性
\newcounter{Hsection}
\preto\section{\stepcounter{Hsection}}
\RequirePackage{titleref} %标题引用
%% ---------------------------------------------------------------------------
%英文字体控制
\RequirePackage{fontspec}
\setmainfont{Noto Serif}
%% ---------------------------------------------------------------------------
%中文环境
%中文字体控制
\RequirePackage[zihao=-4]{ctex}
\RequirePackage{xeCJKfntef}
\setCJKmainfont[BoldFont={Noto Sans CJK SC},ItalicFont={方正仿宋}]{Noto Serif CJK SC}
\setCJKsansfont{Noto Sans Serif CJK SC}
\setCJKmonofont{方正仿宋}
\setCJKfamilyfont{zhli}{方正隶书简体}
\setCJKfamilyfont{zhboldsong}{NotoSerifCJK-Bold.ttc}
%% ---------------------------------------------------------------------------
%章节标题格式
\RequirePackage{titlesec}
\renewcommand{\contentsname}{\centerline{目\hspace{2em}录}}%目录居中
\titleformat{\section}{\linespread{1.5}\selectfont\bfseries\zihao{-3}}{\thesection\hspace{1em}}{0pt}{}
\titlespacing*{\section}{0pt}{*1}{11pt}
\titleformat{\subsection}{\linespread{1.5}\selectfont\bfseries\zihao{4}}{\thesubsection\hspace{1em}}{0pt}{}
\titlespacing*{\subsection}{0pt}{*1.5}{*1}
\titleformat{\subsubsection}{\linespread{1.5}\selectfont\bfseries\zihao{-4}}{\thesubsubsection\hspace{1em}}{0pt}{}
\titlespacing*{\subsubsection}{0pt}{*1.5}{*1}
%% ---------------------------------------------------------------------------
%无编号section
\newcommand{\specialsection}[1]{%
\makeatletter\setcounter{secnumdepth}{-2}\makeatother
\phantomsection
\section{#1}
\makeatletter\setcounter{secnumdepth}{3}\makeatother}
%% ---------------------------------------------------------------------------
%数学
\RequirePackage{bbding,pifont} %特殊字体,参考latexfriend
\RequirePackage{xltxtra} %用于输出tex的特殊文本格式,以及上下标的字符
\RequirePackage{mflogo,texnames}%用于输出tex的特殊文本格式,texnames的说明文档没有找到
\RequirePackage{amsmath}%使用宏包{美国数学协会数学},有个功能可以将章节和方程号联系起来。
\RequirePackage{amssymb} %使用宏包{美国数学协会符号}
\RequirePackage{mathrsfs}%数学字体
%% ---------------------------------------------------------------------------
%绘图和绘制统计图
\RequirePackage{metalogo}
\RequirePackage{xcolor}
\RequirePackage{pgf,tikz}
%\RequirePackage{pgfplots}
%\RequirePackage{pgfplotstable}
%\pgfplotsset{compat=newest}
%\usepgfmodule{shapes}
%\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri}
%\usetikzlibrary{math,mindmap,shapes.geometric,calc,intersections,through}
%\usetikzlibrary{knots}
%% ---------------------------------------------------------------------------
%表格
\RequirePackage{float}
\RequirePackage{multirow} %for excel2latex
\RequirePackage{booktabs} %for excel2latex
%\RequirePackage{longtable} %注意longtable无法在multicol中使用
\RequirePackage{supertabular} %使用supertabular来实现可以跨页的表格
\RequirePackage{tabularx}
\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
%% ---------------------------------------------------------------------------
%图表
\RequirePackage{subfigure}
\RequirePackage{ccaption}
\captiondelim{~} %图序图题中间的间隔符号
\captionnamefont{\zihao{-5}\heiti} %图序样式
\captiontitlefont{\zihao{-5}\heiti} %图题样式
\captionwidth{0.8\linewidth} %标题宽度
\changecaptionwidth
%\captionstyle{<style>} can be used to alter this. Sensible values for
%style are: \centering, \raggedleft or \raggedright
\captionstyle{\centering}
%\precaption{\rule{\linewidth}{0.4pt}\par}
%\postcaption{\rule[0.5\baselineskip]{\linewidth}{0.4pt}}
\setlength{\belowcaptionskip}{0.1cm} %设置caption上下间距
\setlength{\abovecaptionskip}{0.1cm}
\setlength{\abovelegendskip}{0.1cm} %设置legend上下间距
\setlength{\belowlegendskip}{0.1cm}
%注意用中文的图题时,用\\好像出错,而用\newline就没有问题
%浮动体外使用标题,使用\tabcaptionfix命令产生在浮动体外
%与table中默认的caption一致的标题效果
\newfixedcaption{\tabcaption}{table}
\newfixedcaption{\figcaption}{figure}
%\newfixedcaption{\tabcaptionfix}{table}
%% ---------------------------------------------------------------------------
%参考文献
\RequirePackage{url}
\RequirePackage[backend=biber,%
style=gb7714-2015]{biblatex}%biber
\renewcommand{\bibfont}{\zihao{-5}\songti}
\newcommand{\bibname}{参考文献}
\setlength{\bibitemsep}{2pt}
\defbibheading{bibliography}[\bibname]{%
\specialsection{#1}}%
%% ---------------------------------------------------------------------------
%分层次enumerate
\RequirePackage{enumitem}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{%
\node[shape=circle,draw,inner sep=1pt] (char) {#1};}}
\newenvironment{level}[1]{%
\ifnumequal{#1}{2}{%
\begin{enumerate}[label=\protect\circled{\arabic*}]%
}{%
\ifnumequal{#1}{1}{}{\ClassWarning{cauthesis}{Invalid argument. Treated as one.}}%
\begin{enumerate}[label=(\arabic*)]%
}%
}{%
\end{enumerate}%
}
%% ---------------------------------------------------------------------------
%封面
\newcommand{\@schoolyear}{20\hspace{1em}-20\hspace{1em}}
\newcommand{\schoolyear}[1]{\renewcommand{\@schoolyear}{#1}}
\newcommand{\@semester}{\hspace{1em}}
\newcommand{\semester}[1]{\renewcommand{\@semester}{#1}}
\DeclareListParser*{\forcsvlista}{;}
\def\tpitem#1{\def\tpitemlist{}%
\forcsvlista{\listadd\tpitemlist}{#1}}
\def\zhkeywords#1{\def\zhkeywordslist{}%
\forcsvlista{\listadd\zhkeywordslist}{#1}}
\def\enkeywords#1{\def\enkeywordslist{}%
\forcsvlista{\listadd\enkeywordslist}{#1}}
\newlength{\@maxlen}
\newlength{\@temporary}
\newcounter{cycling}
\newcounter{exlcyc}
\deflength{\@maxlen}{0pt}
%% ---------------------------------------------------------------------------
%摘要
\newcommand{\@zhabstract}{}
\newcommand{\zhabstract}[1]{\renewcommand{\@zhabstract}{#1}}
\newcommand{\@enabstract}{}
\newcommand{\enabstract}[1]{\renewcommand{\@enabstract}{#1}}
%% ---------------------------------------------------------------------------
%生成封面
\AtBeginDocument{%
\begin{titlepage}%
\pagestyle{empty}%
\begin{flushleft}%
\includegraphics[width=3.18cm,height=2.41cm]{./Picture/Logo.jpg}%
\end{flushleft}%
\centering%
\begin{tabularx}{\textwidth}{@{}Y@{}c@{}X@{}}%
& \begin{minipage}[t]{0.75\textwidth}%
\CJKfamily{zhli}%
\begin{center}%
\linespread{1}\selectfont%
\zihao{0}中国农业大学\par{}课程论文\par%
\zihao{1}(\textrm{\@schoolyear}学年\@semester{}季学期)\par%
\end{center}%
\vspace{66pt}%1%
\zihao{-2}%
\CJKfamily{zhboldsong}%
\defcounter{cycling}{0}%
\renewcommand*{\do}[1]{%
\stepcounter{cycling}%
\ifnumequal{\value{cycling}}{1}{\settowidth{\@temporary}{#1}%
\ifdimgreater{\@temporary}{\@maxlen}{\deflength{\@maxlen}{\@temporary}}{}}{%
\ifnumequal{\value{cycling}}{3}{\defcounter{cycling}{0}}{%
\ifnumgreater{#1}{0}{\defcounter{cycling}{0}}{}}}}%
\dolistloop{\tpitemlist}%
\centering%
\begin{minipage}[t]{0.75\textwidth}%
\centering%
\linespread{1.75}\selectfont%2%
\defcounter{cycling}{0}%
\renewcommand*{\do}[1]{\stepcounter{cycling}\ifnumequal{\value{cycling}}{1}{\makebox[\@maxlen][s]{#1}:}{%
\ifnumequal{\value{cycling}}{3}{\uline{#1\hfill}\par\defcounter{cycling}{0}}{%
\ifnumgreater{#1}{0}{\defcounter{exlcyc}{0}%
\whiledo{\value{exlcyc}<#1}{%
\uline{\hfill}\par\stepcounter{exlcyc}}\defcounter{cycling}{0}}{}}}}%
\dolistloop{\tpitemlist}%
\end{minipage}%
\end{minipage} %
& \begin{minipage}[t]{0.15\textwidth}%
\vspace{-0.5cm}%
\linespread{1.5}\selectfont%
\begin{tabular}[t]{|p{2.1cm}<{\centering}|}%
\hline%
\zihao{-4}\CJKfamily{zhboldsong} 成绩 \\%
\hline%
\zihao{-4} \\\hline%
\end{tabular}%
\renewcommand{\arraystretch}{1}%
\end{minipage} \\%
\end{tabularx}%
\end{titlepage}%
\pagebreak%
\if@clearaftp%
\pagestyle{empty}%
\cleardoublepage%
\fi%
%% ---------------------------------------------------------------------------
%生成摘要
\renewcommand\arraystretch{1}%
\setcounter{page}{1}%
\pagenumbering{Roman}%
\maketitle%
\ifdefempty{\@zhabstract}{\ClassWarning{cauthesis}{Empty Zhabstract.}}{%
\phantomsection%
\addcontentsline{toc}{section}{摘要}%
\begin{center}%
\linespread{1.5}\selectfont%
\zihao{-3}\textbf{摘\hspace{2em}要}%
\vspace{11pt}%
\end{center}%
\linespread{1.25}\selectfont%
\setlength{\parindent}{2em}%
\par\@zhabstract\\%
\newline%
\ifdefvoid{\zhkeywordslist}{\ClassWarning{cauthesis}{Empty Enkeywords.}}{%
\noindent%
\textbf{关键词:}%
\renewcommand*{\do}[1]{\textbf{#1};}%
\dolistloop{\zhkeywordslist}\par}}%
\ifdefempty{\@enabstract}{\ClassWarning{cauthesis}{Empty Enabstract.}}{%
\phantomsection%
\addcontentsline{toc}{section}{ABSTRACT}%
\begin{center}%
\linespread{1.5}\selectfont%
\zihao{-3}\textbf{ABSTRACT}%
\vspace{11pt}%
\end{center}%
\linespread{1.25}\selectfont%
\setlength{\parindent}{2em}%
\par\@enabstract\\%
\newline%
\ifdefvoid{\enkeywordslist}{\ClassWarning{cauthesis}{Empty Enkeywords.}}{%
\noindent%
\textbf{Key Words: }%
\renewcommand*{\do}[1]{\textbf{#1}; }%
\dolistloop{\enkeywordslist}\par}}%
\clearpage%
\if@maketable%
\tableofcontents%
\fi%
\clearpage%
\setcounter{page}{1}%
\pagestyle{plain}%
\pagenumbering{arabic}%
}
%% ---------------------------------------------------------------------------