-
Notifications
You must be signed in to change notification settings - Fork 0
/
bnuthesis.cls
1074 lines (860 loc) · 30.7 KB
/
bnuthesis.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
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% Copyright (C) 2010-2012 by Gerry
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3a
% 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
%
% Modified by Jinyi Liu 2019/4/11
% 基本信息
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesClass{bnuthesis}
[2014/3/12 1.52 Beijing Normal University Thesis Template]
% 定义文档所使用编码
\newif\ifbnu@UTF
\newif\ifbnu@GBK
\DeclareOption{utf}{\bnu@UTFtrue\bnu@GBKfalse}
\DeclareOption{gbk}{\bnu@GBKtrue\bnu@UTFfalse}
% 定义论文类型是否涉密
\hyphenation{bnu-Thesis}
\def\bnuthesis{\textsc{BNUThesis}}
\def\version{1.51}
\newif\ifbnu@bachelor\bnu@bachelorfalse
\newif\ifbnu@secret\bnu@secretfalse
\newif\ifbnu@twoside\bnu@twosidefalse
\DeclareOption{bachelor}{\bnu@bachelortrue}
\DeclareOption{secret}{\bnu@secrettrue}
\DeclareOption{twoside}{\bnu@twosidetrue}
% 使用 dvips, dvipdfm, pdflatex 还是 xelatex
\newif\ifbnu@dvips
\newif\ifbnu@dvipdfm
\newif\ifbnu@xetex
\newif\ifbnu@pdftex
\DeclareOption{dvips}{\bnu@dvipstrue}
\DeclareOption{dvipdfm}{\bnu@dvipdfmtrue}
\DeclareOption{pdftex}{\bnu@pdftextrue}
\DeclareOption{xetex}{\bnu@xetextrue}
% 如果需要使用 arial 字体,请打开 [arial] 选项
\newif\ifbnu@arial
\DeclareOption{arial}{\bnu@arialtrue} % 目录中是否使用 arial 字体
\newif\ifbnu@arialtoc
\DeclareOption{arialtoc}{\bnu@arialtoctrue} % 章节标题中是否使用 arial 字体
\newif\ifbnu@arialtitle
\DeclareOption{arialtitle}{\bnu@arialtitletrue}
% 将选项传递给 book 类
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}}
\ExecuteOptions{utf,arialtitle}
\ProcessOptions\relax
\LoadClass[12pt, a4paper, openany]{book}
% 指定论文类型为学士论文
\ifbnu@bachelor\relax\else\fi
% 检查用户指定的选项和实际编译命令是否冲突
\RequirePackage{ifpdf, ifxetex}
\ifbnu@xetex\RequireXeTeX\fi
\def\RequirePDFTeX{
\ifpdf\else
\ClassError{bnuthesis}
{pdflatex is required to compile this document!}{}
\fi}
\ifbnu@pdftex\RequirePDFTeX\fi
\def\bnu@checkoption#1#2{
\@for\reserved@a:=#2\do{
\csname ifbnu@\reserved@a\endcsname
\ClassError{bnuthesis}
{Please remove `\reserved@a' option when you run #1.}{}
\fi}}
\ifpdf\bnu@checkoption{pdflatex}{dvips,dvipdfm,xetex}\bnu@pdftextrue\fi
\ifxetex\bnu@checkoption{xelatex}{dvips,dvipdfm,pdftex}\bnu@xetextrue\fi
% 装载宏包
\RequirePackage{ifthen, calc} % 引用宏包和相应的定义
\RequirePackage{amsmath, amssymb, amsfonts} % AMS-TEX 宏包,用来排出更漂亮的公式
\RequirePackage{txfonts} % 用很爽的 txfonts 替换 mathptmx 宏包
\RequirePackage{graphicx} % 图形支持宏包
\RequirePackage{titletoc} %
\RequirePackage[config]{subfig} % 并排图形
\RequirePackage{indentfirst} % 首行缩进
\RequirePackage[neverdecrease]{paralist} % 更好的列表环境
% 中文支持宏包
\ifbnu@xetex
\RequirePackage{xltxtra, xunicode}
\RequirePackage[BoldFont]{xeCJK}
\RequirePackage{CJKnumb}
% 全角标点符号
\punctstyle{quanjiao}
\def\CJK@null{\kern\CJKnullspace\hskip \f@size \p@\kern\CJKnullspace}
\defaultfontfeatures{Mapping=tex-text}
% Macbook 字体设置
\newcommand*{\fontsong}{SimSun} % 宋体
\newcommand*{\fonthei}{SimHei} % 黑体
\newcommand*{\fontkai}{KaiTi} % 楷体
\newcommand*{\fontfs}{FangSong} % 仿宋
\newcommand*{\fontli}{LiSu} % 隶书
\newcommand*{\fontyou}{YouYuan} % 幼圆
\setCJKmainfont[Path=fonts/, AutoFakeBold = {2.5}, ItalicFont = simkai.ttf]{simsun.ttc} % 主要字体
\setCJKsansfont[Path=fonts/, AutoFakeBold = {3}]{simhei.ttf} % 无衬线字体
\setCJKmonofont[Path=fonts/]{simkai.ttf} % 等宽字体
\setCJKfamilyfont{song}[Path=fonts/, AutoFakeBold = {2.5}]{simsun.ttc}
\setCJKfamilyfont{hei}[Path=fonts/, AutoFakeBold = {3}]{simhei.ttf}
\setCJKfamilyfont{kai}[Path=fonts/]{simkai.ttf}
\setCJKfamilyfont{fs}[Path=fonts/]{simfang.ttf}
\setCJKfamilyfont{li}[Path=fonts/]{simli.ttf}
\setCJKfamilyfont{you}[Path=fonts/]{simyou.ttf}
\setmainfont{Times New Roman}
\setsansfont{Arial}
\setmonofont{Courier New}
\else
\RequirePackage{CJKutf8}
\RequirePackage{CJKnumb}
\ifbnu@GBK
\IfFileExists{CJKpunct.sty}{\RequirePackage{CJKpunct}}
{\ClassWarning{bnuthesis}{no CJKpunct.sty availiable!}}\fi
\RequirePackage{CJKspace}
\ifbnu@arial
\IfFileExists{arial.sty}
{\RequirePackage{arial}}
{\ClassWarning{bnuthesis}{no arial.sty availiable!}}\fi
\fi
% 定义类环境宏包
\RequirePackage[amsmath, thmmarks, hyperref]{ntheorem} % amsmath 用来兼容 ams-tex 宏包
\RequirePackage{array, longtable} % 表格控制
\RequirePackage{booktabs} % 三线表
\RequirePackage[numbers,super,sort&compress]{natbib} % 参考文献引用宏包
% 生成有书签的 pdf 及其开关,请结合 gbk2uni 避免书签乱码
\RequirePackage{hyperref}
\ifxetex
\hypersetup{
CJKbookmarks=true}
\else
\hypersetup{
unicode=true,
CJKbookmarks=false}\fi
\hypersetup{
bookmarksnumbered=true,
bookmarksopen=true,
bookmarksopenlevel=1,
breaklinks=true,
colorlinks=false,
plainpages=false,
pdfborder=0 0 0}
\ifbnu@dvips\RequirePackage{breakurl}\fi % dvips 格式下网址断字有问题,加入这个包解决
\urlstyle{same} % 设置 URL 样式
\RequirePackage{hypernat} % hypernat 让 hyperref 和 natbib 协调的工作
% 双面开关
\newcommand{\clpage}{\ifbnu@twoside\cleardoublepage\else\clearpage\fi}
\renewcommand\frontmatter{
\clpage
\@mainmatterfalse
\pagenumbering{Roman}
\pagestyle{bnu@empty}}
\renewcommand\mainmatter{
\clpage
\@mainmattertrue
\pagenumbering{arabic}
\pagestyle{bnu@plain}}
\renewcommand\backmatter{
\clpage
\@mainmattertrue}
% 重定义字体命令
\newcommand{\song}{\CJKfamily{song}} % 宋体
\def\songti{\song}
\newcommand{\fs}{\CJKfamily{fs}} % 仿宋
\def\fangsong{\fs}
\newcommand{\kai}{\CJKfamily{kai}} % 楷体
\def\kaishu{\kai}
\newcommand{\hei}{\CJKfamily{hei}} % 黑体
\def\heiti{\hei}
\newcommand{\li}{\CJKfamily{li}} % 隶书
\def\lishu{\li}
\newcommand{\you}{\CJKfamily{you}} % 幼圆
\def\youyuan{\you}
% 避免字号选择和行距的紧耦合。
% 所有字号定义时为单倍行距,并提供制定行距的倍数
\newlength\bnu@linespace
\newcommand{\bnu@choosefont}[2]{%
\setlength{\bnu@linespace}{#2*\real{#1}}\fontsize{#2}{\bnu@linespace}\selectfont}
\def\bnu@define@fontsize#1#2{
\expandafter\newcommand\csname #1\endcsname[1][\baselinestretch]{\bnu@choosefont{##1}{#2}}}
% 定义字号
\bnu@define@fontsize{yuanchu}{48bp}
\bnu@define@fontsize{chuhao}{42bp}
\bnu@define@fontsize{xiaochu}{36bp}
\bnu@define@fontsize{yihao}{26bp}
\bnu@define@fontsize{xiaoyi}{24bp}
\bnu@define@fontsize{erhao}{22bp}
\bnu@define@fontsize{xiaoer}{18bp}
\bnu@define@fontsize{sanhao}{16bp}
\bnu@define@fontsize{xiaosan}{15bp}
\bnu@define@fontsize{sihao}{14bp}
\bnu@define@fontsize{banxiaosi}{13bp}
\bnu@define@fontsize{xiaosi}{12bp}
\bnu@define@fontsize{dawu}{11bp}
\bnu@define@fontsize{wuhao}{10.5bp}
\bnu@define@fontsize{xiaowu}{9bp}
\bnu@define@fontsize{liuhao}{7.5bp}
\bnu@define@fontsize{xiaoliu}{6.5bp}
\bnu@define@fontsize{qihao}{5.5bp}
\bnu@define@fontsize{bahao}{5bp}
% 正文小四号字,行距为固定值 20 磅
\renewcommand\normalsize{%
\@setfontsize\normalsize{12bp}{20bp}
\abovedisplayskip=10bp \@plus 2bp \@minus 2bp
\abovedisplayshortskip=10bp \@plus 2bp \@minus 2bp
\belowdisplayskip=\abovedisplayskip
\belowdisplayshortskip=\abovedisplayshortskip}
% 页面设置
\AtBeginDvi{\special{papersize=\the\paperwidth,\the\paperheight}}
\AtBeginDvi{\special{!%
\@percentchar\@percentchar BeginPaperSize: a4
^^Ja4^^J\@percentchar\@percentchar EndPaperSize}}
% 页边距设置
% 每一页面的上边距和左边距侧(订口)分别留边 25mm
% 下边距和右边距(切口)应分别留边 20mm
\RequirePackage{geometry}
\geometry{left=2.5cm, right=2cm, top=2.5cm, bottom=3.25cm, foot=1.5cm}
\setlength{\hoffset}{-1in} % 清空默认页边距
\ifbnu@twoside
\setlength{\oddsidemargin}{2.5cm} % 奇数页左边距
\setlength{\evensidemargin}{2cm} % 偶数页左边距
\else
\setlength{\oddsidemargin}{2.5cm} % 奇数页左边距
\setlength{\evensidemargin}{\oddsidemargin} % 偶数页左边距
\fi
% 页眉页脚
% 新的一章最好从奇数页开始
\let\bnu@cleardoublepage\cleardoublepage
\newcommand{\bnu@clearemptydoublepage}{%
\clearpage{\pagestyle{empty}\bnu@cleardoublepage}}
\let\cleardoublepage\bnu@clearemptydoublepage
% 定义页眉页脚
\def\ps@bnu@empty{%
\let\@oddhead\@empty%
\let\@evenhead\@empty%
\let\@oddfoot\@empty%
\let\@evenfoot\@empty}
\def\ps@bnu@plain{%
\let\@oddhead\@empty%
\let\@evenhead\@empty%
\def\@oddfoot{\hfil\wuhao\thepage\hfil}%
\let\@evenfoot=\@oddfoot}
\def\ps@bnu@headings{%
\def\@oddhead{\vbox to\headheight{%
\hb@xt@\textwidth{\hfill\wuhao\song\leftmark\hfill}%
\vskip2pt\hbox{\vrule width\textwidth height0.4pt depth0pt}}}
\def\@evenhead{\vbox to\headheight{%
\hb@xt@\textwidth{\wuhao\song%
\hfill\leftmark\hfill}%
\vskip2pt\hbox{\vrule width\textwidth height0.4pt depth0pt}}}
\def\@oddfoot{\hfil\wuhao\thepage\hfil}
\let\@evenfoot=\@oddfoot}
% 其实可以直接写到 \chapter 的定义里面
\renewcommand{\chaptermark}[1]{\@mkboth{\@chapapp\ ~~#1}{}}
% 段落
% 用于中文段落缩进和正文板式
\newlength\CJK@twochars
\ifxetex
\def\CJK@spaceChar{\hskip \f@size \p@}
\else
\ifbnu@UTF
\def\CJK@spaceChar{\CJKchar{"080}{"080}}\fi
\ifbnu@GBK
\def\CJK@spaceChar{\CJKchar{"0A1}{"0A1}}\fi
\fi
\def\CJKindent{%
\settowidth\CJK@twochars{\CJK@spaceChar\CJK@spaceChar}%
\parindent\CJK@twochars}
% 段落之间的垂直距离
\setlength{\parskip}{0pt \@plus2pt \@minus0pt}
% 调整默认列表环境间的距离,以符合中文习惯
\def\bnu@item@space{%
\let\itemize\compactitem
\let\enditemize\endcompactitem
\let\enumerate\compactenum
\let\endenumerate\endcompactenum
\let\description\compactdesc
\let\enddescription\endcompactdesc}
% 脚注
\RequirePackage[perpage]{footmisc}
% 脚注字体:宋体小五,单倍行距,悬挂缩进 1.5 字符
\def\bnu@textcircled#1{%
\ifnum \value{#1} <10 \textcircled{\xiaoliu\arabic{#1}}
\else\ifnum \value{#1} <100 \textcircled{\qihao\arabic{#1}}\fi\fi}
\renewcommand{\thefootnote}{\bnu@textcircled{footnote}}
\renewcommand{\thempfootnote}{\bnu@textcircled{mpfootnote}}
\def\footnoterule{\vskip-3\p@\hrule\@width0.3\textwidth\@height0.4\p@\vskip2.6\p@}
\let\bnu@footnotesize\footnotesize
\renewcommand\footnotesize{\bnu@footnotesize\xiaowu[1.5]}
\def\@makefnmark{\textsuperscript{\hbox{\normalfont\@thefnmark}}}
\long\def\@makefntext#1{
\bgroup
\setbox\@tempboxa\hbox{%
\hb@xt@ 2em{\@thefnmark\hss}}
\leftmargin\wd\@tempboxa
\rightmargin\z@
\linewidth \columnwidth
\advance \linewidth -\leftmargin
\parshape \@ne \leftmargin \linewidth
\footnotesize
\@setpar{{\@@par}}%
\leavevmode
\llap{\box\@tempboxa}%
#1
\par\egroup}
% 数学相关
% 允许太长的共识段行、分页等
\allowdisplaybreaks[4]
\renewcommand\theequation{\ifnum \c@chapter>\z@ \thechapter-\fi\@arabic\c@equation}
% 公式前后文的距离由 4 个参数控制,参见 \normalsize 的定义
% 公式改成 (1-1) 的形式,本科还要在前面加上 "式" 字
\def\make@df@tag{\@ifstar\bnu@make@df@tag@@\make@df@tag@@@}
\def\bnu@make@df@tag@@#1{\gdef\df@tag{\bnu@maketag{#1}\def\@currentlabel{#1}}}
\renewcommand{\eqref}[1]{\textup{(\ref{#1})}}
\renewcommand\theequation{\ifnum \c@chapter>\z@ \thechapter-\fi\@arabic\c@equation}
% 针对学士论文的设置
\def\bnu@maketag#1{\maketag@@@{(\ignorespaces #1\unskip\@@italiccorr)}}
\def\tagform@#1{\maketag@@@{(\ignorespaces #1\unskip\@@italiccorr)\equcaption{#1}}}
% 解决证明环境中方块乱跑的问题
\gdef\@endtrivlist#1{%
\if@inlabel \indent\fi
\if@newlist \@noitemerr\fi
\ifhmode
\ifdim\lastskip >\z@ #1\unskip \par
\else #1\unskip \par \fi
\fi
\if@noparlist \else
\ifdim\lastskip >\z@
\@tempskipa\lastskip \vskip -\lastskip
\advance\@tempskipa\parskip \advance\@tempskipa -\@outerparskip
\vskip\@tempskipa
\fi
\@endparenv
\fi #1}
% 定理字样使用黑体,正文使用宋体,冒号隔开
\theorembodyfont{\song}
\theoremheaderfont{\hei}
% 浮动对像和表格
% 设置浮动对像和文字之间的距离
\setlength{\floatsep}{12bp \@plus4pt \@minus1pt}
\setlength{\intextsep}{12bp \@plus4pt \@minus2pt}
\setlength{\textfloatsep}{12bp \@plus4pt \@minus2pt}
\setlength{\@fptop}{0bp \@plus1.0fil}
\setlength{\@fpsep}{12bp \@plus2.0fil}
\setlength{\@fpbot}{0bp \@plus1.0fil}
% 下面这组命令使浮动对像的缺省值稍微宽松一点
\renewcommand{\textfraction}{0.15}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.65}
\renewcommand{\floatpagefraction}{0.60}
% 定制浮动图形和表格标题样式
\let\old@tabular\@tabular
\def\bnu@tabular{\dawu[1.5]\old@tabular}
\DeclareCaptionLabelFormat{bnu}{{\dawu[1.5]\song #1~\rmfamily #2}}
\DeclareCaptionLabelSeparator{bnu}{\hspace{1em}}
\DeclareCaptionFont{bnu}{\dawu[1.5]}
\captionsetup{labelformat=bnu,labelsep=bnu,font=bnu}
\captionsetup[table]{position=top,belowskip={12bp-\intextsep},aboveskip=6bp}
\captionsetup[figure]{position=bottom,belowskip={12bp-\intextsep},aboveskip=6bp}
\captionsetup[subfloat]{labelformat=simple,font=bnu,captionskip=6bp,nearskip=6bp,farskip=0bp,topadjust=0bp}
\renewcommand{\thesubfigure}{(\alph{subfigure})}
\renewcommand{\thesubtable}{(\alph{subtable})}
% 采用 longtable 来处理跨页表格
\let\bnu@LT@array\LT@array
\def\LT@array{\dawu[1.5]\bnu@LT@array}
% 简单的表格使用三线表推荐用 \hlinewd
\def\hlinewd#1{%
\noalign{\ifnum0=`}\fi\hrule \@height #1 \futurelet
\reserved@a\@xhline}
% 章节标题,如果章节题目中的英文要使用 arial,那么就加上 \sffamily
\ifbnu@arialtitle
\def\bnu@title@font{\sffamily}
\fi
\renewcommand\chapter{\clpage\phantomsection%
\thispagestyle{bnu@plain}%
\global\@topnum\z@%
\@afterindenttrue%
\secdef\@chapter\@schapter}
\def\@chapter[#1]#2{%
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\refstepcounter{chapter}%
\addcontentsline{toc}{chapter}{\@chapapp \hspace{1em} #1}
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\chaptermark{#1}%
\@makechapterhead{#2}}
% 正文标题:均加粗,段前后均 0.5 行
% 一级标题:三号黑体,加粗
% 二级标题:小三号黑体
% 三级标题:四号黑体
\def\@makechapterhead#1{
\vspace*{0.5\baselineskip}%
{\parindent \z@ \centering
\bf \hei \csname bnu@title@font\endcsname\sanhao[1.6]
\ifnum \c@secnumdepth >\m@ne
\@chapapp\hskip1em
\fi
#1\par\nobreak
\vskip0.5\baselineskip}}
\def\@schapter#1{%
\@makeschapterhead{#1}
\@afterheading}
\def\@makeschapterhead#1{%
\vspace*{0.5\baselineskip}%
{\parindent \z@ \centering
\bf \hei \csname bnu@title@font\endcsname\sanhao[1.6]
\def\@tempa{#1}
\def\@tempb{\eabstractname}
\ifx\@tempa\@tempb\bfseries\fi
\interlinepenalty\@M
#1\par\nobreak
\vskip0.5\baselineskip}}
\newcounter{bnu@bookmark}
\def\bnu@chapter*{%
\@ifnextchar [ % ]
{\bnu@@chapter}
{\bnu@@chapter@}}
\def\bnu@@chapter@#1{\bnu@@chapter[#1]{#1}}
\def\bnu@@chapter[#1]#2{%
\@ifnextchar [ % ]
{\bnu@@@chapter[#1]{#2}}
{\bnu@@@chapter[#1]{#2}[]}}
\def\bnu@@@chapter[#1]#2[#3]{%
\clpage
\phantomsection
\def\@tmpa{#1}
\def\@tmpb{#3}
\ifx\@tmpa\@empty
\addtocounter{bnu@bookmark}\@ne
\pdfbookmark[0]{#2}{bnuchapter.\thebnu@bookmark}
\else
\addcontentsline{toc}{chapter}{#1}
\fi
\chapter*{#2}
\ifx\@tmpb\@empty
\@mkboth{#2}{#2}
\else
\@mkboth{#3}{#3}
\fi}
\RequirePackage{titlesec}
\titlespacing{\chapter}{0pt}{0.5\baselineskip}{0.5\baselineskip}
\renewcommand\section{\@startsection {section}{1}{\z@}%
{ -24bp\@plus -1ex \@minus -.2ex}%
{6bp \@plus .2ex}%
{\bf \hei \csname bnu@title@font\endcsname\xiaosan[1.429]}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
{-16bp\@plus -1ex \@minus -.2ex}%
{6bp \@plus .2ex}%
{\bf \hei \csname bnu@title@font\endcsname\sihao[1.538]}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
{-16bp\@plus -1ex \@minus -.2ex}%
{6bp \@plus .2ex}%
{\bf \hei \csname bnu@title@font\endcsname\xiaosi[1.667]}}
% 目录格式
% 最多涉及 4 层,即 x.x.x.x
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
% 每章标题行前空 6 磅,后空 0 磅
\renewcommand\tableofcontents{%
\bnu@chapter*[]{\contentsname}
\sanhao[1.5]\@starttoc{toc}\normalsize}
\ifbnu@arialtoc
\def\bnu@toc@font{\sffamily}\fi
\def\@tocrmarg{2em}
\def\@dotsep{1}
\def\@dottedtocline#1#2#3#4#5{%
\ifnum #1>\c@tocdepth \else
\vskip \z@ \@plus.2\p@
{\leftskip #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
\parindent #2\relax\@afterindenttrue
\interlinepenalty\@M\leavevmode\@tempdima #3\relax
\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
{\hei \csname bnu@toc@font \endcsname #4}\nobreak
\leaders\hbox{$\m@th\mkern \@dotsep mu\hbox{$\cdot$}\mkern \@dotsep mu$}\hfill
\nobreak{\normalsize \normalcolor #5}%
\par}%
\fi}
% 目录格式
\titlecontents{chapter}[0em]
{\vspace{.05\baselineskip}\hei}
{\sanhao[0.0]{\thecontentslabel}~\hspace{.5em}} {}
{\dotfill\contentspage[{\makebox[0pt][r]{\thecontentspage}}]}
[\vspace{.05\baselineskip}]
\titlecontents{section}[1em]
{\vspace{.05\baselineskip}\hei}
{\xiaosan[0.0]{\thecontentslabel}~\hspace{.5em}} {}
{\dotfill\contentspage[{\makebox[0pt][r]{\thecontentspage}}]}
[\vspace{.05\baselineskip}]
\titlecontents{subsection}[2em]
{\vspace{.05\baselineskip}\hei}
{\sihao[0.0]{\thecontentslabel}~\hspace{.5em}} {}
{\dotfill\contentspage[{\makebox[0pt][r]{\thecontentspage}}]}
[\vspace{.05\baselineskip}]
\titlecontents{subsubsection}[3em]
{\vspace{.05\baselineskip}\hei}
{\xiaosi[0.0]{\thecontentslabel}~\hspace{.5em}} {}
{\dotfill\contentspage[{\makebox[0pt][r]{\thecontentspage}}]}
[\vspace{.05\baselineskip}]
% 封面和封底
% 方便定义封面的一些替换命令
\def\bnu@define@term#1{
\expandafter\gdef\csname #1\endcsname##1{%
\expandafter\gdef\csname bnu@#1\endcsname{##1}}
\csname #1\endcsname{}}
% 封面、摘要、版权、致谢格式定义
\bnu@define@term{secretlevel}
\bnu@define@term{secretyear}
\bnu@define@term{ctitle}
\bnu@define@term{cdegree}
\newcommand\cdepartment[2][]{\def\bnu@cdepartment@short{#1}\def\bnu@cdepartment{#2}}
\def\caffil{\cdepartment}
\def\bnu@cdepartment@short{}
\def\bnu@cdepartment{}
\bnu@define@term{cmajor}
\def\csubject{\cmajor}
\bnu@define@term{cbuyuanxi}
\bnu@define@term{czhuanye}
\bnu@define@term{cxuehao}
\bnu@define@term{cxueshengxingming}
\bnu@define@term{czhidaojiaoshi}
\bnu@define@term{czhidaojiaoshizhicheng}
\bnu@define@term{czhidaojiaoshidanwei}
\bnu@define@term{cauthor}
\bnu@define@term{csupervisor}
\bnu@define@term{cassosupervisor}
\bnu@define@term{ccosupervisor}
\bnu@define@term{cnum}
\bnu@define@term{cdate}
\bnu@define@term{etitle}
\bnu@define@term{edegree}
\bnu@define@term{edepartment}
\def\eaffil{\edepartment}
\bnu@define@term{emajor}
\def\esubject{\emajor}
\bnu@define@term{eauthor}
\bnu@define@term{esupervisor}
\bnu@define@term{eassosupervisor}
\bnu@define@term{ecosupervisor}
\bnu@define@term{edate}
% 摘要最好以环境的形式出现
\long\@xp\def\@xp\collect@@body\@xp#\@xp1\@xp\end\@xp#\@xp2\@xp{%
\collect@@body{#1}\end{#2}}
\long\@xp\def\@xp\push@begins\@xp#\@xp1\@xp\begin\@xp#\@xp2\@xp{%
\push@begins{#1}\begin{#2}}
\long\@xp\def\@xp\addto@envbody\@xp#\@xp1\@xp{%
\addto@envbody{#1}}
% 使用 \collect@body 构建摘要环境
\newcommand{\bnu@@cabstract}[1]{\long\gdef\bnu@cabstract{#1}}
\newenvironment{cabstract}{\collect@body\bnu@@cabstract}{}
\newcommand{\bnu@@eabstract}[1]{\long\gdef\bnu@eabstract{#1}}
\newenvironment{eabstract}{\collect@body\bnu@@eabstract}{}
\def\bnu@parse@keywords#1{
\expandafter\gdef\csname bnu@#1\endcsname{}
\expandafter\gdef\csname #1\endcsname##1{
\@for\reserved@a:=##1\do{
\expandafter\ifx\csname bnu@#1\endcsname\@empty\else
\expandafter\g@addto@macro\csname bnu@#1\endcsname{\ignorespaces\csname bnu@#1@separator\endcsname}
\fi
\expandafter\expandafter\expandafter\g@addto@macro%
\expandafter\csname bnu@#1\expandafter\endcsname\expandafter{\reserved@a}}}}
\bnu@parse@keywords{ckeywords}
\bnu@parse@keywords{ekeywords}
% 封面第一页
\newlength{\bnu@title@width}
\def\bnu@put@title#1{\makebox{\hb@xt@ \bnu@title@width{#1}}}
\newcommand{\bnu@first@titlepage}{
\begin{center}
\vspace*{-1.8cm}
\parbox[b][2.4cm][t]{\textwidth}{\ifbnu@secret\hfill{\sihao\bnu@secret@title}\else\rule{1cm}{0cm}\fi}
\vskip0.3cm
\includegraphics[width=7.96cm]{BNU_name.pdf}
\parbox[t][7cm][t]{\paperwidth-6.5cm}{
\renewcommand{\baselinestretch}{1.5}
\begin{center}
\vskip-0.4cm
{\xiaochu[1.2]\bf \song \ziju{0.21cm}\bnu@bachelor@subtitle}
\par\vskip1.9cm
\end{center}
\begin{flushleft}
\hskip0.3cm \sanhao[1] \bf \hei \bnu@thesistitlepre
\end{flushleft}
\begin{center}
\sanhao[1] \song \bf \underline{\bnu@ctitle}
\end{center}
}
\parbox[t][9.0cm][t]{\paperwidth-9cm}{
\sanhao[1] \ \\ \ \\ \\ \vskip0.2cm
% 封面排版
\sihao[1.6] \song \bf
\bnu@buyuanxi \bnu@title@sep \hspace{1em} \bnu@cbuyuanxi\vskip0.33cm
\bnu@zhuanye \bnu@title@sep \hspace{1em} \bnu@czhuanye\vskip0.33cm
\bnu@xuehao \bnu@title@sep \hspace{1em} \bnu@cxuehao\vskip0.33cm
\bnu@xueshengxingming \bnu@title@sep \hspace{1em} \bnu@cxueshengxingming\vskip0.33cm
\bnu@zhidaojiaoshi \bnu@title@sep \hspace{1em} \bnu@czhidaojiaoshi\vskip0.33cm
\bnu@zhidaojiaoshizhicheng \bnu@title@sep \hspace{1em} \bnu@czhidaojiaoshizhicheng\vskip0.33cm
\bnu@zhidaojiaoshidanwei \bnu@title@sep \hspace{1em} \bnu@czhidaojiaoshidanwei\vskip0.33cm
}
\vskip3.0cm
\begin{center}
{\xiaosi \song\ziju{4bp} \bf \bnu@org}
\end{center}
\end{center}}
% 设置封面字体
\newcommand\bnu@justspace[2][6em]{\hskip1pt {\hb@xt@ #1{\hss#2\hss}}\hskip3pt}
\newcommand\bnu@underline[2][6em]{\hskip1pt\underline{\hb@xt@ #1{\hss#2\hss}}\hskip3pt}
\newcommand{\bnu@authorization@mk}{%
\vspace*{-0.1cm}
\begin{center}\xiaosi\song\bf {\bnu@declaretitle}\end{center}
\vskip10pt \xiaosi[1.8] \bnu@declaration\par
\vskip14pt \bnu@declsign\par
\sihao[1.6]\song \ \\ \ \\ \ \\
\begin{center}\xiaosi\song\bf {\bnu@authtitle}\end{center}
\vskip10pt \xiaosi[1.8] \bnu@authorization\par \xiaosi[1.8] \bnu@authorizationplus
\vskip1.2cm
\begingroup
\parindent0pt\xiaosi
\hspace*{2em}\bnu@authorsig\bnu@justspace[9.5em]\relax\hfill
\bnu@org\bnu@justspace[5.5em]\relax\hspace*{3cm}\\[18pt]
\hspace*{2em}\bnu@teachersig\bnu@justspace[9.5em]\relax\hfill
\bnu@org\bnu@justspace[5.5em]\relax\hspace*{3cm}
\endgroup
}
\newcommand{\makecover}{
\phantomsection
\pdfbookmark[-1]{\bnu@ctitle}{ctitle}
\normalsize
\begin{titlepage}
\bnu@first@titlepage
\clpage\bnu@authorization@mk
\end{titlepage}
\normalsize
\bnu@makeabstract
\let\@tabular\bnu@tabular}
% 摘要格式
\newcommand{\bnu@makeabstract}{%
\cleardoublepage
% 中文摘要:四号宋体,行距20磅
\bnu@chapter*[\cabstractname]{}
\pagestyle{bnu@plain}
\pagenumbering{Roman}
\begin{center}
\sanhao[1.6] \bf \hei \bnu@ctitle \par
\vskip20bp
\xiaosan[1.6] \bf \hei \cabstractname
\end{center}
\vskip20bp
\sihao[1.6] \song \par \bnu@cabstract % 摘要内容
\vskip20bp
\setbox0=\hbox{{\sihao \hei\bnu@ckeywords@title}} % 关键词:四号黑体
\noindent\hangindent\wd0\hangafter1
\box0 \sihao \song \bnu@ckeywords % 关键词内容:四号宋体
% 英文摘要:小三号
\bnu@chapter*[\eabstractname]{}
\begin{center}
\sanhao[1.6]\bf \bnu@etitle \par
\vskip20bp
\xiaosan[1.6]\bf \eabstractname
\end{center}
\vskip20bp
\sihao[1.6] \par \bnu@eabstract % 摘要内容:四号,Times New Roman 字体,单倍行距
\vskip20bp
\setbox0=\hbox{\textbf \bnu@ekeywords@title}
\noindent\hangindent\wd0\hangafter1
\box0\bnu@ekeywords
}
% 主要符号对照表
\newenvironment{denotation}[1][2.5cm]{
\bnu@chapter*[]{\bnu@denotation@name}
\noindent
\begin{list}{}%
{\vskip-30bp\xiaosi[1.6]
\renewcommand\makelabel[1]{##1\hfil}
\setlength{\labelwidth}{#1}
\setlength{\labelsep}{0.5cm}
\setlength{\itemindent}{0cm}
\setlength{\leftmargin}{\labelwidth+\labelsep}
\setlength{\rightmargin}{0cm}
\setlength{\parsep}{0cm}
\setlength{\itemsep}{0cm}
\setlength{\listparindent}{0cm}
\setlength{\topsep}{0pt}
}}{\end{list}}
% 致谢
\newenvironment{ack}{%
\bnu@chapter*[\bnu@acklongname]{\bnu@ackname}[\bnu@acklongname]}{%
\vskip12bp\sihao[1.5]\hei\rightline{\bnu@cxueshengxingming \hspace{1.5em}} \par \rightline{\bnu@cdate}}
% 索引部分
\def\bnu@starttoc#1{%
\let\oldnumberline\numberline
\def\numberline##1{\oldnumberline{\csname #1name\endcsname\hskip.4em ##1}}
\@starttoc{\csname ext@#1\endcsname}
\let\numberline\oldnumberline}
\def\bnu@listof#1{%
\@ifstar
{\bnu@chapter*[]{\csname list#1name\endcsname}\bnu@starttoc{#1}}
{\bnu@chapter*{\csname list#1name\endcsname}\bnu@starttoc{#1}}}
\renewcommand\listoffigures{\bnu@listof{figure}}
\renewcommand*\l@figure{\@dottedtocline{1}{0em}{4em}}
\renewcommand\listoftables{\bnu@listof{table}}
\let\l@table\l@figure
% 本命令只是为了生成公式列表,所以这个 caption 是假的
% 如果编号做好使用 equation 环境,如果是其它编号环境,请手动添加 \equcaption
\def\ext@equation{loe}
\def\equcaption#1{%
\addcontentsline{\ext@equation}{equation}
{\protect\numberline{#1}}}
% LaTeX 没有默认的公式索引,此处定义自己的 \listofequations
\newcommand\listofequations{\bnu@listof{equation}}
\let\l@equation\l@figure
% 参考文献
% 正文引用格式,依赖于 natbib 宏包
\bibpunct{[}{]}{,}{s}{}{,}
\renewcommand\NAT@citesuper[3]{\ifNAT@swa%
\unskip\kern\p@\textsuperscript{\NAT@@open #1\NAT@@close}%
\if*#3*\else\ (#3)\fi\else #1\fi\endgroup}
\DeclareRobustCommand\onlinecite{\@onlinecite}
\def\@onlinecite#1{\begingroup\let\@cite\NAT@citenum\citep{#1}\endgroup}
% 参考文献条目学士论文最后加点
\def\bnudot{\ifbnu@bachelor\else\unskip.\fi}
\def\bnumasterbib{\ifbnu@doctor [M]\else [Master Thesis]\fi}
\def\bnuphdbib{\ifbnu@doctor [D]\else [Doctor Thesis]\fi}
% 修改默认的 thebibliography 环境,增加一些调整代码
\def\bibleftdelim{[}
\def\bibrightdelim{]}
\def\@biblabel#1{\bibleftdelim #1\bibrightdelim}
\renewenvironment{thebibliography}[1]{%
\bnu@chapter*{\bibname}%
\wuhao[1.6]
\list{\@biblabel{\@arabic\c@enumiv .}}%
{\renewcommand{\makelabel}[1]{##1\hfill}
\settowidth\labelwidth{0cm}
%\setlength{\labelsep}{0.5em}
%\setlength{\itemindent}{1em}
%\setlength{\leftmargin}{0.5cm}
\setlength{\listparindent}{2em}
\addtolength{\itemsep}{-0.7em}
\usecounter{enumiv}%
\let\p@enumiv\@empty
\renewcommand\theenumiv{\@arabic\c@enumiv}}%
\sloppy\frenchspacing
\clubpenalty4000
\@clubpenalty \clubpenalty
\widowpenalty4000%
\interlinepenalty4000%
\sfcode`\.\@m}
{\def\@noitemerr
{\@latex@warning{Empty `thebibliography' environment}}%
\endlist\frenchspacing}
% 正文图表公式编号
\RequirePackage{chngcntr}
\RequirePackage{amsmath}
\RequirePackage{mathtools}
\newtagform{empty}{{式}}{}
\usetagform{empty}
\counterwithout{table}{chapter}
\counterwithout{figure}{chapter}
\renewcommand\theequation{(\thechapter-\@arabic\c@equation)}
\renewcommand\thetable{\@arabic \c@table}
\renewcommand\thefigure{\@arabic\c@figure}
% 附录格式
\RequirePackage{CJKnumb}
\let\bnu@appendix\appendix
\renewenvironment{appendix}{%
\bnu@appendix
\setcounter{table}{0}
\setcounter{figure}{0}
\renewcommand \thechapter { \@Roman\c@chapter} % 附录用罗马数字编码
\gdef\@chapapp{\appendixname~\thechapter}
\renewcommand\theequation{(\CJKnumber\c@equation)} % 附录图表公式编号格式
\renewcommand\thetable{\CJKnumber\c@table}
\renewcommand\thefigure{\CJKnumber\c@figure}
}{}
% 研究成果
\newenvironment{paper}{
\bnu@chapter*{\bnu@paper@title}}{}
% 书脊
\newcommand{\shuji}[1][\bnu@ctitle]{
\newpage\thispagestyle{empty}\ziju{0.4em}\fs\xiaosan
\hfill\rotatebox{-90}{\hb@xt@ \textheight{#1\hfill\bnu@cauthor}}}
% 生成索引的一些命令,虽然我们暂时用不到
\iffalse
\newcommand{\bs}{\symbol{'134}} % Print backslash
\newcommand{\cih}[1]{%
\index{commands!#1@\texttt{\bs#1}}%
\index{#1@\texttt{\hspace*{-1.2ex}\bs #1}}}
\newcommand{\ci}[1]{\cih{#1}\texttt{\bs#1}}
\newcommand{\pai}[1]{%
\index{packages!#1@\textsf{#1}}%
\index{#1@\textsf{#1}}%
\textsf{#1}}
\newcommand{\ei}[1]{%
\index{environments!\texttt{#1}}%
\index{#1@\texttt{#1}}%
\texttt{#1}}
\newcommand{\wi}[1]{\index{#1}#1}
\fi
% 自定义命令和环境
% 改变字距
\newcommand*{\ziju}[1]{\renewcommand{\CJKglue}{\hskip #1}}
\newcommand{\pozhehao}{\kern0.3ex\rule[0.8ex]{2em}{0.1ex}\kern0.3ex}