diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/LICENSE-ASSETS.txt b/packages/preview/gzu-thesis-unofficial/0.1.0/LICENSE-ASSETS.txt new file mode 100644 index 0000000000..589d0ed18f --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/LICENSE-ASSETS.txt @@ -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. diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/LICENSE.txt b/packages/preview/gzu-thesis-unofficial/0.1.0/LICENSE.txt new file mode 100644 index 0000000000..d887645bb7 --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/LICENSE.txt @@ -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. diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/README.md b/packages/preview/gzu-thesis-unofficial/0.1.0/README.md new file mode 100644 index 0000000000..3fa83c81f8 --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/README.md @@ -0,0 +1,42 @@ +# 贵州大学本科生毕业论文(设计)模板 +This is a Typst template for undergraduate thesis (design) at Guizhou University. + +## 模板介绍 +此模板参考 +[《贵州大学毕业论文(设计)管理办法(试行)》(2025 年 4 月)](assets/贵州大学毕业论文(设计)管理办法(试行).pdf) +制作。 + +## 使用方法 +可在官方网页端在线使用,只需在仪表板上点击 “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. diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/assets/gzu_logo.png b/packages/preview/gzu-thesis-unofficial/0.1.0/assets/gzu_logo.png new file mode 100644 index 0000000000..13277d0c1c Binary files /dev/null and b/packages/preview/gzu-thesis-unofficial/0.1.0/assets/gzu_logo.png differ diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/assets/gzu_name.png b/packages/preview/gzu-thesis-unofficial/0.1.0/assets/gzu_name.png new file mode 100644 index 0000000000..15ddf82bfb Binary files /dev/null and b/packages/preview/gzu-thesis-unofficial/0.1.0/assets/gzu_name.png differ diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/assets/thumbnail.png b/packages/preview/gzu-thesis-unofficial/0.1.0/assets/thumbnail.png new file mode 100644 index 0000000000..237e30b036 Binary files /dev/null and b/packages/preview/gzu-thesis-unofficial/0.1.0/assets/thumbnail.png differ diff --git "a/packages/preview/gzu-thesis-unofficial/0.1.0/assets/\350\264\265\345\267\236\345\244\247\345\255\246\346\257\225\344\270\232\350\256\272\346\226\207\357\274\210\350\256\276\350\256\241\357\274\211\347\256\241\347\220\206\345\212\236\346\263\225\357\274\210\350\257\225\350\241\214\357\274\211.pdf" "b/packages/preview/gzu-thesis-unofficial/0.1.0/assets/\350\264\265\345\267\236\345\244\247\345\255\246\346\257\225\344\270\232\350\256\272\346\226\207\357\274\210\350\256\276\350\256\241\357\274\211\347\256\241\347\220\206\345\212\236\346\263\225\357\274\210\350\257\225\350\241\214\357\274\211.pdf" new file mode 100644 index 0000000000..471ca1214d Binary files /dev/null and "b/packages/preview/gzu-thesis-unofficial/0.1.0/assets/\350\264\265\345\267\236\345\244\247\345\255\246\346\257\225\344\270\232\350\256\272\346\226\207\357\274\210\350\256\276\350\256\241\357\274\211\347\256\241\347\220\206\345\212\236\346\263\225\357\274\210\350\257\225\350\241\214\357\274\211.pdf" differ diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/lib.typ b/packages/preview/gzu-thesis-unofficial/0.1.0/lib.typ new file mode 100644 index 0000000000..19b59bad8c --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/lib.typ @@ -0,0 +1,2 @@ +#import "/src/main.typ": gzu-thesis +#import "/src/styles/table.typ": bottomrule, cmidrule, continued-header, midrule, toprule diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/manual.pdf b/packages/preview/gzu-thesis-unofficial/0.1.0/manual.pdf new file mode 100644 index 0000000000..e525afb994 Binary files /dev/null and b/packages/preview/gzu-thesis-unofficial/0.1.0/manual.pdf differ diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/manual.typ b/packages/preview/gzu-thesis-unofficial/0.1.0/manual.typ new file mode 100644 index 0000000000..b699b210d1 --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/manual.typ @@ -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, +) diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/src/fonts.typ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/fonts.typ new file mode 100644 index 0000000000..f598b3a986 --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/fonts.typ @@ -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") diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/src/main.typ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/main.typ new file mode 100644 index 0000000000..d99cec6fd3 --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/main.typ @@ -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 + } +} diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/src/pages/abstract.typ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/pages/abstract.typ new file mode 100644 index 0000000000..fa3f1e39f0 --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/pages/abstract.typ @@ -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) +} diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/src/pages/cover.typ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/pages/cover.typ new file mode 100644 index 0000000000..a446b007ab --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/pages/cover.typ @@ -0,0 +1,48 @@ +#import "@preview/pointless-size:0.1.2": zh + +#import "/src/fonts.typ" + + +#let cover( + author, + college, + major, + class, + id, + teacher, + date, +) = { + set align(center) + set text(font: fonts.sans, size: zh(3)) + + v(13pt) + box(image("../../assets/gzu_logo.png")) + h(25pt) + box(image("../../assets/gzu_name.png")) + v(1fr) + text(size: zh(2))[本科毕业论文(设计)] + v(1fr) + show title: set text(zh(-2)) + title[论文(设计)题目:#context document.title] + v(1fr) + + context { + table( + columns: (auto, auto), + rows: 1.1cm, + inset: ((x: 5pt, y: 0.5pt), (x: 1em, y: 1.0pt)), + align: bottom + center, + stroke: (none, (bottom: 0.5pt + text.fill)), + [学#h(2em)院:], college, + [专#h(2em)业:], major, + [班#h(2em)级:], class, + [学#h(2em)号:], id, + [学生姓名:], author, + [指导教师:], teacher, + ) + } + v(3.9em) + date.display("[year]年[month]月[day]日") + v(3.5em) + pagebreak(weak: true) +} diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/src/pages/integrity-statement.typ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/pages/integrity-statement.typ new file mode 100644 index 0000000000..b20dcc05af --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/pages/integrity-statement.typ @@ -0,0 +1,27 @@ +#import "@preview/pointless-size:0.1.2": zh + + +#let integrity-statement(sign, date) = [ + #set heading(numbering: none, outlined: false) + #show heading: set text(size: zh(3)) + = 贵州大学本科毕业论文(设计)\ 诚信责任书 + + #set text(size: zh(4)) + #v(1em) + 本人郑重声明:本人所呈交的毕业论文(设计),是在导师的指导下独立进行研究所完成。毕业论文(设计)中凡引用他人已经发表或未发表的成果、数据、观点等,均已明确注明出处。 + + 特此声明。 + #v(1em) + + #align(right)[ + 论文(设计)作者签名: + #box( + if sign != none { sign } else { box(width: 5em, height: 2.5em) }, + baseline: 50% - 1em / 2, + ) + + 日#h(1em)期:#date.display("[year]年[month]月[day]日") + ] + + #pagebreak(weak: true) +] diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles.typ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles.typ new file mode 100644 index 0000000000..3cce14e455 --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles.typ @@ -0,0 +1,5 @@ +#import "styles/heading.typ": heading-style as heading +#import "styles/figure.typ": figure-style as figure +#import "styles/table.typ": table-style as table +#import "styles/footnote.typ": footnote-style as footnote +#import "styles/math.typ": math-style as math diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles/figure.typ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles/figure.typ new file mode 100644 index 0000000000..ea774820e5 --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles/figure.typ @@ -0,0 +1,12 @@ +#import "@preview/pointless-size:0.1.2": zh + +#import "/src/fonts.typ" + + +#let figure-style(body) = { + show figure.caption: set text(font: fonts.sans, size: zh(5)) + set figure(numbering: (n, ..) => numbering("1.1", counter(heading).get().first(), n)) + show heading.where(level: 1): it => counter(figure.where(kind: image)).update(0) + it + show heading.where(level: 1): it => counter(figure.where(kind: table)).update(0) + it + body +} diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles/footnote.typ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles/footnote.typ new file mode 100644 index 0000000000..64692c0a0c --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles/footnote.typ @@ -0,0 +1,16 @@ +#import "@preview/pointless-size:0.1.2": zh + +#import "/src/fonts.typ" + + +#let footnote-style(body) = { + set footnote(numbering: "①") + show footnote.entry: it => { + set text(font: fonts.serif, size: zh(5)) + h(it.indent) + numbering(it.note.numbering, ..counter(footnote).at(it.note.location())) + h(0.25em, weak: true) + it.note.body + } + body +} diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles/heading.typ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles/heading.typ new file mode 100644 index 0000000000..8226464374 --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles/heading.typ @@ -0,0 +1,27 @@ +#import "@preview/numbly:0.1.0": numbly +#import "@preview/pointless-size:0.1.2": zh + +#import "/src/fonts.typ" + + +#let heading-style(body) = { + set heading(numbering: numbly("第{1:一}章", "{1}.{2}", "{1}.{2}.{3}", default: none)) + show heading: it => block( + spacing: auto, + sticky: true, + { + if it.numbering != none { + if it.level != 1 { h(2 * zh(-4)) } + counter(heading).display(it.numbering) + h(0.25em, weak: true) + } + it.body + }, + ) + show heading: set text(font: fonts.sans) + show heading.where(level: 1): align.with(center) + show heading.where(level: 1): set text(size: zh(-3)) + show heading.where(level: 2): set text(size: zh(4)) + show heading.where(level: 3): set text(size: zh(-4)) + body +} diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles/math.typ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles/math.typ new file mode 100644 index 0000000000..259304bd66 --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles/math.typ @@ -0,0 +1,5 @@ +#let math-style(body) = { + set math.equation(numbering: (n, ..) => numbering("(1-1)", counter(heading).get().first(), n)) + show heading.where(level: 1): it => counter(math.equation).update(0) + it + body +} diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles/table.typ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles/table.typ new file mode 100644 index 0000000000..3e04ad82cc --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/src/styles/table.typ @@ -0,0 +1,95 @@ +#import "@preview/pointless-size:0.1.2": zh + +#import "/src/fonts.typ" + + +// 记录当前是否在绘制续表中的 header +#let _continued-header-state = state("continued-header") + +/// 提供为跨页表显示表序、表题的能力 +/// +/// 如果需要绘制可跨页的表格,请用此函数创建 header。 +/// 同时还需将 @toprule.continued 赋值为 `true`。 +/// +/// -> content +#let continued-header( + /// 表格的列数 + /// -> int + columns: none, + /// 同 `table.header` 的同名参数 -> int + level: 1, + ..children, +) = { + let continued-cell = table.cell( + colspan: columns, + inset: (bottom: 9pt, top: 0pt), + { + pdf.artifact( + context if _continued-header-state.get() { + align(center)[ + #set text(font: fonts.sans, size: zh(5)) + 表#context counter(figure.where(kind: table)).display()#h(0.4em, weak: true)(续) + ] + } else { + v(-9pt) + _continued-header-state.update(true) + }, + ) + }) + + table.header( + repeat: true, + continued-cell, + ..children, + ) +} + +/// 三线表的顶线 +/// -> content +#let toprule( + /// 如果这个表格是可跨页的表,设置此参数为 `true` -> bool + continued: false, + /// 同 `table.hline` 的同名参数 + stroke: 0.08em, +) = table.hline(y: if continued { 1 } else { auto }, stroke: stroke) + +/// 三线表的底线 +/// -> content +#let bottomrule( + /// 同 `table.hline` 的同名参数 + stroke: 0.08em, +) = toprule(stroke: stroke) + +/// 三线表的栏目线 +/// -> content +#let midrule( + /// 同 `table.hline` 的同名参数 + stroke: 0.05em, +) = table.hline(stroke: stroke) + +/// 三线表的部分栏目线 +/// -> content +#let cmidrule( + /// 线放置的行(零索引) + /// -> auto | int + y: auto, + /// 线开始的列(零索引,包含) + /// -> int + start: 0, + /// 线结束的列(零索引,不包含) + /// -> none | int + end: none, + /// 同 `table.hline` 的同名参数 + stroke: 0.03em, +) = table.hline(y: y, stroke: stroke, start: start, end: end) + +#let table-style(body) = { + show figure.where(kind: table): it => { + set figure.caption(position: top) + show figure.caption: set block(sticky: true) + it + } + set table(inset: (y: 0.5em), stroke: none) + show table: it => _continued-header-state.update(false) + it + body +} diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/template/main.typ b/packages/preview/gzu-thesis-unofficial/0.1.0/template/main.typ new file mode 100644 index 0000000000..d548d76e2e --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/template/main.typ @@ -0,0 +1,99 @@ +// typst 源码中中文换行会导致编译出的内容多一个空白符,使用此包可移除换行空白 +#import "@preview/cjk-unbreak:0.2.3": remove-cjk-break-space + +// 这是一个用于显示占位文本的包,用于填充文本。实际使用删除即可。 +#import "@preview/kouhu:0.2.0": kouhu + +// 导入模板 +#import "@preview/gzu-thesis-unofficial:0.1.0": * + +#show: remove-cjk-break-space + +// 关于此函数的详细用法可查看代码仓库中的 manual.pdf +// 其中除了有此函数的详细说明,还包括一些常见问题的解决方案。 +#show: gzu-thesis.with( + title-zh: [基于 Typst 的贵州大学本科生毕业论文(设计)模板], + title-en: [Guizhou University Undergraduate Graduation Thesis (Design) Template Based on Typst], + author: [姓名], + college: [#h(1em)学院名称#h(1em)], + major: [专业名称], + class: [班级], + id: [学号], + teacher: [指导教师], + sign: image("sign.jpg", width: 5em), // 签名图片 + // 中文摘要和关键词 + abstract-zh: ( + abstract: kouhu(indices: range(3), builtin-text: "xiangyu"), // 可以在一个单独的文件中写摘要正文,然后在这里使用 #include "文件名.typ" + keywords: ("Typst模板", "贵州大学毕业论文"), + ), + // 英文摘要和关键词 + abstract-en: ( + abstract: lorem(200), // 同样建议在单独的文件中写内容 + keywords: ("Typst template", "GZU thesis"), + ), + // 参考文献,必须是 bibliography 函数的返回值,支持 BibTeX 和 Hayagriva 两种类型, + // 通常可由你的文献管理工具导出。 + bibliography: bibliography("ref.bib"), + // 致谢正文 + acknowledgment: kouhu(indices: range(7), builtin-text: "nanshanjing"), // 建议在单独的文件中写,用法同摘要部分的描述 + // 附录正文,可省略 + appendix: kouhu(indices: range(2), builtin-text: "zhufu"), // 建议在单独的文件中写,用法同摘要部分的描述 +) + +// 这里开始写正文部分(论文的正文部分) += 介绍 +== 图片示例 +#figure( + caption: [用于测试的图片], + image("sign.jpg", width: 20%), +) // 为图片打一个标签 +如@fig.1 是一张在雪地里写了文字的图片 + +== 公式示例 +牛顿第二定律的代数表如@eq.nu +#set terms(indent: 4em, separator: [:], spacing: 0.4em) +$ F = m a $ + +== 引用文献和脚注 +引用文献 @netwok2020#footnote[必须在前面使用`gzu-thesis`函数时传入正确的`bibliography`才能引用], +之后便能在参考文献页自动显示。 + +== 表格示例 +=== 非跨页表 +#figure( + caption: [用于测试的表格], + table( + columns: 5, + toprule(), + table.header[表头1][表头2][表头4][表头4][表头5], + midrule(), + ..for _ in range(5) { ([A], [B], [C], [D], [E]) }, + bottomrule(), + ), +) +=== 跨页表 +表格也支持跨页,跨页会显示续表。 +#{ + show figure: set block(breakable: true) // 只有使用了这行代码才会跨页 + figure( + caption: [用于测试的跨页表格], + table( + columns: 4, + toprule(continued: true), + continued-header( + columns: 4, + table.cell(rowspan: 2, align: horizon)[材料], + table.cell(colspan: 3)[化学元素(%)], + cmidrule(), + [C], + [Al], + [V], + ), + midrule(), + ..for i in range(5) { + ([Ti6Al4V], [0.1], [0.2], [0.3]) + }, + bottomrule(), + ), + ) +} diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/template/ref.bib b/packages/preview/gzu-thesis-unofficial/0.1.0/template/ref.bib new file mode 100644 index 0000000000..6a024b6bcf --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/template/ref.bib @@ -0,0 +1,9 @@ +@article{netwok2020, + title={At-scale impact of the {Net Wok}: A culinarically holistic investigation of distributed dumplings}, + author={Astley, Rick and Morris, Linda}, + journal={Armenian Journal of Proceedings}, + volume={61}, + pages={192--219}, + year=2020, + publisher={Automatic Publishing Inc.} +} diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/template/sign.jpg b/packages/preview/gzu-thesis-unofficial/0.1.0/template/sign.jpg new file mode 100644 index 0000000000..f5619d00e7 Binary files /dev/null and b/packages/preview/gzu-thesis-unofficial/0.1.0/template/sign.jpg differ diff --git a/packages/preview/gzu-thesis-unofficial/0.1.0/typst.toml b/packages/preview/gzu-thesis-unofficial/0.1.0/typst.toml new file mode 100644 index 0000000000..0b0eb8fd52 --- /dev/null +++ b/packages/preview/gzu-thesis-unofficial/0.1.0/typst.toml @@ -0,0 +1,20 @@ +[package] +name = "gzu-thesis-unofficial" +version = "0.1.0" +entrypoint = "lib.typ" +authors = ["chengwu <@chengwu26>"] +license = "MIT" +description = "贵州大学本科生毕业论文(设计)模板(社区版)/ Undergraduate thesis template for Guizhou University (community-maintained)" +repository = "https://github.com/chengwu26/gzu-thesis-unofficial.git" +keywords = ["贵州大学", "毕业论文", "GZU", "Guizhou University", "thesis"] +categories = ["thesis"] +compiler = "0.14.0" +exclude = [ + "manual.*", + "assets/贵州大学毕业论文(设计)管理办法(试行).pdf", +] + +[template] +path = "template" +entrypoint = "main.typ" +thumbnail = "assets/thumbnail.png"