-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhuthesis.cls
127 lines (108 loc) · 3.88 KB
/
whuthesis.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
%% whuthesis
%% Copyright (C) 2024 Kangwei Xia <https://github.com/xkwxdyy>
%%
%% 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 2008 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainer of this work is Kangwei Xia <kangweixia_xdyy@163.com>.
%%
%% This work consists of the files whu.sty, whuthesis.cls .
%%
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{l3keys2e}
% \whu@date 和 \whu@version 为 whuthesis 的日期和版本号
% \whu@d@te 和 \whu@versi@n 为上游的 CusTeX 的日期和版本号
\def\whu@date{2024/04/08}
\def\whu@version{0.0.4}
\ProvidesExplClass{whuthesis}{\whu@date}{\whu@version}{Thesis template for Wuhan University}
\str_new:N \g__whu_type_str
\clist_new:N \g__whu_to_book_clist
\keys_define:nn { whu/class }
{
library .code:n =
{ \PassOptionsToPackage { library = {#1} } { whu } }
, type .choice:
, type/electronic .code:n =
{
\str_gset:Nn \g__whu_type_str { electronic }
\clist_gput_right:Nn \g__whu_to_book_clist { a4paper, twoside }
}
, type/for-print .code:n =
{
\str_gset:Nn \g__whu_type_str { for-print }
\clist_gput_right:Nn \g__whu_to_book_clist { a4paper, twoside }
}
, type/for-library .code:n =
{
\str_gset:Nn \g__whu_type_str { for-library }
\clist_gput_right:Nn \g__whu_to_book_clist { a4paper, twoside, openany }
}
, type .initial:n = electronic
}
\ProcessKeysOptions { whu/class }
\cs_new:Nn \__whu_type_electronic_setting:
{ \__whu_type_electronic_additional_setting: }
\cs_new:Nn \__whu_type_electronic_additional_setting: { }
\cs_new:Nn \__whu_type_for_print_setting:
{ \__whu_type_for_print_additional_setting: }
\cs_new:Nn \__whu_type_for_print_additional_setting: { }
\cs_new:Nn \__whu_type_for_library_setting:
{
% 这样设置可以防止 \frontmatter 和 \mainmatter 里面的 \cleardoublepage 产生空白页
\cs_set_eq:NN \__whu_cleardoublepage: \cleardoublepage
\AddToHook { cmd / frontmatter / before }
{ \cs_set_eq:NN \cleardoublepage \newpage }
\AddToHook { cmd / frontmatter / after }
{ \cs_set_eq:NN \cleardoublepage \__whu_cleardoublepage: }
\AddToHook { cmd / mainmatter / before }
{ \cs_set_eq:NN \cleardoublepage \newpage }
\AddToHook { cmd / mainmatter / after }
{ \cs_set_eq:NN \cleardoublepage \__whu_cleardoublepage: }
% 2024-04-07 zepinglee 建议不用上面那样 hook,直接加一个 \@twosidefalse 即可,但是这样会影响页眉
% \@twosidefalse
\__whu_type_for_library_additional_setting:
}
\cs_new:Nn \__whu_type_for_library_additional_setting: { }
% 消除 xeCJK 的警告
\PassOptionsToPackage { silent } { xeCJK }
\seq_put_right:Nx \l_file_search_path_seq { ./module }
\seq_put_right:Nx \l_file_search_path_seq { ./library }
\seq_put_right:Nx \l_file_search_path_seq { ./library-cus }
\RequirePackage { whu }
\PassOptionsToClass{ \g__whu_to_book_clist }{ book }
\LoadClass { book }
% 要放在 whu 加载之后
\str_case:Vn \g__whu_type_str
{
{ electronic } { \__whu_type_electronic_setting: }
{ for-print } { \__whu_type_for_print_setting: }
{ for-library } { \__whu_type_for_library_setting: }
}
\RequirePackage { ctex }
\RequirePackage { graphicx }
\graphicspath { {./figures/} {./logo/} }
\RequirePackage { tikzpagenodes }
\ExplSyntaxOff
\usetikzlibrary { positioning }
\ExplSyntaxOn
\RequirePackage { tabularray }
\AtEndPreamble
{
\RequirePackage { hyperref }
\hypersetup
{
pdfencoding = auto,
citecolor = magenta,
linkcolor = blue,
hidelinks
}
}