Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/preview/gzu-thesis-unofficial/0.1.0/LICENSE-ASSETS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Asset License Notice

The files in the `assets/` directory are NOT covered by the MIT License.

In particular:

- assets/gzu_logo.png
- assets/gzu_name.png

contains the logo and trademarks of Guizhou University(贵州大学).

All rights to these assets are reserved by their respective owners.

These assets may not be redistributed, modified, or used except as permitted by the trademark owner or applicable law.

The MIT License applies only to the source code and template files of this repository.
21 changes: 21 additions & 0 deletions packages/preview/gzu-thesis-unofficial/0.1.0/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 chengwu26

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.
42 changes: 42 additions & 0 deletions packages/preview/gzu-thesis-unofficial/0.1.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 贵州大学本科生毕业论文(设计)模板
This is a Typst template for undergraduate thesis (design) at Guizhou University.

Comment thread
saecki marked this conversation as resolved.
## 模板介绍
此模板参考
[《贵州大学毕业论文(设计)管理办法(试行)》(2025 年 4 月)](assets/贵州大学毕业论文(设计)管理办法(试行).pdf)

Check failure on line 6 in packages/preview/gzu-thesis-unofficial/0.1.0/README.md

View check run for this annotation

Typst package check / @preview/gzu-thesis-unofficial:0.1.0

packages/preview/gzu-thesis-unofficial/0.1.0/README.md#L6

Linked file not found: `/assets/%E8%B4%B5%E5%B7%9E%E5%A4%A7%E5%AD%A6%E6%AF%95%E4%B8%9A%E8%AE%BA%E6%96%87%EF%BC%88%E8%AE%BE%E8%AE%A1%EF%BC%89%E7%AE%A1%E7%90%86%E5%8A%9E%E6%B3%95%EF%BC%88%E8%AF%95%E8%A1%8C%EF%BC%89.pdf`. Make sure to commit all linked files and possibly add them to the `exclude` list. More details: https://github.com/typst/packages/blob/main/docs/tips.md#what-to-commit-what-to-exclude
Comment thread
saecki marked this conversation as resolved.
制作。

## 使用方法
可在官方网页端在线使用,只需在仪表板上点击 “Start from template”,
然后搜索 gzu-thesis-unofficial。

另外,你也可以在本地使用下面的命令来启动这个项目。
```bash
typst init @preview/gzu-thesis-unofficial
```
Typst 将会创建一个新的目录,其中包含此模板的一套示例,可阅读代码了解使用方法,
关于此模板的更多内容可查看 [模板手册](manual.pdf)

## 模板预览
![封面](assets/thumbnail.png)

## 存在的问题
目前存在参考文献超过三位作者时,中英文文献均会统一用“等”省略后续作者,
无法智能地在英文条目中使用“et al”。此问题源自于 Typst
现在还未支持多语言参考文献,暂时没有比较优雅的解决方式。

## License
本项目中的 Typst 模板源代码依据 MIT 许可证进行授权。

学校校徽、校名标识及其他受商标权、著作权保护的资源文件不在 MIT
许可证授权范围内,其知识产权归相关权利人所有。
除法律法规另有规定或已获得相关授权外,不得对上述资源进行再分发、
修改或用于其他用途。

具体说明请参阅 `LICENSE-ASSETS` 文件。

The Typst template source code is licensed under MIT.

The university logo and other trademarked assets located in `assets/`
are excluded from the MIT license and remain the property of their
respective owners. See LICENSE-ASSETS for details.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages/preview/gzu-thesis-unofficial/0.1.0/lib.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#import "/src/main.typ": gzu-thesis
#import "/src/styles/table.typ": bottomrule, cmidrule, continued-header, midrule, toprule
Binary file not shown.
62 changes: 62 additions & 0 deletions packages/preview/gzu-thesis-unofficial/0.1.0/manual.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#import "@preview/tidy:0.4.3"

#set page(height: auto)
#set text(font: ("Times New Roman", "SimSun"), size: 13pt, lang: "zh", region: "cn")
#show strong: set text(font: ("Times New Roman", "SimHei"))
#show heading: set text(font: ("Times New Roman", "SimHei"))
#show heading.where(level: 1): set block(above: 2em, below: 1em)
#set par(first-line-indent: (amount: 2em, all: true), justify: true)
#set list(indent: 2em)
#show link: underline
#show link: set text(fill: blue)

#let gzu-thesis = tidy.parse-module(read("/src/main.typ"))
#let tree-line-table = tidy.parse-module(read("/src/styles/table.typ"))

