Skip to content

Commit fc24420

Browse files
committed
chore(release):prepare for modern-sysu-thesis:0.4.1
1 parent d4ac49c commit fc24420

36 files changed

+1983
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 SYSU Typst Thesis Template Authors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# 基于 Typst 的中山大学学位论文模板
2+
<!-- [![GitLab 最新版本](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/badges/release.svg?style=flat-square)](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/releases/permalink/latest) -->
3+
[![GitHub stars](https://img.shields.io/github/stars/sysu/better-thesis.svg?style=social&label=Star&maxAge=2592000)](https://github.com/sysu/better-thesis)
4+
5+
**[点击此处注册 typst.app 并创建你的论文工程](https://typst.app/app?template=modern-sysu-thesis&version=0.3.0)**
6+
7+
本科生模板已经符合学位论文格式要求(~~[#6](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/issues/6)~~),欢迎同学/校友们[贡献代码](https://github.com/sysu/better-thesis/pulls)/反馈问题([GitHub issue][issues])!
8+
9+
模板交流 QQ 群:[797942860](https://jq.qq.com/?_wv=1027&k=m58va1kd)
10+
11+
12+
## 参考规范
13+
- 本科生论文模板参考 [中山大学本科生毕业论文(设计)写作与印制规范 2020年发](https://spa.sysu.edu.cn/zh-hans/article/1744)
14+
- 研究生论文模板参考 [中山大学研究生学位论文格式要求](https://graduate.sysu.edu.cn/sites/graduate.prod.dpcms4.sysu.edu.cn/files/2019-04/%E4%B8%AD%E5%B1%B1%E5%A4%A7%E5%AD%A6%E7%A0%94%E7%A9%B6%E7%94%9F%E5%AD%A6%E4%BD%8D%E8%AE%BA%E6%96%87%E6%A0%BC%E5%BC%8F%E8%A6%81%E6%B1%82.pdf)
15+
16+
## 使用方法
17+
18+
### typst.app
19+
经过近一月紧张的迭代重构,本模板已经[发布在typst-app.universe](https://typst.app/universe/package/modern-sysu-thesis)上,[点击此处直接创建你的论文工程](https://typst.app/app?template=modern-sysu-thesis&version=0.3.0),并直接开始编写你的论文!
20+
21+
<!-- TODO(#1): 在 typst.universe 版本上线后分离模板项目 -->
22+
23+
### Windows 用户
24+
25+
1. [下载本仓库][download],或者使用 `git clone https://github.com/sysu/better-thesis` 命令克隆本仓库。
26+
2. 右键 `install_typst.ps1` 文件,选择“用 Powershell 运行”,等待 Typst 安装完成。
27+
3. 根据 [Typst 文档](https://typst.app/docs/),参考 [项目结构](#项目结构) 中的说明,按照你的需要修改论文的各个部分。
28+
4. 双击运行 `compile.bat`,即可生成 `thesis.pdf` 文件。
29+
30+
### Linux/macOS 用户
31+
32+
1. [下载本仓库][download],或者使用 `git clone https://github.com/sysu/better-thesis` 命令克隆本仓库。
33+
2. 使用命令行安装 Rust 工具链以及 Typst:
34+
35+
```bash
36+
# 安装 Rust 环境并激活,之前安装过则不需要执行下面这两行
37+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
38+
source $HOME/.cargo/env
39+
40+
# 安装 Typst CLI
41+
cargo install typst-cli
42+
43+
# 访问缓慢的话,执行以下命令设置清华镜像源,并从镜像站安装
44+
cat << EOF > $HOME/.cargo/config
45+
[source.crates-io]
46+
replace-with = "tuna"
47+
48+
[source.tuna]
49+
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
50+
EOF
51+
cargo install typst-cli
52+
```
53+
54+
3. 根据 [Typst 文档](https://typst.app/docs/),参考 [项目结构](#项目结构) 中的说明,按照你的需要修改论文的各个部分。
55+
4. 执行 `make` 命令,即可生成 `thesis.pdf` 文件。
56+
57+
## 项目结构
58+
详见 `template\thesis.typ`
59+
60+
## FAQ
61+
### 为什么 XXX 的功能不能用/不符合预期?
62+
1. 先参考 [Typst 中文支持相关问题](https://typst-doc-cn.github.io/docs/chinese/),以及 [Typst 官方文档](https://typst.app/docs/)[tpyst.app/universe 仓库](https://typst.app/universe),了解相关问题进展或解决方案
63+
2. 如果在以上资料中找不到关联资料,可以参考是否在的 [issue 列表][issues] 中能找到相关问题与进展。
64+
3. 如果依然没有线索,欢迎反馈问题([GitHub issue][issues]
65+
66+
### 为什么学校学位论文已经有了 [LaTeX 模板](https://github.com/SYSU-SCC/sysu-thesis),还有 Typst 模板?
67+
- 前述 LaTeX 模板目前仅有计算机学院官方指定使用,其他学院并没有统一指定
68+
- 考虑到 LaTeX 对于大部分非计算机/理工科的学生入门成本比较高,因此有必要提供一种更加简洁清晰并且方便的论文模板,包括:
69+
- 开箱即用:
70+
- 如[前文所述](#typstapp),本模板提供了在线直接编辑/保存/备份方案
71+
- 本地使用模板时,模板组件可以简单地通过 `typst` 命令自动管理安装
72+
- 语法简洁:typst 是与 markdown 类似的标记性语言,可以通过标记的方式来轻松控制语法(如`= 标题``*粗体*``_斜体_` `@引用`、 数学公式`$E = m c^2$`
73+
74+
### 为什么有两份 Typst 模板([sysu-thesis-typst] 和 modern-sysu-thesis)?
75+
后者是在前者的基础上,同时参考 [modern-nju-thesis] ,改造后适配了 [typst.app/universe](https://typst.app/universe)。以及,放到 [@sysu](https://github.com/sysu) 组织下提高了曝光度。
76+
77+
## 致谢
78+
- 感谢 [sysu-thesis-typst] 提供了中山大学的页面样式与初版源码
79+
- 感谢 [modern-nju-thesis] 提供了一个更好的代码组织架构
80+
- 感谢中山大学 Typst 模板交流群([797942860](https://jq.qq.com/?_wv=1027&k=m58va1kd))、Typst 中文交流群(793548390)群友的帮助交流。
81+
82+
[issues]: https://github.com/sysu/better-thesis/issues
83+
[download]: https://github.com/sysu/better-thesis
84+
[sysu-thesis-typst]: https://github.com/howardlau1999/sysu-thesis-typst
85+
[modern-nju-thesis]: https://typst.app/universe/package/modern-nju-thesis

packages/preview/modern-sysu-thesis/0.4.1/assets/vi/sysu_logo.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#import "@preview/i-figured:0.2.4"
2+
#import "../utils/custom-numbering.typ": custom-numbering
3+
4+
// 后记,重置 heading 计数器
5+
#let appendix(
6+
numbering: custom-numbering.with(first-level: "", depth: 4, "1.1 "),
7+
// figure 计数
8+
show-figure: i-figured.show-figure.with(numbering: "1.1"),
9+
// equation 计数
10+
show-equation: i-figured.show-equation.with(numbering: "(1.1)"),
11+
// 重置计数
12+
reset-counter: false,
13+
it,
14+
) = {
15+
set heading(numbering: numbering)
16+
if reset-counter {
17+
counter(heading).update(0)
18+
}
19+
// 设置 figure 的编号
20+
show figure: show-figure
21+
// 设置 equation 的编号
22+
show math.equation.where(block: true): show-equation
23+
it
24+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// 文稿设置,可以进行一些像页面边距这类的全局设置
2+
#let doc(
3+
// documentclass 传入参数
4+
info: (:),
5+
// 其他参数
6+
fallback: false, // 字体缺失时使用 fallback,不显示豆腐块
7+
lang: "zh",
8+
margin: (x: 89pt),
9+
it,
10+
) = {
11+
// 1. 默认参数
12+
info = (
13+
title: ("基于 Typst 的", "中山大学学位论文模板"),
14+
author: "张三",
15+
) + info
16+
17+
// 2. 对参数进行处理
18+
// 2.1 如果是字符串,则使用换行符将标题分隔为列表
19+
if type(info.title) == str {
20+
info.title = info.title.split("\n")
21+
}
22+
23+
// 3. 基本的样式设置
24+
set text(fallback: fallback, lang: lang)
25+
set page(margin: margin)
26+
27+
// 4. PDF 元信息
28+
set document(
29+
title: (("",)+ info.title).sum(),
30+
author: info.author,
31+
)
32+
33+
it
34+
}
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
#import "@preview/anti-matter:0.0.2": anti-front-end
2+
#import "@preview/i-figured:0.2.4"
3+
#import "../utils/style.typ": 字号, 字体
4+
#import "../utils/custom-numbering.typ": custom-numbering
5+
#import "../utils/custom-heading.typ": heading-display, active-heading, current-heading
6+
#import "../utils/unpairs.typ": unpairs
7+
8+
#let mainmatter(
9+
// documentclass 传入参数
10+
twoside: false,
11+
fonts: (:),
12+
// 其他参数
13+
leading: 1.5 * 15.6pt - 0.7em,
14+
spacing: 1.5 * 15.6pt - 0.7em,
15+
justify: true,
16+
first-line-indent: (amount: 2em, all: true),
17+
numbering: custom-numbering.with(first-level: "第一章 ", depth: 4, "1.1 "),
18+
// 正文字体与字号参数
19+
text-args: auto,
20+
// 标题字体与字号
21+
heading-font: (字体.黑体, 字体.黑体, 字体.宋体),
22+
heading-size: (字号.三号, 字号.四号, 字号.小四),
23+
heading-weight: ("regular", "regular", "bold"),
24+
heading-above: (2 * 15.6pt - 0.7em, 2 * 15.6pt - 0.7em),
25+
heading-below: (2 * 15.6pt - 0.7em, 1.5 * 15.6pt - 0.7em),
26+
heading-pagebreak: (true, false),
27+
heading-align: (center, left, auto),
28+
// 页眉
29+
header-render: auto,
30+
header-vspace: 0em,
31+
display-header: false,
32+
skip-on-first-level: true,
33+
stroke-width: 0.5pt,
34+
reset-footnote: true,
35+
// caption 的 separator
36+
separator: " ",
37+
// caption 样式
38+
caption-style: strong,
39+
caption-size: 字号.五号,
40+
// figure 计数
41+
show-figure: i-figured.show-figure,
42+
// equation 计数
43+
show-equation: i-figured.show-equation,
44+
..args,
45+
it,
46+
) = {
47+
// 0. 标志前言结束
48+
anti-front-end()
49+
50+
// 1. 默认参数
51+
fonts = 字体 + fonts
52+
if (text-args == auto) {
53+
text-args = (font: fonts.宋体, size: 字号.小四)
54+
}
55+
// 1.1 字体与字号
56+
if (heading-font == auto) {
57+
heading-font = (fonts.黑体,)
58+
}
59+
// 1.2 处理 heading- 开头的其他参数
60+
let heading-text-args-lists = args.named().pairs()
61+
.filter((pair) => pair.at(0).starts-with("heading-"))
62+
.map((pair) => (pair.at(0).slice("heading-".len()), pair.at(1)))
63+
64+
// 2. 辅助函数
65+
let array-at(arr, pos) = {
66+
arr.at(calc.min(pos, arr.len()) - 1)
67+
}
68+
69+
// 3. 设置基本样式
70+
// 3.1 文本和段落样式
71+
set text(..text-args)
72+
set par(
73+
leading: leading,
74+
justify: justify,
75+
first-line-indent: first-line-indent
76+
)
77+
show par: set block(spacing: spacing)
78+
// 3.2 脚注样式
79+
show footnote.entry: set text(font: fonts.宋体, size: 字号.五号)
80+
// 3.3 设置 figure 的编号
81+
show heading: i-figured.reset-counters
82+
show figure: show-figure
83+
// 3.4 设置 equation 的编号和假段落首行缩进
84+
show math.equation.where(block: true): show-equation
85+
// 3.5 表格表头置顶 + 不用冒号用空格分割 + 样式
86+
show figure.where(
87+
kind: table
88+
): set figure.caption(position: top)
89+
set figure.caption(separator: separator)
90+
show figure.caption: caption-style
91+
show figure.caption: set text(font: fonts.宋体, size: 字号.五号)
92+
// 3.6 优化列表显示
93+
// 术语列表 terms 不应该缩进
94+
show terms: set par(first-line-indent: 0pt)
95+
96+
// 4. 处理标题
97+
// 4.1 设置标题的 Numbering
98+
set heading(numbering: numbering)
99+
// 4.2 设置字体字号并加入假段落模拟首行缩进
100+
show heading: it => {
101+
set text(
102+
font: array-at(heading-font, it.level),
103+
size: array-at(heading-size, it.level),
104+
weight: array-at(heading-weight, it.level),
105+
..unpairs(heading-text-args-lists
106+
.map((pair) => (pair.at(0), array-at(pair.at(1), it.level))))
107+
)
108+
set block(
109+
above: array-at(heading-above, it.level),
110+
below: array-at(heading-below, it.level),
111+
)
112+
it
113+
}
114+
// 4.3 标题居中与自动换页
115+
show heading: it => {
116+
if (array-at(heading-pagebreak, it.level)) {
117+
// 如果打上了 no-auto-pagebreak 标签,则不自动换页
118+
if ("label" not in it.fields() or str(it.label) != "no-auto-pagebreak") {
119+
pagebreak(weak: true)
120+
}
121+
}
122+
if (array-at(heading-align, it.level) != auto) {
123+
set align(array-at(heading-align, it.level))
124+
it
125+
} else {
126+
pad(left: 2em, it)
127+
}
128+
}
129+
130+
// 5. 处理页眉
131+
set page(..(if display-header {
132+
(
133+
header: {
134+
// 重置 footnote 计数器
135+
if reset-footnote {
136+
counter(footnote).update(0)
137+
}
138+
locate(loc => {
139+
// 5.1 获取当前页面的一级标题
140+
let cur-heading = current-heading(level: 1, loc)
141+
// 5.2 如果当前页面没有一级标题,则渲染页眉
142+
if not skip-on-first-level or cur-heading == none {
143+
if header-render == auto {
144+
// 一级标题和二级标题
145+
let first-level-heading = if not twoside or calc.rem(loc.page(), 2) == 0 { heading-display(active-heading(level: 1, loc)) } else { "" }
146+
let second-level-heading = if not twoside or calc.rem(loc.page(), 2) == 2 { heading-display(active-heading(level: 2, prev: false, loc)) } else { "" }
147+
set text(font: fonts.宋体, size: 字号.五号)
148+
stack(
149+
first-level-heading + h(1fr) + second-level-heading,
150+
v(0.25em),
151+
if first-level-heading != "" or second-level-heading != "" { line(length: 100%, stroke: stroke-width + black) },
152+
)
153+
} else {
154+
header-render(loc)
155+
}
156+
v(header-vspace)
157+
}
158+
})
159+
}
160+
)
161+
} else {
162+
(
163+
header: {
164+
// 重置 footnote 计数器
165+
if reset-footnote {
166+
counter(footnote).update(0)
167+
}
168+
}
169+
)
170+
}))
171+
172+
it
173+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#import "@preview/anti-matter:0.0.2": anti-matter
2+
3+
// 前言,重置页面计数器
4+
#let preface(
5+
// documentclass 传入的参数
6+
twoside: false,
7+
// 其他参数
8+
spec: (front: "I", inner: "1", back: "I"),
9+
..args,
10+
it,
11+
) = {
12+
// 分页
13+
if (twoside) {
14+
pagebreak() + " "
15+
}
16+
counter(page).update(0)
17+
anti-matter(spec: spec, ..args, it)
18+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// 中山大学学位论文 Typst 模板 modern-sysu-thesis
2+
// 基于 [南京大学学位论文模板](https://github.com/nju-lug/modern-nju-thesis) 重构中
3+
// Repo: https://gitlab.com/sysu-gitlab/thesis-template/better-thesis
4+
// https://typst.app/universe/package/modern-sysu-thesis
5+
6+
#import "/specifications/bachelor/lib.typ" as bachelor

0 commit comments

Comments
 (0)