Skip to content

Commit fc4a33f

Browse files
committed
fix: refine bachelor thesis layout
Signed-off-by: Juntong Chen <[email protected]>
1 parent 27176f9 commit fc4a33f

10 files changed

+107
-53
lines changed

README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@
1515

1616
对于研究生,我们参考华东师范大研究生院于 2023 年发布的[华东师范大学博士、硕士学位论文基本格式要求](https://yjsy.ecnu.edu.cn/8e/62/c42090a429666/page.htm);对于本科生,我们参考华东师范大学教务处于 2021 年更新的[华东师范大学本科生毕业论文(设计)格式要求](http://www.jwc.ecnu.edu.cn/d4/be/c40573a513214/page.htm)。格式适配于 2025 年初,后续使用的同学请留意参考校方的最新通知。
1717

18-
![1736471485839](https://jtchen.s3.ap-northeast-1.amazonaws.com/v1/img/2025/01/09/1736471485839.png)
19-
20-
在这里可以找到硕士学位论文的示例文档:[thesis.pdf](https://github.com/jtchen2k/modern-ecnu-thesis/releases/download/0.1.0/thesis.pdf)
18+
![1736643710702](https://jtchen.s3.ap-northeast-1.amazonaws.com/v1/img/2025/01/11/1736643710702.png)
19+
20+
示例文档:
21+
- 本科学位论文 [modern-ecnu-thesis-bachelor.pdf](https://github.com/jtchen2k/modern-ecnu-thesis/releases/latest/download/modern-ecnu-thesis-bachelor.pdf)
22+
- 硕士学位论文,学术学位 [modern-ecnu-thesis-master-academic.pdf](https://github.com/jtchen2k/modern-ecnu-thesis/releases/latest/download/modern-ecnu-thesis-master-academic.pdf)
23+
- 硕士学位论文,专业学位 [modern-ecnu-thesis-master-professional.pdf](https://github.com/jtchen2k/modern-ecnu-thesis/releases/latest/download/modern-ecnu-thesis-master-professional.pdf)
24+
- 博士学位论文,学术学位 [modern-ecnu-thesis-doctor-academic.pdf](https://github.com/jtchen2k/modern-ecnu-thesis/releases/latest/download/modern-ecnu-thesis-doctor-academic.pdf)
25+
- 博士学位论文,专业学位 [modern-ecnu-thesis-doctor-professional.pdf](https://github.com/jtchen2k/modern-ecnu-thesis/releases/latest/download/modern-ecnu-thesis-doctor-professional.pdf)
2126

2227
## Why Typst
2328

layouts/appendix.typ

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
#import "@preview/i-figured:0.2.4"
22
#import "../utils/custom-numbering.typ": custom-numbering
3-
3+
#import "../utils/style.typ": 字号, 字体
4+
#import "../utils/invisible-heading.typ": invisible-heading
45

56
// 后记,重置 heading 计数器
67
#let appendix(
8+
doctype: "master",
79
numbering: custom-numbering.with(first-level: "", depth: 4, "1.1 "),
810
// figure 计数
911
show-figure: i-figured.show-figure.with(numbering: "1.1"),
1012
// equation 计数
1113
show-equation: i-figured.show-equation.with(numbering: "(1.1)"),
1214
// 重置计数
1315
reset-counter: false,
16+
fonts: (:),
1417
it,
1518
) = {
1619
set heading(numbering: numbering)
@@ -21,5 +24,6 @@
2124
show figure: show-figure
2225
// 设置 equation 的编号
2326
show math.equation.where(block: true): show-equation
27+
2428
it
2529
}

layouts/mainmatter.typ

+13-4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
show-figure: i-figured.show-figure,
4848
// equation 计数
4949
show-equation: i-figured.show-equation,
50+
// heading 文字(本科生论文需要)
51+
heading-extra: "华东师范大学本科毕业论文",
5052
..args,
5153
it,
5254
) = {
@@ -155,10 +157,14 @@
155157
// 4.1 设置标题的 Numbering
156158
set heading(numbering: numbering)
157159
// 4.2 设置字体字号并加入假段落模拟首行缩进
158-
show heading: it => {
160+
show heading: it => context {
159161
set text(
160162
font: array-at(heading-font, it.level),
161-
size: array-at(heading-size, it.level),
163+
size: if it.level == 1 {
164+
if state("in-mainmatter").get() { array-at(heading-size, it.level) } else {
165+
if doctype == "bachelor" { 字号.小三 } else { 字号.三号 }
166+
}
167+
} else { array-at(heading-size, it.level) },
162168
weight: array-at(heading-weight, it.level),
163169
..unpairs(heading-text-args-lists
164170
.map((pair) => (pair.at(0), array-at(pair.at(1), it.level))))
@@ -171,15 +177,15 @@
171177
fake-par
172178
}
173179
// 4.3 标题居中与自动换页
174-
show heading: it => {
180+
show heading: it => context {
175181
if (array-at(heading-pagebreak, it.level)) {
176182
// 如果打上了 no-auto-pagebreak 标签,则不自动换页
177183
if ("label" not in it.fields() or str(it.label) != "no-auto-pagebreak") {
178184
pagebreak(weak: true)
179185
}
180186
}
181187
if (array-at(heading-align, it.level) != auto) {
182-
set align(array-at(heading-align, it.level))
188+
set align(if state("in-mainmatter").get() { array-at(heading-align, it.level) } else { center })
183189
it
184190
} else {
185191
it
@@ -224,6 +230,9 @@
224230
#metadata(state("total-characters").final()) <total-chars>
225231
]
226232

233+
let s = state("in-mainmatter", true)
234+
context s.update(true)
235+
227236
it
228237
// 正文结束标志,不可缺少
229238
// 这里放在附录后面,使得页码能正确计数

lib.typ

+38-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @project: modern-ecnu-thesis
55
* @author: OrangeX4, Juntong Chen ([email protected])
66
* @created: 2025-01-06 22:37:34
7-
* @modified: 2025-01-11 15:11:45
7+
* @modified: 2025-01-11 16:46:35
88
*
99
* 华东师范大学学位论文模板
1010
* Repo: https://github.com/jtchen2k/modern-ecnu-thesis
@@ -54,6 +54,15 @@
5454
fonts: (:), // 字体,应传入「宋体」、「黑体」、「楷体」、「仿宋」、「等宽」
5555
info: (:),
5656
) = {
57+
58+
// 开发用,用 sys input 覆盖 doctype 以方便编译多种类型的文档
59+
if "doctype" in sys.inputs {
60+
doctype = sys.inputs.at("doctype")
61+
}
62+
if "degree" in sys.inputs {
63+
degree = sys.inputs.at("degree")
64+
}
65+
5766
// 默认参数
5867
fonts = 字体 + fonts
5968
info = (
@@ -105,13 +114,32 @@
105114
preface(doctype: doctype, twoside: twoside, ..args)
106115
},
107116
mainmatter: (..args) => {
108-
mainmatter(doctype: doctype, twoside: twoside, display-header: true, ..args, fonts: fonts + args.named().at("fonts", default: (:)))
117+
if doctype == "bachelor" {
118+
mainmatter(doctype: doctype, twoside: twoside, display-header: true,
119+
heading-size: (字号.小四, 字号.小四,),
120+
numbering: custom-numbering.with(first-level: "1. ", depth: 4, "1.1 "),
121+
heading-align: (left, auto),
122+
heading-above: (0em, 1.8em),
123+
heading-below: (1.8em, 1.5em),
124+
..args, fonts: fonts + args.named().at("fonts", default: (:)))
125+
} else {
126+
mainmatter(doctype: doctype, twoside: twoside, display-header: true, ..args, fonts: fonts + args.named().at("fonts", default: (:)))
127+
}
109128
},
110129
mainmatter-end: (..args) => {
111130
mainmatter-end(..args)
112131
},
113132
appendix: (..args) => {
114-
appendix(..args)
133+
if doctype == "bachelor" {
134+
appendix(
135+
doctype: doctype,
136+
numbering: custom-numbering.with(first-level: "", depth: 4, "1.1 "),
137+
..args,
138+
fonts: fonts + args.named().at("fonts", default: (:))
139+
)
140+
} else {
141+
appendix(doctype: doctype, ..args)
142+
}
115143
},
116144
// 字体展示页
117145
fonts-display-page: (..args) => {
@@ -228,12 +256,12 @@
228256
doctype: doctype,
229257
twoside: twoside,
230258
size: (字号.小四, 字号.小四),
231-
font: (fonts.黑体, fonts.宋体),
259+
font: (fonts.宋体, fonts.宋体),
232260
weight: ("bold", "regular"),
233-
title-text-args: (font: 字体.黑体, size: 字号.三号, weight: "bold"),
261+
title-text-args: (font: 字体.黑体, size: 字号.小三, weight: "bold"),
234262
show-heading: true,
235263
vspace: (1.2em, 1em),
236-
indent: (0em, 2.38em, 2em, 2.8em),
264+
indent: (0em, 1.4em, 2em, 2.8em),
237265
..args,
238266
fonts: fonts + args.named().at("fonts", default: (:)),
239267
)
@@ -257,7 +285,7 @@
257285
list-of-figures(
258286
twoside: twoside,
259287
show-heading: true,
260-
title-text-args: (font: 字体.黑体, size: 字号.三号, weight: "bold"),
288+
title-text-args: (font: 字体.黑体, size: if doctype == "master" { 字号.三号 } else { 字号.小三 } , weight: "bold"),
261289
doctype: doctype,
262290
..args,
263291
fonts: fonts + args.named().at("fonts", default: (:)),
@@ -270,7 +298,7 @@
270298
twoside: twoside,
271299
doctype: doctype,
272300
show-heading: true,
273-
title-text-args: (font: 字体.黑体, size: 字号.三号, weight: "bold"),
301+
title-text-args: (font: 字体.黑体, size: if doctype == "master" { 字号.三号 } else { 字号.小三 } , weight: "bold"),
274302
..args,
275303
fonts: fonts + args.named().at("fonts", default: (:)),
276304
)
@@ -281,8 +309,8 @@
281309
notation(
282310
twoside: twoside,
283311
show-heading: true,
284-
title-text-args: (font: 字体.黑体, size: 字号.三号, weight: "bold"),
285-
doctype: doctype,
312+
title-text-args: (font: 字体.黑体, size: if doctype == "master" { 字号.三号 } else { 字号.小三 } , weight: "bold"),
313+
doctype: doctype,
286314
..args,
287315
fonts: fonts + args.named().at("fonts", default: (:)),
288316
)

pages/bachelor-abstract-en.typ

+8-10
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
// 其他参数
1616
keywords: (),
1717
outline-title: "Abstract",
18-
outlined: false,
18+
outlined: true,
1919
anonymous-info-keys: ("author-en", "supervisor-en", "supervisor-ii-en"),
20-
leading: 1.28em,
21-
spacing: 1.38em,
20+
leading: 1.2em,
21+
spacing: 1.25em,
2222
body,
2323
) = {
2424
// 1. 默认参数
@@ -61,24 +61,22 @@
6161
#invisible-heading(level: 1, outlined: outlined, outline-title)
6262

6363
#align(center)[
64-
#set text(font: fonts.黑体, size: 字号.三号)
65-
#context s.get()
64+
#set text(font: fonts.黑体, size: 字号.小三)
65+
Abstract
6666
]
6767

6868
#v(1em)
6969

70-
*Abstract:*
71-
72-
#set text(font: fonts.宋体)
70+
#set text(font: fonts.宋体, size: 字号.五号)
7371

7472
#[
7573
#set par(first-line-indent: 2em)
7674
#fake-par
7775
#body
7876
]
7977

80-
#v(1em)
78+
#v(2.5em)
8179

82-
*Keywords: *_#(("",) + keywords.intersperse(", ")).sum()_
80+
*Keywords: *#h(0.25em)#(("",) + keywords.intersperse(", ")).sum()
8381
]
8482
}

pages/bachelor-abstract.typ

+6-8
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
outline-title: "摘要",
1919
outlined: true,
2020
anonymous-info-keys: ("author", "supervisor", "supervisor-ii"),
21-
leading: 1.28em,
22-
spacing: 1.28em,
21+
leading: 1.25em,
22+
spacing: 1.25em,
2323
body,
2424
) = {
2525
// 1. 默认参数
@@ -57,22 +57,20 @@
5757
#invisible-heading(level: 1, outlined: outlined, outline-title)
5858

5959
#align(center)[
60-
#set text(font: fonts.黑体, size: 字号.三号)
61-
#context s.get()
60+
#set text(font: fonts.黑体, size: 字号.小三)
61+
摘要
6262
]
6363

6464
#v(1em)
65-
#text(font: fonts.黑体)[摘要:]
66-
67-
#set text(font: fonts.宋体)
65+
#set text(font: fonts.宋体, size: 字号.五号)
6866

6967
#[
7068
#set par(first-line-indent: 2em)
7169
#fake-par
7270
#body
7371
]
7472

75-
#v(1em)
73+
#v(2.5em)
7674

7775
#text(font: fonts.黑体)[关键词:]#(("",)+ keywords.intersperse("")).sum()
7876
]

pages/bachelor-cover.typ

+11-11
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
bold-level: "bold",
2525
datetime-display: datetime-display-bachelor,
2626
title-line-length: 320pt,
27-
title-line-length-en: 300pt,
27+
title-line-length-en: 320pt,
2828
meta-info-line-length: 200pt,
2929
meta-info-line-length-en: 230pt,
3030
) = {
@@ -63,11 +63,11 @@
6363
width: 100%,
6464
inset: info-inset,
6565
stroke: none,
66-
text(font: fonts.at(info-key-font, default: "宋体"), weight: "bold", size: 字号.小三, body + if with-tail { "" } else { "" }),
66+
text(font: fonts.at(info-key-font, default: "宋体"), weight: "bold", size: 字号.四号, body + if with-tail { "" } else { "" }),
6767
)
6868
}
6969

70-
let info-value(size: 字号.小三, key, body) = {
70+
let info-value(size: 字号.四号, key, body) = {
7171
set align(center)
7272
rect(width: 100%, inset: info-inset, stroke: (bottom: stoke-width + black), text(
7373
font: fonts.at(info-value-font, default: "宋体"),
@@ -78,15 +78,15 @@
7878
))
7979
}
8080

81-
let info-long-value(size: 字号.小三, key, body) = {
81+
let info-long-value(size: 字号.四号, key, body) = {
8282
grid.cell(colspan: 3, info-value(size: size, key, if anonymous and (key in anonymous-info-keys) {
8383
"██████████"
8484
} else {
8585
body
8686
}))
8787
}
8888

89-
let info-title-value(size: 字号.小一, body) = {
89+
let info-title-value(size: 字号.一号, body) = {
9090
set align(center)
9191
underline(offset: 6pt, stroke: 1.25pt, text(
9292
font: fonts.at(info-value-font, default: "宋体"),
@@ -124,15 +124,15 @@
124124
学校代码:#underline(stroke: 0.5pt, offset: 3pt)[*10269*]
125125
]
126126

127-
v(12pt)
127+
v(5pt)
128128

129129
// 匿名化处理去掉封面标识
130130
if anonymous {
131131
v(60pt)
132132
} else {
133133
// 封面图标
134134
v(6pt)
135-
image("../assets/ecnu-bachelor-thesis-cover.svg", width: 10cm)
135+
image("../assets/ecnu-bachelor-thesis-cover.svg", width: 9.5cm)
136136
}
137137

138138
if anonymous {
@@ -142,13 +142,13 @@
142142
}
143143

144144
stack(dir: ttb, spacing: 1fr,
145-
block(width: title-line-length)[
145+
block(width: title-line-length * 1.5)[
146146
#stack(
147147
dir: ttb,
148148
spacing: 12pt,
149-
..info.title.map((it) => info-title-value(size: 字号.小一, it)),
149+
..info.title.map((it) => info-title-value(size: 字号.一号, it)),
150150
h(0.5em),
151-
..info.title-en.map((it) => info-title-value(size: 字号.二号, it))
151+
..info.title-en.map((it) => info-title-value(size: 字号.一号, it))
152152
)
153153
],
154154

@@ -160,7 +160,7 @@
160160
info-long-value("author", info.author),
161161
info-key("学  号"),
162162
info-long-value("student-id", info.student-id),
163-
info-key("院  系"),
163+
info-key("学  院"),
164164
..info.department.map((it) => info-long-value("department", it)).intersperse(info-key("", with-tail: false)),
165165
info-key("专  业"),
166166
info-long-value("major", info.major),

0 commit comments

Comments
 (0)