#align(center, title[「贵州大学本科生毕业论文(设计)」Typst 模板手册])
#outline(depth: 3)

= 介绍
此模板参考《贵州大学毕业论文(设计)管理办法(试行)》(2025 年 4 月)(以下简称「规范」)制作,如需查阅此文件,可在
#link(
"https://github.com/chengwu26/gzu-thesis/blob/master/assets/贵州大学毕业论文(设计)管理办法(试行).pdf",
)[代码仓库]
中查看。此模板仅对「规范」中要求的样式进行了预定义,不提供过多额外的内容,在需要时可组合其他包来实现。
*唯一例外的是*,此模板对公式编号采用了“(1-1)”的两级编号模式。

此模板提供的用于创建可跨页表格的接口显得不那么人体工学(见后文关于 `continued-header` 函数的介绍)。但此实现并非强制使用,
你完全可以使用你认为更好的实现。

= 常见问题
下面是截止完成此模板时最新的 Typst 版本 (0.15.0) 仍然存在的一些问题及解决方案:
- 列表文字和序号/符号出现错位,可使用 #link("https://typst.app/universe/package/itemize")[itemize] 包解决。
关于此问题的描述还可查阅 #link("https://guide.typst.dev/FAQ/fix-enum-list")[修复列表的终极方案] 了解。
- 在源码中的中文换行会导致错误分词并自动在换行处插入空白符,可使用
#link("https://typst.app/universe/package/cjk-spacer")[cjk-spacer]、
#link("https://typst.app/universe/package/cjk-unbreak")[cjk-unbreak]、
#link("https://typst.app/universe/package/remove-cjk-break-space")[remove-cjk-break-space]
包或
#link("https://guide.typst.dev/FAQ/chinese-remove-space.html")[写中文文档时,如何去掉源码中换行导致的空格?]
描述的方案(选其一)。


= 此模板提供的 API
#set par(first-line-indent: 0em)

== 模板函数
用法示例可参考你使用此模板创建的项目目录中的 `main.typ` 文件

#tidy.show-module(
gzu-thesis,
omit-private-definitions: true,
show-outline: false,
)

#v(3em)
== 三线表与可跨页表辅助函数
#tidy.show-module(
tree-line-table,
omit-private-definitions: true,
show-outline: false,
sort-functions: none,
)
12 changes: 12 additions & 0 deletions packages/preview/gzu-thesis-unofficial/0.1.0/src/fonts.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// 西文字体
#let serif_en = "Times New Roman"

// 宋体
#let song = "SimSun"
// 黑体
#let hei = "SimHei"

// 中英文混合时的衬线体方案
#let serif = ((name: serif_en, covers: "latin-in-cjk"), song, "New Computer Modern Math")
// 中英文混合时的无衬线体方案,西文字符依然使用衬线体
#let sans = ((name: serif_en, covers: "latin-in-cjk"), hei, "New Computer Modern Math")
165 changes: 165 additions & 0 deletions packages/preview/gzu-thesis-unofficial/0.1.0/src/main.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
#import "@preview/numbly:0.1.0": numbly
#import "@preview/pointless-size:0.1.2": zh

#import "fonts.typ"
#import "styles.typ"
#import "pages/abstract.typ": abstract
#import "pages/integrity-statement.typ": integrity-statement
#import "pages/cover.typ": cover


// 这个函数仅仅用于为 PDF 元数据的 `author` 提供字符串
// 对非 content 和 str 类型将返回空字符串。
#let _to-string(it) = {
if type(it) == str {
it
} else if type(it) != content {
""
} else if it.has("text") {
it.text
} else if it.has("children") {
it.children.map(_to-string).join()
} else if it.has("body") {
_to-string(it.body)
} else {
""
}
}

