main
1
2#import "layouts/doc.typ": doc
3#import "layouts/preface.typ": preface
4#import "layouts/mainmatter.typ": mainmatter
5#import "layouts/appendix.typ": appendix
6#import "pages/bachelor-cover.typ": bachelor-cover
7#import "pages/bachelor-integrity.typ": bachelor-integrity
8#import "pages/acknowledgement.typ": acknowledgement
9#import "pages/bachelor-abstract.typ": bachelor-abstract
10#import "pages/bachelor-abstract-en.typ": bachelor-abstract-en
11#import "pages/bachelor-outline-page.typ": bachelor-outline-page
12#import "pages/bachelor-outline-page-en.typ": bachelor-outline-page-en
13#import "pages/bilingual-bibliography.typ": bilingual-bibliography
14#import "utils/style.typ": 字体, 字号
15
16// 使用函数闭包特性,通过 `documentclass` 函数类进行全局信息配置,然后暴露出拥有了全局配置的、具体的 `layouts` 和 `templates` 内部函数。
17#let documentclass(
18 twoside: false, // 双面模式,会加入空白页,便于打印
19 fonts: (:), // 字体,应传入「宋体」、「黑体」、「楷体」、「仿宋」、「等宽」
20 info: (:),
21) = {
22 fonts = 字体 + fonts
23 info = (
24 (
25 title: ("基于 Typst 的", "厦门大学本科毕业论文模板"),
26 title-en: "An XMU Undergraduate Thesis Template\nPowered by Typst",
27 grade: "20XX",
28 student-id: "1234567890",
29 author: "张三",
30 department: "某学院",
31 major: "某专业",
32 field: "某方向",
33 supervisor: ("李四", "教授"),
34 supervisor-outside: (),
35 submit-date: datetime.today(),
36 )
37 + info
38 )
39
40 return (
41 // 将传入参数再导出
42 twoside: twoside,
43 fonts: fonts,
44 info: info,
45 // 页面布局
46 doc: (..args) => {
47 doc(
48 ..args,
49 info: info + args.named().at("info", default: (:)),
50 )
51 },
52 preface: (..args) => {
53 preface(
54 twoside: twoside,
55 ..args,
56 fonts: fonts + args.named().at("fonts", default: (:)),
57 )
58 },
59 mainmatter: (..args) => {
60 mainmatter(
61 twoside: twoside,
62 ..args,
63 info: info + args.named().at("info", default: (:)),
64 fonts: fonts + args.named().at("fonts", default: (:)),
65 )
66 },
67 appendix: (..args) => appendix(..args),
68 // 封面页
69 cover: (..args) => bachelor-cover(
70 twoside: twoside,
71 ..args,
72 fonts: fonts + args.named().at("fonts", default: (:)),
73 info: info + args.named().at("info", default: (:)),
74 ),
75 // 诚信承诺书页
76 integrity: (..args) => bachelor-integrity(
77 twoside: twoside,
78 ..args,
79 fonts: fonts + args.named().at("fonts", default: (:)),
80 ),
81 // 致谢页
82 acknowledgement: (..args) => acknowledgement(
83 twoside: twoside,
84 ..args,
85 fonts: fonts + args.named().at("fonts", default: (:)),
86 ),
87 // 中文摘要页
88 abstract: (..args) => bachelor-abstract(
89 twoside: twoside,
90 ..args,
91 fonts: fonts + args.named().at("fonts", default: (:)),
92 ),
93 // 英文摘要页
94 abstract-en: (..args) => bachelor-abstract-en(
95 twoside: twoside,
96 ..args,
97 fonts: fonts + args.named().at("fonts", default: (:)),
98 ),
99 // 中文目录页
100 outline-page: (..args) => bachelor-outline-page(
101 twoside: twoside,
102 ..args,
103 fonts: fonts + args.named().at("fonts", default: (:)),
104 ),
105 // 英文目录页
106 outline-page-en: (..args) => bachelor-outline-page-en(
107 twoside: twoside,
108 ..args,
109 fonts: fonts + args.named().at("fonts", default: (:)),
110 ),
111 // 双语参考文献页
112 bilingual-bibliography: (..args) => bilingual-bibliography(..args),
113 )
114}