-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlib.typ
More file actions
299 lines (295 loc) · 9.68 KB
/
lib.typ
File metadata and controls
299 lines (295 loc) · 9.68 KB
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
// 中国科学院大学学位论文模板 modern-ucas-thesis
// Author: https://github.com/Vncntvx
// Repo: https://github.com/Vncntvx/modern-ucas-thesis
#import "layouts/doc.typ": doc
#import "layouts/preface.typ": preface
#import "layouts/mainmatter.typ": mainmatter
#import "layouts/appendix.typ": appendix
#import "pages/fonts-display-page.typ": fonts-display-page
#import "pages/bachelor-cover.typ": bachelor-cover
#import "pages/master-cover.typ": master-cover
#import "pages/bachelor-decl-page.typ": bachelor-decl-page
#import "pages/master-decl-page.typ": master-decl-page
#import "pages/bachelor-abstract.typ": bachelor-abstract
#import "pages/master-abstract.typ": master-abstract
#import "pages/bachelor-abstract-en.typ": bachelor-abstract-en
#import "pages/master-abstract-en.typ": master-abstract-en
#import "pages/outline-page.typ": outline-page
#import "pages/list-of-figures-and-tables.typ": list-of-figures-and-tables
#import "pages/notation.typ": notation
#import "pages/acknowledgement.typ": acknowledgement
#import "pages/backmatter.typ": backmatter
#import "utils/bilingual-bibliography.typ": bilingual-bibliography
#import "utils/custom-figure.typ": bifigure, bitable
#import "utils/bilingual-figured.typ": show-equation, show-figure
#import "utils/custom-numbering.typ": custom-numbering
#import "utils/custom-heading.typ": active-heading, current-heading, heading-display
#import "utils/style.typ": get-fonts, 字体组, 字号
// 使用函数闭包特性,通过 `documentclass` 函数类进行全局信息配置,然后暴露出拥有了全局配置的、具体的 `layouts` 和 `templates` 内部函数。
#let documentclass(
doctype: "doctor", // "bachelor" | "master" | "doctor" | "postdoc",文档类型,默认为博士生 doctor
degree: "academic", // "academic" | "professional",学位类型,默认为学术型 academic
nl-cover: false, // TODO: 是否使用国家图书馆封面,默认关闭
twoside: false, // 双面模式,会加入空白页,便于打印
anonymous: false, // 盲审模式
bibliography: none, // 参考文献函数
// 字体配置说明:
// - fontset参数用于选择预定义的字体组(windows、mac、fandol或adobe)
// - fonts参数用于覆盖或补充fontset中的字体设置,提供更精细的字体控制
// - 对大多数用户而言,只需设置fontset即可;对有特殊需求的用户,可使用fonts参数自定义
fontset: "mac", // "windows" | "mac" | "fandol" | "adobe",选择预定义的字体组
fonts: (:), // 用于覆盖或补充fontset中的字体,可选择性覆盖
info: (:),
) = {
// 默认参数
// 根据 fontset 参数选择对应的字体组
// 将用户自定义的fonts与预定义字体组合并,用户定义的字体会覆盖预定义字体
fonts = get-fonts(fontset) + fonts
info = (
(
title: ("基于 Typst 的", "中国科学院大学学位论文"),
title-en: "UCAS Thesis Template for Typst",
grade: "20XX",
student-id: "1234567890",
author: "张三",
author-en: "Zhang San",
department: "某研究所",
department-en: "XX Institute",
major: "xx 专业",
major-en: "xx major",
category: "学科门类或专业学位类别",
category-en: "XX category",
supervisor: ("李四", "教授"),
supervisor-en: "Professor Li Si",
supervisor-ii: (),
supervisor-ii-en: "",
submit-date: datetime.today(),
// 以下为研究生项
defend-date: datetime.today(),
confer-date: datetime.today(),
bottom-date: datetime.today(),
chairman: "某某某 教授",
reviewer: ("某某某 教授", "某某某 教授"),
clc: "O643.12",
udc: "544.4",
secret-level: "公开",
supervisor-contact: "中国科学院大学 北京市海淀区中关村东路80号",
email: "xyz@mails.ucas.ac.cn",
school-code: "14430",
degree: auto,
degree-en: auto,
)
+ info
)
return (
// 将传入参数再导出
doctype: doctype,
degree: degree,
nl-cover: nl-cover,
twoside: twoside,
anonymous: anonymous,
fonts: fonts,
info: info,
// 页面布局
doc: (..args) => {
doc(
..args,
fontset: fontset,
info: info + args.named().at("info", default: (:)),
)
},
preface: (..args) => {
preface(
twoside: twoside,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
)
},
mainmatter: (..args) => {
if doctype == "master" or doctype == "doctor" {
mainmatter(
twoside: twoside,
display-header: true,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
info: info + args.named().at("info", default: (:)),
)
} else {
mainmatter(
twoside: twoside,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
info: info + args.named().at("info", default: (:)),
)
}
},
appendix: (..args) => {
appendix(
..args,
)
},
// 字体展示页
fonts-display-page: (..args) => {
fonts-display-page(
twoside: twoside,
fontset: fontset,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
)
},
// 封面页,通过 type 分发到不同函数
cover: (..args) => {
if doctype == "master" or doctype == "doctor" {
master-cover(
doctype: doctype,
degree: degree,
nl-cover: nl-cover,
anonymous: anonymous,
twoside: twoside,
fontset: fontset,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
info: info + args.named().at("info", default: (:)),
)
} else if doctype == "postdoc" {
panic("postdoc has not yet been implemented.")
} else {
bachelor-cover(
anonymous: anonymous,
twoside: twoside,
fontset: fontset,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
info: info + args.named().at("info", default: (:)),
)
}
},
// 声明页,通过 type 分发到不同函数
decl-page: (..args) => {
if doctype == "master" or doctype == "doctor" {
master-decl-page(
anonymous: anonymous,
twoside: twoside,
fontset: fontset,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
)
} else if doctype == "postdoc" {
panic("postdoc has not yet been implemented.")
} else {
bachelor-decl-page(
anonymous: anonymous,
twoside: twoside,
fontset: fontset,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
info: info + args.named().at("info", default: (:)),
)
}
},
// 中文摘要页,通过 type 分发到不同函数
abstract: (..args) => {
if doctype == "master" or doctype == "doctor" {
master-abstract(
doctype: doctype,
degree: degree,
anonymous: anonymous,
twoside: twoside,
fontset: fontset,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
info: info + args.named().at("info", default: (:)),
)
} else if doctype == "postdoc" {
panic("postdoc has not yet been implemented.")
} else {
bachelor-abstract(
anonymous: anonymous,
twoside: twoside,
fontset: fontset,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
info: info + args.named().at("info", default: (:)),
)
}
},
// 英文摘要页,通过 type 分发到不同函数
abstract-en: (..args) => {
if doctype == "master" or doctype == "doctor" {
master-abstract-en(
doctype: doctype,
degree: degree,
anonymous: anonymous,
twoside: twoside,
fontset: fontset,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
info: info + args.named().at("info", default: (:)),
)
} else if doctype == "postdoc" {
panic("postdoc has not yet been implemented.")
} else {
bachelor-abstract-en(
anonymous: anonymous,
twoside: twoside,
fontset: fontset,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
info: info + args.named().at("info", default: (:)),
)
}
},
// 目录页
outline-page: (..args) => {
outline-page(
twoside: twoside,
fontset: fontset,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
)
},
// 图表目录页
list-of-figures-and-tables: (..args) => {
list-of-figures-and-tables(
twoside: twoside,
fontset: fontset,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
)
},
// 符号表页
notation: (..args) => {
notation(
twoside: twoside,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
)
},
// 参考文献页
bilingual-bibliography: (..args) => {
bilingual-bibliography(
bibliography: bibliography,
..args,
)
},
// 致谢页
acknowledgement: (..args) => {
acknowledgement(
anonymous: anonymous,
twoside: twoside,
..args,
)
},
// 个人信息页
backmatter: (..args) => {
backmatter(
anonymous: anonymous,
twoside: twoside,
..args,
)
},
// 双语图表函数
bifigure: bifigure,
bitable: bitable,
)
}