/// 模板入口函数。
/// -> content
#let gzu-thesis(
/// 论文题目(中文)
/// -> str | content
title-zh: [],
/// 论文题目(英文)
/// -> str | content
title-en: [],
/// 封面和签名日期。省略时默认为当前日期。
/// -> content | none
date: datetime.today(),
/// 论文作者
///
/// 通常情况传入字符串即可,如若希望在封面页姓名中加入空白,可使用简单的 content,如
/// `[姓#h(1em)名]` 可在姓名中插入一个字符宽度的空白。
/// -> str | content
author: [],
/// 学院名称。同 @gzu-thesis.author
/// -> str | content
college: [],
/// 专业名称。同 @gzu-thesis.author
/// -> str | content
major: [],
/// 班级。同 @gzu-thesis.author
/// -> str | content
class: [],
/// 学号。同 @gzu-thesis.author
/// -> str | content
id: [],
/// 指导教师。同 @gzu-thesis.author
/// -> str | content
teacher: [],
/// 用于「诚信责任书」的手写签名,通常使用图片,如 `image("签名图片.png")`。
/// 理论上可以是任意 `content`。 如果为 `none`,则留白处理。
/// -> content | none
sign: none,
/// 中文摘要和关键词。
/// 接受一个字典,包含如下的键:
/// - abstract: 摘要正文
/// - keywords: 关键词数组,每个元素必须是字符串
/// -> dictionary
abstract-zh: (abstract: [], keywords: ()),
/// 英文摘要和关键词,同 @gzu-thesis.abstract-zh
/// -> dictionary
abstract-en: (abstract: [], keywords: ()),
/// 参考文献,必须是调用 `bibliography` 函数的返回值
/// -> content | none
bibliography: none,
/// 致谢正文
/// -> content | none
acknowledgment: none,
/// 附录正文
/// -> content | none
appendix: none,
/// 正文内容
/// -> content
body,
) = {
// 设置 PDF 元数据
set document(
title: title-zh,
author: _to-string(author),
keywords: abstract-zh.keywords,
)

// 基本版式设计
set page("a4", footer: none, margin: (top: 30mm, bottom: 25mm, left: 30mm, right: 20mm))
set text(
font: fonts.serif,
size: zh(-4),
lang: "zh",
region: "cn",
top-edge: "bounds",
bottom-edge: "bounds",
)
set par(
justify: true,
leading: 1.05em, // 模拟 Word 中的 1.5 倍行距
spacing: 1.05em, // 行数:29 行,行长:37 字
first-line-indent: (amount: 2em, all: true),
)

// 设置样式
show: styles.heading
show: styles.footnote
// 由于需要在一级标题后重置图、表、公式的编号,不能在 styles.heading 前应用这些样式。
show: styles.figure
show: styles.table
show: styles.math

// === 文档开始 ===
cover(author, college, major, class, id, teacher, date)
integrity-statement(sign, date)

counter(page).update(1) // 目录、摘要页码使用罗马数字
set page(
numbering: "I",
header: context [
#set text(zh(5))
#v(1fr)
#place(dx: 25%, dy: -25%, image("../assets/gzu_logo.png", height: 1.22cm))
#place(center)[贵州大学毕业论文(设计)]
#h(1fr)
第#counter(page).display()页
#v(3pt)
#line(length: 100%, stroke: 0.08em + text.fill)
],
)
outline(depth: 3, title: "目录")
pagebreak(weak: true)
abstract(abstract-zh, abstract-en, title-en)

// 从正文开始一级标题自动分页
show heading: it => if it.level == 1 { pagebreak(weak: true) } + it
counter(page).update(1) // 正文页码使用阿拉伯数字重新编号
set page(numbering: "1")

body

if bibliography != none {
heading(numbering: none)[参考文献]
set text(font: fonts.serif, size: zh(5))
// 模拟 Word 中的单倍行距
set par(leading: 0.37em, spacing: 0.37em)
set std.bibliography(style: "gb-7714-2015-numeric", title: none)
bibliography
}
if acknowledgment != none {
heading(numbering: none)[致谢]
acknowledgment
}
if appendix != none {
heading(numbering: none)[附录]
appendix
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#import "@preview/pointless-size:0.1.2": zh as zh-size

#import "/src/fonts.typ"


#let _list-keywords(header, keywords, sep) = {
show heading: set text(weight: "regular")
show heading: it => box(it.body)
linebreak()
context {
place(dy: -2.5pt, heading(header, numbering: none))
let size = measure(heading(header, numbering: none))
par(first-line-indent: size.width, sep + keywords)
}
}

#let abstract(zh, en, title-en) = {
show title: set align(center)
show title: set text(font: fonts.sans, zh-size(-2))

// 中文摘要页
v(1em)
title()
heading(numbering: none)[摘要]
zh.abstract
_list-keywords([关键词], zh.keywords.join([,]), [:])
pagebreak(weak: true)

// 英文摘要页
v(1em)
set text(lang: "en", region: "us")
title(title-en)
heading(numbering: none)[Abstract]
en.abstract
_list-keywords([Keywords], en.keywords.join([, ]), [: ])
pagebreak(weak: true)
}
Loading
Loading