-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: sysu-bot <huangjj27@mail2.sysu.edu.cn>
- Loading branch information
Showing
36 changed files
with
1,980 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 SYSU Typst Thesis Template Authors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# 基于 Typst 的中山大学学位论文模板 | ||
[](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/releases/permalink/latest) [](https://github.com/sysu/better-thesis) | ||
|
||
**[点击此处注册 typst.app 并创建你的论文工程](https://typst.app/app?template=modern-sysu-thesis&version=0.1.1)** | ||
|
||
本科生模板已经符合学位论文格式要求([#6](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/issues/6)),欢迎同学/校友们[贡献代码](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/merge_requests)/反馈问题([GitLab issue](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/issues)/[邮件](mailto:contact-project+sysu-gitlab-thesis-template-better-thesis-57823416-issue-@incoming.gitlab.com))! | ||
|
||
模板交流 QQ 群:[797942860](https://jq.qq.com/?_wv=1027&k=m58va1kd) | ||
|
||
|
||
## 参考规范 | ||
- 本科生论文模板参考 [中山大学本科生毕业论文(设计)写作与印制规范 2020年发](https://spa.sysu.edu.cn/zh-hans/article/1744) | ||
- 研究生论文模板参考 [中山大学研究生学位论文格式要求](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) | ||
|
||
## 使用方法 | ||
|
||
### typst.app | ||
经过近一月紧张的迭代重构,本模板已经[发布在typst-app.universe](https://typst.app/universe/package/modern-sysu-thesis)上,[点击此处直接创建你的论文工程](https://typst.app/app?template=modern-sysu-thesis&version=0.2.0),并直接开始编写你的论文! | ||
|
||
<!-- TODO(#1): 在 typst.universe 版本上线后分离模板项目 --> | ||
|
||
### Windows 用户 | ||
|
||
1. [下载本仓库](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/archive/main/better-thesis-main.zip),或者使用 `git clone https://gitlab.com/sysu-gitlab/thesis-template/better-thesis` 命令克隆本仓库。 | ||
2. 右键 `install_typst.ps1` 文件,选择“用 Powershell 运行”,等待 Typst 安装完成。 | ||
3. 根据 [Typst 文档](https://typst.app/docs/),参考 [项目结构](#项目结构) 中的说明,按照你的需要修改论文的各个部分。 | ||
4. 双击运行 `compile.bat`,即可生成 `thesis.pdf` 文件。 | ||
|
||
### Linux/macOS 用户 | ||
|
||
1. [下载本仓库](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/archive/main/better-thesis-main.zip),或者使用 `git clone https://gitlab.com/sysu-gitlab/thesis-template/better-thesis` 命令克隆本仓库。 | ||
2. 使用命令行安装 Rust 工具链以及 Typst: | ||
|
||
```bash | ||
# 安装 Rust 环境并激活,之前安装过则不需要执行下面这两行 | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
source $HOME/.cargo/env | ||
|
||
# 安装 Typst CLI | ||
cargo install typst-cli | ||
|
||
# 访问缓慢的话,执行以下命令设置清华镜像源,并从镜像站安装 | ||
cat << EOF > $HOME/.cargo/config | ||
[source.crates-io] | ||
replace-with = "tuna" | ||
[source.tuna] | ||
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git" | ||
EOF | ||
cargo install typst-cli | ||
``` | ||
|
||
3. 根据 [Typst 文档](https://typst.app/docs/),参考 [项目结构](#项目结构) 中的说明,按照你的需要修改论文的各个部分。 | ||
4. 执行 `make` 命令,即可生成 `thesis.pdf` 文件。 | ||
|
||
## 项目结构 | ||
详见 `template\thesis.typ` | ||
|
||
## FAQ | ||
### 为什么 XXX 的功能不能用/不符合预期? | ||
1. 先参考 [Typst 中文支持相关问题](https://typst-doc-cn.github.io/docs/chinese/),以及 [Typst 官方文档](https://typst.app/docs/) 与 [tpyst.app/universe 仓库](https://typst.app/universe),了解相关问题进展或解决方案 | ||
2. 如果在以上资料中找不到关联资料,可以参考是否在的 [issue 列表](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/issues) 中能找到相关问题与进展。 | ||
3. 如果依然没有线索,欢迎反馈问题([GitLab issue](https://gitlab.com/sysu-gitlab/thesis-template/better-thesis/-/issues)/[邮件](mailto:contact-project+sysu-gitlab-thesis-template-better-thesis-57823416-issue-@incoming.gitlab.com)) | ||
|
||
### 为什么学校学位论文已经有了 [LaTeX 模板](https://github.com/SYSU-SCC/sysu-thesis),还有 Typst 模板? | ||
- 前述 LaTeX 模板目前仅有计算机学院官方指定使用,其他学院并没有统一指定 | ||
- 考虑到 LaTeX 对于大部分非计算机/理工科的学生入门成本比较高,因此有必要提供一种更加简洁清晰并且方便的论文模板,包括: | ||
- 开箱即用: | ||
- 如[前文所述](#typstapp),本模板提供了在线直接编辑/保存/备份方案 | ||
- 本地使用模板时,模板组件可以简单地通过 `typst` 命令自动管理安装 | ||
- 语法简洁:typst 是与 markdown 类似的标记性语言,可以通过标记的方式来轻松控制语法(如`= 标题`、`*粗体*`、`_斜体_` `@引用`、 数学公式`$E = m c^2$`) | ||
|
||
### 为什么有两份 Typst 模板([sysu-thesis-typst] 和 modern-sysu-thesis)? | ||
后者是在前者的基础上,同时参考 [modern-nju-thesis] ,改造后适配了 [typst.app/universe](https://typst.app/universe)。以及,放到 [@sysu](https://github.com/sysu) 组织下提高了曝光度。 | ||
|
||
## 致谢 | ||
- 感谢 [sysu-thesis-typst] 提供了中山大学的页面样式与初版源码 | ||
- 感谢 [modern-nju-thesis] 提供了一个更好的代码组织架构 | ||
- 感谢中山大学 Typst 模板交流群([797942860](https://jq.qq.com/?_wv=1027&k=m58va1kd))、Typst 中文交流群(793548390)群友的帮助交流。 | ||
|
||
[sysu-thesis-typst]: https://github.com/howardlau1999/sysu-thesis-typst | ||
[modern-nju-thesis]: https://typst.app/universe/package/modern-nju-thesis |
1 change: 1 addition & 0 deletions
1
packages/preview/modern-sysu-thesis/0.4.0/assets/vi/sysu_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions
24
packages/preview/modern-sysu-thesis/0.4.0/layouts/appendix.typ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#import "@preview/i-figured:0.2.4" | ||
#import "../utils/custom-numbering.typ": custom-numbering | ||
|
||
// 后记,重置 heading 计数器 | ||
#let appendix( | ||
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, | ||
it, | ||
) = { | ||
set heading(numbering: numbering) | ||
if reset-counter { | ||
counter(heading).update(0) | ||
} | ||
// 设置 figure 的编号 | ||
show figure: show-figure | ||
// 设置 equation 的编号 | ||
show math.equation.where(block: true): show-equation | ||
it | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// 文稿设置,可以进行一些像页面边距这类的全局设置 | ||
#let doc( | ||
// documentclass 传入参数 | ||
info: (:), | ||
// 其他参数 | ||
fallback: false, // 字体缺失时使用 fallback,不显示豆腐块 | ||
lang: "zh", | ||
margin: (x: 89pt), | ||
it, | ||
) = { | ||
// 1. 默认参数 | ||
info = ( | ||
title: ("基于 Typst 的", "中山大学学位论文模板"), | ||
author: "张三", | ||
) + info | ||
|
||
// 2. 对参数进行处理 | ||
// 2.1 如果是字符串,则使用换行符将标题分隔为列表 | ||
if type(info.title) == str { | ||
info.title = info.title.split("\n") | ||
} | ||
|
||
// 3. 基本的样式设置 | ||
set text(fallback: fallback, lang: lang) | ||
set page(margin: margin) | ||
|
||
// 4. PDF 元信息 | ||
set document( | ||
title: (("",)+ info.title).sum(), | ||
author: info.author, | ||
) | ||
|
||
it | ||
} |
173 changes: 173 additions & 0 deletions
173
packages/preview/modern-sysu-thesis/0.4.0/layouts/mainmatter.typ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
#import "@preview/anti-matter:0.0.2": anti-front-end | ||
#import "@preview/i-figured:0.2.4" | ||
#import "../utils/style.typ": 字号, 字体 | ||
#import "../utils/custom-numbering.typ": custom-numbering | ||
#import "../utils/custom-heading.typ": heading-display, active-heading, current-heading | ||
#import "../utils/unpairs.typ": unpairs | ||
|
||
#let mainmatter( | ||
// documentclass 传入参数 | ||
twoside: false, | ||
fonts: (:), | ||
// 其他参数 | ||
leading: 1.5 * 15.6pt - 0.7em, | ||
spacing: 1.5 * 15.6pt - 0.7em, | ||
justify: true, | ||
first-line-indent: (amount: 2em, all: true), | ||
numbering: custom-numbering.with(first-level: "第一章 ", depth: 4, "1.1 "), | ||
// 正文字体与字号参数 | ||
text-args: auto, | ||
// 标题字体与字号 | ||
heading-font: (字体.黑体, 字体.黑体, 字体.宋体), | ||
heading-size: (字号.三号, 字号.四号, 字号.小四), | ||
heading-weight: ("regular", "regular", "bold"), | ||
heading-above: (2 * 15.6pt - 0.7em, 2 * 15.6pt - 0.7em), | ||
heading-below: (2 * 15.6pt - 0.7em, 1.5 * 15.6pt - 0.7em), | ||
heading-pagebreak: (true, false), | ||
heading-align: (center, left, auto), | ||
// 页眉 | ||
header-render: auto, | ||
header-vspace: 0em, | ||
display-header: false, | ||
skip-on-first-level: true, | ||
stroke-width: 0.5pt, | ||
reset-footnote: true, | ||
// caption 的 separator | ||
separator: " ", | ||
// caption 样式 | ||
caption-style: strong, | ||
caption-size: 字号.五号, | ||
// figure 计数 | ||
show-figure: i-figured.show-figure, | ||
// equation 计数 | ||
show-equation: i-figured.show-equation, | ||
..args, | ||
it, | ||
) = { | ||
// 0. 标志前言结束 | ||
anti-front-end() | ||
|
||
// 1. 默认参数 | ||
fonts = 字体 + fonts | ||
if (text-args == auto) { | ||
text-args = (font: fonts.宋体, size: 字号.小四) | ||
} | ||
// 1.1 字体与字号 | ||
if (heading-font == auto) { | ||
heading-font = (fonts.黑体,) | ||
} | ||
// 1.2 处理 heading- 开头的其他参数 | ||
let heading-text-args-lists = args.named().pairs() | ||
.filter((pair) => pair.at(0).starts-with("heading-")) | ||
.map((pair) => (pair.at(0).slice("heading-".len()), pair.at(1))) | ||
|
||
// 2. 辅助函数 | ||
let array-at(arr, pos) = { | ||
arr.at(calc.min(pos, arr.len()) - 1) | ||
} | ||
|
||
// 3. 设置基本样式 | ||
// 3.1 文本和段落样式 | ||
set text(..text-args) | ||
set par( | ||
leading: leading, | ||
justify: justify, | ||
first-line-indent: first-line-indent | ||
) | ||
show par: set block(spacing: spacing) | ||
// 3.2 脚注样式 | ||
show footnote.entry: set text(font: fonts.宋体, size: 字号.五号) | ||
// 3.3 设置 figure 的编号 | ||
show heading: i-figured.reset-counters | ||
show figure: show-figure | ||
// 3.4 设置 equation 的编号和假段落首行缩进 | ||
show math.equation.where(block: true): show-equation | ||
// 3.5 表格表头置顶 + 不用冒号用空格分割 + 样式 | ||
show figure.where( | ||
kind: table | ||
): set figure.caption(position: top) | ||
set figure.caption(separator: separator) | ||
show figure.caption: caption-style | ||
show figure.caption: set text(font: fonts.宋体, size: 字号.五号) | ||
// 3.6 优化列表显示 | ||
// 术语列表 terms 不应该缩进 | ||
show terms: set par(first-line-indent: 0pt) | ||
|
||
// 4. 处理标题 | ||
// 4.1 设置标题的 Numbering | ||
set heading(numbering: numbering) | ||
// 4.2 设置字体字号并加入假段落模拟首行缩进 | ||
show heading: it => { | ||
set text( | ||
font: array-at(heading-font, it.level), | ||
size: 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)))) | ||
) | ||
set block( | ||
above: array-at(heading-above, it.level), | ||
below: array-at(heading-below, it.level), | ||
) | ||
it | ||
} | ||
// 4.3 标题居中与自动换页 | ||
show heading: it => { | ||
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)) | ||
it | ||
} else { | ||
pad(left: 2em, it) | ||
} | ||
} | ||
|
||
// 5. 处理页眉 | ||
set page(..(if display-header { | ||
( | ||
header: { | ||
// 重置 footnote 计数器 | ||
if reset-footnote { | ||
counter(footnote).update(0) | ||
} | ||
locate(loc => { | ||
// 5.1 获取当前页面的一级标题 | ||
let cur-heading = current-heading(level: 1, loc) | ||
// 5.2 如果当前页面没有一级标题,则渲染页眉 | ||
if not skip-on-first-level or cur-heading == none { | ||
if header-render == auto { | ||
// 一级标题和二级标题 | ||
let first-level-heading = if not twoside or calc.rem(loc.page(), 2) == 0 { heading-display(active-heading(level: 1, loc)) } else { "" } | ||
let second-level-heading = if not twoside or calc.rem(loc.page(), 2) == 2 { heading-display(active-heading(level: 2, prev: false, loc)) } else { "" } | ||
set text(font: fonts.宋体, size: 字号.五号) | ||
stack( | ||
first-level-heading + h(1fr) + second-level-heading, | ||
v(0.25em), | ||
if first-level-heading != "" or second-level-heading != "" { line(length: 100%, stroke: stroke-width + black) }, | ||
) | ||
} else { | ||
header-render(loc) | ||
} | ||
v(header-vspace) | ||
} | ||
}) | ||
} | ||
) | ||
} else { | ||
( | ||
header: { | ||
// 重置 footnote 计数器 | ||
if reset-footnote { | ||
counter(footnote).update(0) | ||
} | ||
} | ||
) | ||
})) | ||
|
||
it | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/preview/modern-sysu-thesis/0.4.0/layouts/preface.typ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#import "@preview/anti-matter:0.0.2": anti-matter | ||
|
||
// 前言,重置页面计数器 | ||
#let preface( | ||
// documentclass 传入的参数 | ||
twoside: false, | ||
// 其他参数 | ||
spec: (front: "I", inner: "1", back: "I"), | ||
..args, | ||
it, | ||
) = { | ||
// 分页 | ||
if (twoside) { | ||
pagebreak() + " " | ||
} | ||
counter(page).update(0) | ||
anti-matter(spec: spec, ..args, it) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// 中山大学学位论文 Typst 模板 modern-sysu-thesis | ||
// 基于 [南京大学学位论文模板](https://github.com/nju-lug/modern-nju-thesis) 重构中 | ||
// Repo: https://gitlab.com/sysu-gitlab/thesis-template/better-thesis | ||
// https://typst.app/universe/package/modern-sysu-thesis | ||
|
||
#import "/specifications/bachelor/lib.typ" as bachelor |
Oops, something went wrong.