forked from werifu/HUST-typst-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.typ
470 lines (399 loc) · 9.69 KB
/
template.typ
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
#let heiti = ("Times New Roman", "Heiti SC", "Heiti TC")
#let songti = ("Times New Roman", "Songti SC", "Songti TC")
#let equation_num(_) = {
locate(loc => {
let chapt = counter(heading).at(loc).at(0)
let c = counter("equation-chapter" + str(chapt))
let n = c.at(loc).at(0)
"(" + str(chapt) + "-" + str(n + 1) + ")"
})
}
#let table_num(_) = {
locate(loc => {
let chapt = counter(heading).at(loc).at(0)
let c = counter("table-chapter" + str(chapt))
let n = c.at(loc).at(0)
str(chapt) + "-" + str(n + 1)
})
}
#let image_num(_) = {
locate(loc => {
let chapt = counter(heading).at(loc).at(0)
let c = counter("image-chapter" + str(chapt))
let n = c.at(loc).at(0)
str(chapt) + "-" + str(n + 1)
})
}
#let equation(equation, caption: "") = {
figure(
equation,
caption: caption,
supplement: [公式],
numbering: equation_num,
kind: "equation"
)
}
#let tbl(tbl, caption: "") = {
figure(
tbl,
caption: caption,
supplement: [表],
numbering: table_num,
kind: "table"
)
}
#let img(img, caption: "") = {
figure(
img,
caption: caption,
supplement: [图],
numbering: image_num,
kind: "image"
)
}
#let indent_par(body) = {
// 加上元素间间隔大概 2.0em
box(width: 1.8em)
body
}
#let toc() = {
v(1em)
// HUST 的反人类目录还包括出现在目录前的摘要……硬编码吧
align(center)[
#text(font: heiti, size: 18pt, "目 录")
]
parbreak()
set text(font: songti, size: 12pt)
[摘要 ] + [.] * 130 + [ I]
parbreak()
text(weight: "bold")[Abstract ] + [.] * 122 + [ II]
show outline: it => {
set text(font: songti, size: 12pt)
set par(leading: 1.5em)
it
pagebreak()
}
outline(
title: none
)
}
// 原创性声明和授权书
#let declaration() = {
set text(font: songti, 12pt)
show par: it => {
it
v(5pt)
}
v(3em)
align(center)[
#text(font: heiti, size: 18pt)[
学位论文原创性声明
]
]
text(font: songti, size: 12pt)[
#set par(justify: false, leading: 1.5em, first-line-indent: 2em)
本人郑重声明:所呈交的论文是本人在导师的指导下独立进行研究所取得的 研究成果。除了文中特别加以标注引用的内容外,本论文不包括任何其他个人或集体已经发表或撰写的成果作品。本人完全意识到本声明的法律后果由本人承担。
]
v(2em)
align(right)[
#text("作者签名: 年 月 日")
]
v(6em)
align(center)[
#text(font: heiti, size: 18pt)[
学位论文版权使用授权书
]
]
text(font: songti, size: 12pt)[
#set par(justify: false, leading: 1.5em, first-line-indent: 2em)
本学位论文作者完全了解学校有关保障、使用学位论文的规定,同意学校保留并向有关学位论文管理部门或机构送交论文的复印件和电子版,允许论文被查阅和借阅。本人授权省级优秀学士论文评选机构将本学位论文的全部或部分内容编入有关数据进行检索,可以采用影印、缩印或扫描等复制手段保存和汇编本学位论文。
学位论文属于 1、保密 □,在#h(3em)年解密后适用本授权书。
#h(6.3em) 2、不保密 □
#h(6.3em)请在以上相应方框内打 “√”
]
v(3em)
align(right)[
#text("作者签名: 年 月 日")
]
align(right)[
#text("导师签名: 年 月 日")
]
}
// 参考文献
#let references(path) = {
// 这个取消目录里的 numbering
set heading(level: 1, numbering: none)
set par(justify: false, leading: 1.5em, first-line-indent: 2em)
show par: it => {
it
v(5pt)
}
bibliography(path, title:"参考文献")
}
// 致谢,请手动调用
#let acknowledgement(body) = {
// 这个取消目录里的 numbering
set heading(level: 1, numbering: none)
show <_thx>: {
// 这个取消展示时的 numbering
set heading(level: 1, numbering: none)
set align(center)
set text(weight: "bold", font: heiti, size: 18pt)
pad(bottom: 1em, "致 谢")
}
[= 致谢 <_thx>]
set par(justify: false, leading: 1.5em, first-line-indent: 2em)
show par: it => {
it
v(5pt)
}
body
}
// 中文摘要
#let zh_abstract_page(abstract, keywords: ()) = {
v(2em)
align(center)[
#text(font: heiti, size: 18pt, "摘 要")
]
set text(font: songti, size: 12pt)
set par(justify: false, leading: 1.5em, first-line-indent: 2em)
show par: it => {
it
v(5pt)
}
abstract
par(first-line-indent: 0em)[
#text(weight: "bold", font: heiti, size: 12pt)[
关键词:
#keywords.join(";")
]
]
}
// 英文摘要
#let en_abstract_page(abstract, keywords: ()) = {
v(2em)
align(center)[
#text(weight: "bold", font: heiti, size: 18pt, "Abstract")
]
set text(font: songti, size: 12pt)
set par(justify: false, leading: 1.5em, first-line-indent: 2em)
show par: it => {
it
v(5pt)
}
abstract
par(first-line-indent: 0em)[
#text(weight: "bold", font: heiti, size: 12pt)[
Key Words:
#keywords.join("; ")
]
]
}
#let project(
title: "",
abstract_zh: [],
abstract_en: [],
keywords_zh: (),
keywords_en: (),
school: "",
author: "",
id: "",
mentor: "",
class: "",
date: (1926, 8, 17),
body,
) = {
// 图表公式的排版
show figure: it => {
set align(center)
if it.kind == "image" {
set text(font: heiti, size: 12pt)
it.body
it.supplement
" " + it.counter.display(it.numbering)
" " + it.caption
locate(loc => {
let chapt = counter(heading).at(loc).at(0)
let c = counter("image-chapter" + str(chapt))
c.step()
})
} else if it.kind == "table" {
set text(font: heiti, size: 12pt)
it.supplement
" " + it.counter.display(it.numbering)
" " + it.caption
set text(font: songti, size: 10.5pt)
it.body
locate(loc => {
let chapt = counter(heading).at(loc).at(0)
let c = counter("table-chapter" + str(chapt))
c.step()
})
} else if it.kind == "equation" {
// 通过大比例来达到中间和靠右的排布
grid(
columns: (20fr, 1fr),
it.body,
align(center + horizon,
it.counter.display(it.numbering)
)
)
locate(loc => {
let chapt = counter(heading).at(loc).at(0)
let c = counter("equation-chapter" + str(chapt))
c.step()
})
} else {
it
}
}
set page(paper: "a4", margin: (
top: 2.5cm,
bottom: 2.5cm,
left: 3cm,
right: 3cm
))
// 封面
align(center)[
// hust logo
#v(30pt)
#image("./assets/hust.png", width: 55%)
#v(50pt)
#text(
size: 36pt,
font: "Songti SC",
weight: "bold"
)[本科生毕业设计(论文)]
#v(40pt)
#text(
font: heiti,
size: 20pt,
)[
#title
]
#v(100pt)
#let info_value(body) = {
rect(
width: 100%,
inset: 2pt,
stroke: (
bottom: 1pt + black
),
text(
font: songti,
size: 16pt,
bottom-edge: "descender"
)[
#body
]
)
}
#let info_key(body) = {
rect(width: 100%, inset: 2pt,
stroke: none,
text(
font: songti,
size: 16pt,
body
))
}
#grid(
columns: (70pt, 180pt),
rows: (40pt, 40pt),
gutter: 3pt,
info_key("院 系"),
info_value(school),
info_key("专业班级"),
info_value(class),
info_key("姓 名"),
info_value(author),
info_key("学 号"),
info_value(id),
info_key("指导教师"),
info_value(mentor),
)
#v(40pt)
#text(
font: songti,
size: 16pt,
)[
#date.at(0) 年 #date.at(1) 月 #date.at(2) 日
]
]
counter(page).update(0)
// 页眉
set page(
header: {
set text(font: songti, 10pt, baseline: 8pt, spacing: 3pt)
set align(center)
[华 中 科 技 大 学 毕 业 设 计 (论 文)]
line(length: 100%, stroke: 0.7pt)
}
)
// 页脚
// 封面不算页数
set page(
footer: {
set align(center)
grid(
columns: (5fr, 1fr, 5fr),
line(length: 200pt, stroke: 0.7pt),
text(font: songti, 10pt, baseline: -3pt,
counter(page).display("I")
),
line(length: 200pt, stroke: 0.7pt)
)
}
)
// 原创性声明
declaration()
pagebreak()
counter(page).update(1)
// 摘要
zh_abstract_page(abstract_zh, keywords: keywords_zh)
pagebreak()
// abstract
en_abstract_page(abstract_en, keywords: keywords_en)
pagebreak()
// 目录
toc()
counter(page).update(0)
pagebreak()
// 正文的页脚
set page(
footer: {
set align(center)
grid(
columns: (5fr, 1fr, 5fr),
line(length: 200pt, stroke: 0.7pt),
text(font: songti, 10pt, baseline: -3pt,
counter(page).display("1")
),
line(length: 200pt, stroke: 0.7pt)
)
}
)
set heading(numbering: (..nums) => {
nums.pos().map(str).join(".") + " "
})
show heading.where(level: 1): it => {
set align(center)
set text(weight: "bold", font: heiti, size: 18pt)
it
}
show heading.where(level: 2): it => {
set text(weight: "bold", font: heiti, size: 14pt)
it
}
show heading: it => {
set text(weight: "bold", font: heiti, size: 12pt)
pad(bottom: 1em, it)
}
set text(font: songti, 12pt)
set par(justify: false, leading: 1.5em, first-line-indent: 2em)
show par: it => {
it
v(5pt)
}
body
}