Skip to content

Commit

Permalink
fix: refine bachelor thesis layout
Browse files Browse the repository at this point in the history
Signed-off-by: Juntong Chen <[email protected]>
  • Loading branch information
jtchen2k committed Jan 12, 2025
1 parent 27176f9 commit fc4a33f
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 53 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@

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

![1736471485839](https://jtchen.s3.ap-northeast-1.amazonaws.com/v1/img/2025/01/09/1736471485839.png)

在这里可以找到硕士学位论文的示例文档:[thesis.pdf](https://github.com/jtchen2k/modern-ecnu-thesis/releases/download/0.1.0/thesis.pdf)
![1736643710702](https://jtchen.s3.ap-northeast-1.amazonaws.com/v1/img/2025/01/11/1736643710702.png)

示例文档:
- 本科学位论文 [modern-ecnu-thesis-bachelor.pdf](https://github.com/jtchen2k/modern-ecnu-thesis/releases/latest/download/modern-ecnu-thesis-bachelor.pdf)
- 硕士学位论文,学术学位 [modern-ecnu-thesis-master-academic.pdf](https://github.com/jtchen2k/modern-ecnu-thesis/releases/latest/download/modern-ecnu-thesis-master-academic.pdf)
- 硕士学位论文,专业学位 [modern-ecnu-thesis-master-professional.pdf](https://github.com/jtchen2k/modern-ecnu-thesis/releases/latest/download/modern-ecnu-thesis-master-professional.pdf)
- 博士学位论文,学术学位 [modern-ecnu-thesis-doctor-academic.pdf](https://github.com/jtchen2k/modern-ecnu-thesis/releases/latest/download/modern-ecnu-thesis-doctor-academic.pdf)
- 博士学位论文,专业学位 [modern-ecnu-thesis-doctor-professional.pdf](https://github.com/jtchen2k/modern-ecnu-thesis/releases/latest/download/modern-ecnu-thesis-doctor-professional.pdf)

## Why Typst

Expand Down
6 changes: 5 additions & 1 deletion layouts/appendix.typ
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#import "@preview/i-figured:0.2.4"
#import "../utils/custom-numbering.typ": custom-numbering

#import "../utils/style.typ": 字号, 字体
#import "../utils/invisible-heading.typ": invisible-heading

// 后记,重置 heading 计数器
#let appendix(
doctype: "master",
numbering: custom-numbering.with(first-level: "", depth: 4, "1.1 "),
// figure 计数
show-figure: i-figured.show-figure.with(numbering: "1.1"),
// equation 计数
show-equation: i-figured.show-equation.with(numbering: "(1.1)"),
// 重置计数
reset-counter: false,
fonts: (:),
it,
) = {
set heading(numbering: numbering)
Expand All @@ -21,5 +24,6 @@
show figure: show-figure
// 设置 equation 的编号
show math.equation.where(block: true): show-equation

it
}
17 changes: 13 additions & 4 deletions layouts/mainmatter.typ
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
show-figure: i-figured.show-figure,
// equation 计数
show-equation: i-figured.show-equation,
// heading 文字(本科生论文需要)
heading-extra: "华东师范大学本科毕业论文",
..args,
it,
) = {
Expand Down Expand Up @@ -155,10 +157,14 @@
// 4.1 设置标题的 Numbering
set heading(numbering: numbering)
// 4.2 设置字体字号并加入假段落模拟首行缩进
show heading: it => {
show heading: it => context {
set text(
font: array-at(heading-font, it.level),
size: array-at(heading-size, it.level),
size: if it.level == 1 {
if state("in-mainmatter").get() { array-at(heading-size, it.level) } else {
if doctype == "bachelor" { 字号.小三 } else { 字号.三号 }
}
} else { array-at(heading-size, it.level) },
weight: array-at(heading-weight, it.level),
..unpairs(heading-text-args-lists
.map((pair) => (pair.at(0), array-at(pair.at(1), it.level))))
Expand All @@ -171,15 +177,15 @@
fake-par
}
// 4.3 标题居中与自动换页
show heading: it => {
show heading: it => context {
if (array-at(heading-pagebreak, it.level)) {
// 如果打上了 no-auto-pagebreak 标签,则不自动换页
if ("label" not in it.fields() or str(it.label) != "no-auto-pagebreak") {
pagebreak(weak: true)
}
}
if (array-at(heading-align, it.level) != auto) {
set align(array-at(heading-align, it.level))
set align(if state("in-mainmatter").get() { array-at(heading-align, it.level) } else { center })
it
} else {
it
Expand Down Expand Up @@ -224,6 +230,9 @@
#metadata(state("total-characters").final()) <total-chars>
]

let s = state("in-mainmatter", true)
context s.update(true)

it
// 正文结束标志,不可缺少
// 这里放在附录后面,使得页码能正确计数
Expand Down
48 changes: 38 additions & 10 deletions lib.typ
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @project: modern-ecnu-thesis
* @author: OrangeX4, Juntong Chen ([email protected])
* @created: 2025-01-06 22:37:34
* @modified: 2025-01-11 15:11:45
* @modified: 2025-01-11 16:46:35
*
* 华东师范大学学位论文模板
* Repo: https://github.com/jtchen2k/modern-ecnu-thesis
Expand Down Expand Up @@ -54,6 +54,15 @@
fonts: (:), // 字体,应传入「宋体」、「黑体」、「楷体」、「仿宋」、「等宽」
info: (:),
) = {

// 开发用,用 sys input 覆盖 doctype 以方便编译多种类型的文档
if "doctype" in sys.inputs {
doctype = sys.inputs.at("doctype")
}
if "degree" in sys.inputs {
degree = sys.inputs.at("degree")
}

// 默认参数
fonts = 字体 + fonts
info = (
Expand Down Expand Up @@ -105,13 +114,32 @@
preface(doctype: doctype, twoside: twoside, ..args)
},
mainmatter: (..args) => {
mainmatter(doctype: doctype, twoside: twoside, display-header: true, ..args, fonts: fonts + args.named().at("fonts", default: (:)))
if doctype == "bachelor" {
mainmatter(doctype: doctype, twoside: twoside, display-header: true,
heading-size: (字号.小四, 字号.小四,),
numbering: custom-numbering.with(first-level: "1. ", depth: 4, "1.1 "),
heading-align: (left, auto),
heading-above: (0em, 1.8em),
heading-below: (1.8em, 1.5em),
..args, fonts: fonts + args.named().at("fonts", default: (:)))
} else {
mainmatter(doctype: doctype, twoside: twoside, display-header: true, ..args, fonts: fonts + args.named().at("fonts", default: (:)))
}
},
mainmatter-end: (..args) => {
mainmatter-end(..args)
},
appendix: (..args) => {
appendix(..args)
if doctype == "bachelor" {
appendix(
doctype: doctype,
numbering: custom-numbering.with(first-level: "", depth: 4, "1.1 "),
..args,
fonts: fonts + args.named().at("fonts", default: (:))
)
} else {
appendix(doctype: doctype, ..args)
}
},
// 字体展示页
fonts-display-page: (..args) => {
Expand Down Expand Up @@ -228,12 +256,12 @@
doctype: doctype,
twoside: twoside,
size: (字号.小四, 字号.小四),
font: (fonts.黑体, fonts.宋体),
font: (fonts.宋体, fonts.宋体),
weight: ("bold", "regular"),
title-text-args: (font: 字体.黑体, size: 字号.三号, weight: "bold"),
title-text-args: (font: 字体.黑体, size: 字号.小三, weight: "bold"),
show-heading: true,
vspace: (1.2em, 1em),
indent: (0em, 2.38em, 2em, 2.8em),
indent: (0em, 1.4em, 2em, 2.8em),
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
)
Expand All @@ -257,7 +285,7 @@
list-of-figures(
twoside: twoside,
show-heading: true,
title-text-args: (font: 字体.黑体, size: 字号.三号, weight: "bold"),
title-text-args: (font: 字体.黑体, size: if doctype == "master" { 字号.三号 } else { 字号.小三 } , weight: "bold"),
doctype: doctype,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
Expand All @@ -270,7 +298,7 @@
twoside: twoside,
doctype: doctype,
show-heading: true,
title-text-args: (font: 字体.黑体, size: 字号.三号, weight: "bold"),
title-text-args: (font: 字体.黑体, size: if doctype == "master" { 字号.三号 } else { 字号.小三 } , weight: "bold"),
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
)
Expand All @@ -281,8 +309,8 @@
notation(
twoside: twoside,
show-heading: true,
title-text-args: (font: 字体.黑体, size: 字号.三号, weight: "bold"),
doctype: doctype,
title-text-args: (font: 字体.黑体, size: if doctype == "master" { 字号.三号 } else { 字号.小三 } , weight: "bold"),
doctype: doctype,
..args,
fonts: fonts + args.named().at("fonts", default: (:)),
)
Expand Down
18 changes: 8 additions & 10 deletions pages/bachelor-abstract-en.typ
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
// 其他参数
keywords: (),
outline-title: "Abstract",
outlined: false,
outlined: true,
anonymous-info-keys: ("author-en", "supervisor-en", "supervisor-ii-en"),
leading: 1.28em,
spacing: 1.38em,
leading: 1.2em,
spacing: 1.25em,
body,
) = {
// 1. 默认参数
Expand Down Expand Up @@ -61,24 +61,22 @@
#invisible-heading(level: 1, outlined: outlined, outline-title)

#align(center)[
#set text(font: fonts.黑体, size: 字号.三号)
#context s.get()
#set text(font: fonts.黑体, size: 字号.小三)
Abstract
]

#v(1em)

*Abstract:*

#set text(font: fonts.宋体)
#set text(font: fonts.宋体, size: 字号.五号)

#[
#set par(first-line-indent: 2em)
#fake-par
#body
]

#v(1em)
#v(2.5em)

*Keywords: *_#(("",) + keywords.intersperse(", ")).sum()_
*Keywords: *#h(0.25em)#(("",) + keywords.intersperse(", ")).sum()
]
}
14 changes: 6 additions & 8 deletions pages/bachelor-abstract.typ
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
outline-title: "摘要",
outlined: true,
anonymous-info-keys: ("author", "supervisor", "supervisor-ii"),
leading: 1.28em,
spacing: 1.28em,
leading: 1.25em,
spacing: 1.25em,
body,
) = {
// 1. 默认参数
Expand Down Expand Up @@ -57,22 +57,20 @@
#invisible-heading(level: 1, outlined: outlined, outline-title)

#align(center)[
#set text(font: fonts.黑体, size: 字号.三号)
#context s.get()
#set text(font: fonts.黑体, size: 字号.小三)
摘要
]

#v(1em)
#text(font: fonts.黑体)[摘要:]

#set text(font: fonts.宋体)
#set text(font: fonts.宋体, size: 字号.五号)

#[
#set par(first-line-indent: 2em)
#fake-par
#body
]

#v(1em)
#v(2.5em)

#text(font: fonts.黑体)[关键词:]#(("",)+ keywords.intersperse("")).sum()
]
Expand Down
22 changes: 11 additions & 11 deletions pages/bachelor-cover.typ
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
bold-level: "bold",
datetime-display: datetime-display-bachelor,
title-line-length: 320pt,
title-line-length-en: 300pt,
title-line-length-en: 320pt,
meta-info-line-length: 200pt,
meta-info-line-length-en: 230pt,
) = {
Expand Down Expand Up @@ -63,11 +63,11 @@
width: 100%,
inset: info-inset,
stroke: none,
text(font: fonts.at(info-key-font, default: "宋体"), weight: "bold", size: 字号.小三, body + if with-tail { "" } else { "" }),
text(font: fonts.at(info-key-font, default: "宋体"), weight: "bold", size: 字号.四号, body + if with-tail { "" } else { "" }),
)
}

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

let info-long-value(size: 字号.小三, key, body) = {
let info-long-value(size: 字号.四号, key, body) = {
grid.cell(colspan: 3, info-value(size: size, key, if anonymous and (key in anonymous-info-keys) {
"██████████"
} else {
body
}))
}

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

v(12pt)
v(5pt)

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

if anonymous {
Expand All @@ -142,13 +142,13 @@
}

stack(dir: ttb, spacing: 1fr,
block(width: title-line-length)[
block(width: title-line-length * 1.5)[
#stack(
dir: ttb,
spacing: 12pt,
..info.title.map((it) => info-title-value(size: 字号.小一, it)),
..info.title.map((it) => info-title-value(size: 字号.一号, it)),
h(0.5em),
..info.title-en.map((it) => info-title-value(size: 字号.二号, it))
..info.title-en.map((it) => info-title-value(size: 字号.一号, it))
)
],

Expand All @@ -160,7 +160,7 @@
info-long-value("author", info.author),
info-key("学  号"),
info-long-value("student-id", info.student-id),
info-key("院  系"),
info-key("学  院"),
..info.department.map((it) => info-long-value("department", it)).intersperse(info-key("", with-tail: false)),
info-key("专  业"),
info-long-value("major", info.major),
Expand Down
Loading

0 comments on commit fc4a33f

Please sign in to comment.