-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhqugxythesis.dtx
482 lines (439 loc) · 13.6 KB
/
hqugxythesis.dtx
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
% \iffalse meta-comment
% !TeX program = XeLaTeX
% !TeX encoding = UTF-8
%
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any later
% version. The latest version of this license is in:
%
% http://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 Crosstyan.
% \fi
% \iffalse
% <package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
% <package>\ProvidesPackage{hqugxythesis}
% <package>[Crosstyan]
%<*driver>
\ProvidesFile{hqugxythesis.dtx}[2022/5/10]
\documentclass[11pt]{ltxdoc}
\usepackage{hyperref}
\usepackage{xeCJK}
\usepackage{listings}
\lstset{basicstyle=\ttfamily}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
% \GetFileInfo{\jobname.dtx}
%
% \DoNotIndex{\begin,\end,\begingroup,\endgroup}
% \DoNotIndex{\ifx,\ifdim,\ifnum,\ifcase,\else,\or,\fi}
% \DoNotIndex{\let,\def,\xdef,\newcommand,\renewcommand}
% \DoNotIndex{\expandafter,\csname,\endcsname,\relax,\protect}
% \DoNotIndex{\Huge,\huge,\LARGE,\Large,\large,\normalsize}
% \DoNotIndex{\small,\footnotesize,\scriptsize,\tiny}
% \DoNotIndex{\normalfont,\bfseries,\slshape,\interlinepenalty}
% \DoNotIndex{\hfil,\par,\hskip,\vskip,\vspace,\quad}
% \DoNotIndex{\centering,\raggedright}
% \DoNotIndex{\c@secnumdepth,\@startsection,\@setfontsize}
% \DoNotIndex{\ ,\@plus,\@minus,\p@,\z@,\@m,\@M,\@ne,\m@ne}
% \DoNotIndex{\@@par,\DeclareOperation,\RequirePackage,\LoadClass}
% \DoNotIndex{\AtBeginDocument,\AtEndDocument}
%
% \thispagestyle{empty}
% 该文档为对 \href{https://github.com/liubenyuan/nudtpaper/blob/master/nudtpaper.dtx}{liubenyuan/nudtpaper}
% 与 \href{https://github.com/tuna/thuthesis/blob/master/thuthesis.dtx}{tuna/thuthesis} 的改写/抄袭.
%
% \begin{enumerate}
% \item 本模板的发布遵守 \LaTeX{} Project Public License,使用前请认真阅读协议内容
% \item 任何由于使用本模板而引起的论文格式审查问题均与本模板作者无关。
% \item 任何个人或组织均可以本模板为基础进行修改、扩展,生成新的专用模板,但请严格遵
% 守\LaTeX{} Project Public License 协议
% \item 欢迎提出修改意见
% \end{enumerate}
% \section{使用该模板}
% 用 biber 作为 biblatex 的后端. 设文档类为 hqugxythesis
% \begin{macrocode}
%<*thesis>
%BACKEND=biber%
\documentclass{hqugxythesis}
% \end{macrocode}
% 乱文假字包, 实际写作不需要
% \begin{macrocode}
\usepackage{lipsum}
\usepackage{zhlipsum}
% \end{macrocode}
% 定义论文标题, 个人信息等
% \begin{macrocode}
\title{论文标题}
\author{我是谁}
\renewcommand\etitle{English Title} % 英文标题
\renewcommand\eauthor{Whoami} % 英文作者
\renewcommand\studentid{123456789} % 学号
\renewcommand\graduateyear{2022} %毕业年份
\renewcommand\major{信息工程专业}
\renewcommand\emajor{Electrical Engineering}
% \end{macrocode}
% 添加参考文献, 重设页面风格
% \begin{macrocode}
% biber
\addbibresource{refs.bib}
\pagestyle{plain}
% \end{macrocode}
% 导言区结束, 开始正文. 设置开始时的页码编码为
% 大写罗马数字, 设置全局字体
% \begin{macrocode}
\begin{document}
\pagenumbering{Roman}
\xiaosi[1.5]\selectfont
% \end{macrocode}
% 个人信息, 摘要以及关键词. 然后是目录
% \begin{macrocode}
{
\setlength{\parindent}{0em} % 重设段落缩进
\mkchtitle
\begin{cabstract}
\zhlipsum[1-1]
\end{cabstract}
\ckeywords{物联网; 目标识别; clojure; }
\newpage
\mkentitle
\begin{eabstract}
\lipsum[1-1]
\end{eabstract}
\ekeywords{IoT; Object Detection; clojure; }
}
% TOC
\tableofcontents
% \end{macrocode}
% 重设页码计数器, 设页码格式为阿拉伯数字
% \begin{macrocode}
\chapter{绪论}
\pagenumbering{arabic}
\setcounter{page}{1}
\xiaosi[1.5]\selectfont
\section{本课题的的研究目的和意义}
引文\cite{canny_john}
% 写正文...
\section{国内外研究现状}
\zhlipsum
\chapter{总结与展望}
\zhlipsum
% \end{macrocode}
% 参考文献
% \begin{macrocode}
\addcontentsline{toc}{chapter}{参考文献}
\printbibliography[heading=bibliography, title=参考文献]
% \end{macrocode}
% 致谢
% \begin{macrocode}
\begin{ack}
\zhlipsum
\end{ack}
% \end{macrocode}
% 文章结束
% \begin{macrocode}
\end{document}
%</thesis>
% \end{macrocode}
% \subsection{常见问题}
% 没有目录/参考文献? XeLaTeX -> Biber -> XeLaTeX -> XeLaTeX
% 四次编译不可少
% \section{实现细节}
% \subsection{基本信息}
% \begin{macrocode}
%<*cls>
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesClass{hqugxythesis}
% \end{macrocode}
% \subsection{引入基文档库}
%
% 扩展默认的 report.cls 见 \href{https://tex.stackexchange.com/questions/353747/where-can-i-find-the-article-cls-class-file-of-texlive-2016-on-my-pc}{Where can I find the article.cls class file of texlive-2016 on my pc?}.
% 该文件由 \href{http://tug.ctan.org/tex-archive/macros/latex/base/classes.dtx}{classes.dtx} 所生成
% (虽然知道这一点没什么用处就是了.)
% \begin{macrocode}
\LoadClass[scheme=chinese,a4paper]{report}
% \end{macrocode}
% \lstinline{\LoadClass} 在此相当于 \lstinline{\documentclass}
% \subsection{引入自定义库}
% 一大堆玩意, 天知道这些宏包有啥用. 说一些我认识的
% \begin{itemize}
% \item xeCJK 是显示中日文 (CJK) 字符必不可少的
% \item listings 做代码注释. 可以调用 \lstinline{\lstinline} 内联代码/等宽
% \end{itemize}
% \begin{macrocode}
\RequirePackage[utf8]{inputenc}
\RequirePackage{amsmath}
\RequirePackage{esint}
\RequirePackage{tabstackengine}
\RequirePackage[colorlinks,linkcolor=blue]{hyperref}
\RequirePackage{xeCJK}
\RequirePackage{caption}
\RequirePackage{stackengine}
\RequirePackage{graphicx}
\RequirePackage{float}
\RequirePackage{amsmath}
\RequirePackage{ulem}
\RequirePackage{amsfonts}
\RequirePackage{enumitem}
\RequirePackage{listings}
\RequirePackage{setspace}
\RequirePackage{subcaption}
\RequirePackage{ifthen,calc}
% \end{macrocode}
% 参考文献库
% \begin{macrocode}
\RequirePackage[backend=biber,style=gb7714-2015,gbnamefmt=familyahead]{biblatex}
% \end{macrocode}
% 设置列表的间距
% \begin{macrocode}
\setlist[1]{itemsep=-5pt}
% \end{macrocode}
% 设置 \lstinline{listings} 宏包的字体为等宽字体
% \begin{macrocode}
\lstset{basicstyle=\ttfamily}
% \end{macrocode}
% 引入 \lstinline{geometry} 宏包, 设置页边距和页面格式, 详细去看文档或者
% \href{https://github.com/huangxg/lnotes}{雷太赫排版系统简介} 的第11章
% \begin{macrocode}
\RequirePackage{geometry}
\geometry{%
a4paper,%
left=30mm,%
right=30mm,%
headsep=10mm,%
top=30mm,%
bottom=20mm}
% \end{macrocode}
% 设置表格的 padding 以及其 caption 的间距
% \begin{macrocode}
\setlength{\tabcolsep}{0.5em} % for the horizontal padding
\renewcommand{\arraystretch}{1.2}% for the vertical padding
\captionsetup[table]{skip=10pt}
% \end{macrocode}
% \subsection{字体相关}
% 设置字体缩写, 从 nudtpaper 那抄的, 似乎清华的模板也有这一段
% \begin{macrocode}
\newcommand{\cusong}{\bfseries}
\newcommand{\song}{\CJKfamily{song}} % 宋体
\newcommand{\fs}{\CJKfamily{fs}} % 仿宋体
\newcommand{\kai}{\CJKfamily{kai}} % 楷体
\newcommand{\hei}{\CJKfamily{hei}} % 黑体
\def\songti{\song}
\def\fangsong{\fs}
\def\kaishu{\kai}
\def\heiti{\hei}
% \end{macrocode}
% \begin{macro}{\thu@def@fontsize}
% 根据习惯定义字号。用法:
%
% \cs{thu@def@fontsize}\marg{字号名称}\marg{磅数}
% ``避免了字号选择和行距的紧耦合。所有字号定义时为单倍行距,并提供选项指定行距倍数。"
% \begin{macrocode}
\def\thu@def@fontsize#1#2{%
\expandafter\newcommand\csname #1\endcsname[1][1.3]{%
\fontsize{#2}{##1\dimexpr #2}\selectfont}}
% \end{macrocode}
% \end{macro}
% 从清华那抄的
% \begin{macrocode}
\thu@def@fontsize{chuhao}{42bp}
\thu@def@fontsize{xiaochu}{36bp}
\thu@def@fontsize{yihao}{26bp}
\thu@def@fontsize{xiaoyi}{24bp}
\thu@def@fontsize{erhao}{22bp}
\thu@def@fontsize{xiaoer}{18bp}
\thu@def@fontsize{sanhao}{16bp}
\thu@def@fontsize{xiaosan}{15bp}
\thu@def@fontsize{sihao}{14bp}
\thu@def@fontsize{xiaosi}{12bp}
\thu@def@fontsize{wuhao}{10.5bp}
\thu@def@fontsize{xiaowu}{9bp}
\thu@def@fontsize{liuhao}{7.5bp}
\thu@def@fontsize{xiaoliu}{6.5bp}
\thu@def@fontsize{qihao}{5.5bp}
\thu@def@fontsize{bahao}{5bp}
% \end{macrocode}
% 中文缩进两个汉字位
% \begin{macrocode}
\makeatletter
\let\@afterindentfalse\@afterindenttrue
\@afterindenttrue
\makeatother
\setlength{\parindent}{2em}
% \end{macrocode}
% 章节等重定义
% \begin{macrocode}
\renewcommand{\contentsname}{目录}
\renewcommand{\abstractname}{摘要}
\renewcommand{\refname}{参考文献}
\renewcommand{\bibname}{参考文献}
\renewcommand{\indexname}{索引}
\renewcommand{\figurename}{图}
\renewcommand{\tablename}{表}
\renewcommand{\appendixname}{附录}
% \end{macrocode}
% \begin{macro}{\ack}
% 自定义的 Acknowledgement 环境
% \begin{macrocode}
\newenvironment{ack}{%
\chapter*{致\hspace{1em}谢}%
\addcontentsline{toc}{chapter}{致谢}%
\markboth{致谢}{}}
{\par\vspace{2em}\par}
% \end{macrocode}
% \end{macro}
% 让我们多引几个包吧, 调库多爽. 其中
% \begin{itemize}
% \item \lstinline{titlesec} 是格式化标题的宏包
% \item \lstinline{titletoc} 则是格式化目录的宏包
% \item \lstinline{fancyhdr} 设置页眉和页脚
% \end{itemize}
% \begin{macrocode}
\RequirePackage{mathrsfs}
\RequirePackage{fancyhdr}
\RequirePackage{tabularx}
\RequirePackage{titlesec}
\RequirePackage{titletoc}
\RequirePackage{titling}
% \end{macrocode}
% 重新定义标题格式
% \begin{macrocode}
\titleformat{\chapter}{\filcenter\sf \heiti\sihao}{第 \thechapter 章}{1em}{}
\titleformat{\section}{\sf \heiti\sihao[1.25]}{\thesection}{1em}{}
\titleformat{\subsection}{\sf \heiti\xiaosi[1.25]}{\thesubsection}{1em}{}
\titleformat{\subsubsection}{\sf \heiti\xiaosi[1.25]}{\thesubsubsection}{1em}{}
% \end{macrocode}
% 定义章节间距, 需要负的章前段间距
% \begin{macrocode}
\titlespacing*{\chapter}{0pt}{-4ex}{2.4ex}
% \end{macrocode}
% 重新定义目录章节格式
% \begin{macrocode}
\titlecontents{chapter}[0pt]{\vspace{0.25\baselineskip} \heiti \xiaosi[1.25]}
{第 \thecontentslabel 章\quad}{}
{\hspace{.5em}\titlerule*{.}\contentspage}
\titlecontents{section}[2em]{\songti \xiaosi[1.25]}
{\thecontentslabel\quad}{}
{\hspace{.5em}\titlerule*{.}\contentspage}
\titlecontents{subsection}[4em]{\songti \xiaosi[1.25]}
{\thecontentslabel\quad}{}
{\hspace{.5em}\titlerule*{.}\contentspage}
% \end{macrocode}
% 设置页眉页脚
% \begin{macrocode}
\fancypagestyle{plain}{%
\fancyhf{}
\fancyhead[C]{%
\wuhao
\leftmark
}%
\fancyfoot[C]{
\xiaowu
\thepage
}%
\renewcommand\headrulewidth{0.75bp}%
}
% \end{macrocode}
% 设置页眉章节
% \begin{macrocode}
\renewcommand{\chaptermark}[1]{\markboth{
\wuhao
第 \thechapter 章 \quad #1
}{}}
% \end{macrocode}
% \subsection{信息设置}
% 一些个人信息, 你可以在正文中用 \lstinline{\newcommand} 覆写
% \begin{macrocode}
\title{论文标题}
\author{论文作者}
\providecommand\etitle{English Title} % 英文标题
\providecommand\eauthor{Whoami} % 英文作者
\providecommand\studentid{123456789} % 学号
\providecommand\graduateyear{2022} %毕业年份
\providecommand\major{信息工程专业}
\providecommand\emajor{Electrical Engineering}
% \end{macrocode}
% \begin{macro}{\mkchtitle}
% 中文标题
% \begin{macrocode}
\newcommand{\mkchtitle}{
\begin{center}
\setstretch{1.6}
\sanhao\textsf{\thetitle} \\
\sihao 华侨大学工学院 \\
\major \graduateyear \space \theauthor \space \studentid
\end{center}
\par\vspace{2em}\par}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\mkentitle}
% 英文标题
% \begin{macrocode}
\newcommand{\mkentitle}{
\begin{center}
\setstretch{1}
\sihao\textbf{\textsf{\etitle}} \\
\setstretch{1.2}
\xiaosi \eauthor \\
\studentid, \emajor, \graduateyear\\
College of Engineering, Huaqiao University \\
\end{center}
\par\vspace{2em}\par}
% \end{macrocode}
% \end{macro}
% \subsection{摘要设置}
% 一些辅助命令, 从 nudtpaper 那抄的
% \begin{macrocode}
\newcommand\cabstractname{摘要}
\newcommand\eabstractname{Abstract}
\newcommand\ckeywordsname{关键词}
\newcommand\ekeywordsname{Key Words}
% \end{macrocode}
% \begin{macro}{\cabstract}
% 英文摘要
% \begin{macrocode}
\newenvironment{eabstract}{%
\setlength{\parindent}{0em}
\markboth{华侨大学工学院毕业设计 \theauthor: \thetitle}{}
\textbf{\sihao \eabstractname \space}
\xiaosi
}{\par\vspace{2em}\par}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ekeywords}
% 英文关键词
% \begin{macrocode}
\newcommand\ekeywords[1]{\textbf{\textsf{\xiaosi \ekeywordsname:}} #1}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\cabstract}
% 中文摘要
% \begin{macrocode}
\newenvironment{cabstract}{%
\setlength{\parindent}{0em}
\markboth{华侨大学工学院毕业设计 \theauthor: \thetitle}{}
\textsf{\sihao \cabstractname \space}
\xiaosi
}{\par\vspace{2em}\par}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ckeywords}
% 中文关键词
% \begin{macrocode}
\newcommand\ckeywords[1]{{\textsf{\xiaosi \ckeywordsname:} #1}}
%</cls>
% \end{macrocode}
% \end{macro}