├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── assets ├── zju-emblem.svg ├── zju-name-graduate.png └── zju-name.svg ├── dependency └── i-figured.typ ├── documentclass ├── graduate-general.typ └── undergraduate-cs.typ ├── examples ├── common-body.typ ├── graduate-general.typ ├── ref.bib └── undergraduate-cs.typ ├── lib.typ ├── pages ├── bibliography.typ ├── graduate-cover.typ ├── graduate-decl.typ ├── graduate-title-en.typ ├── graduate-title-zh.typ ├── outline.typ ├── template-individual.typ ├── undergraduate-cover.typ ├── undergraduate-decl.typ ├── undergraduate-eval.typ ├── undergraduate-proposal-cover.typ ├── undergraduate-proposal-eval.typ ├── undergraduate-proposal-task.typ └── undergraduate-task.typ ├── scripts └── get-fonts.sh └── utils ├── appendix.typ ├── bib-provider.typ ├── bilingual-bibliography.typ ├── citext ├── LICENSE ├── README.md ├── dist │ ├── index.bin │ └── third-party-licenses.txt ├── gb-t-7714-2015-numeric-bilingual.csl ├── lib.typ ├── locales-zh-CN.xml └── typst.toml ├── datetime-display.typ ├── fakebold.typ ├── fonts.typ ├── header.typ ├── near-chapter.typ ├── part.typ ├── structure.typ ├── supplement.typ └── twoside.typ /.gitattributes: -------------------------------------------------------------------------------- 1 | utils/citext/** linguist-vendored -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pdf 2 | /fonts 3 | .vscode/ 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 OrangeX4 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 浙江大学 Typst 学位论文模板 `modern-zju-thesis` 2 | 3 | * **警告:** 本模板目前处于实验性阶段,请谨慎使用,对输出结果应进行检查和确认。在实验性阶段本模板可能会不加预告地对接口进行破坏性更改。 4 | * Typst@ZJU 交流群:910628289 5 | 6 | ## 使用方法 7 | 1. 本模板尚未发布至 Typst Universe,请先以 Git Submodule 等方式使用。一种可能的目录结构为: 8 | * `/` 9 | * `templates/` 10 | * `modern-zju-thesis/` 11 | * `fonts/` 12 | * `main.typ` 13 | * `ref.bib` 14 | 15 | 2. 安装所需字体:`FangSong` `Kaiti` `SimHei` `SimKai` `TimesNewRoman`。 亦可通过本仓库目录 `scripts/get-fonts.sh` 将该字体下载至 `fonts` 路径。若采用后者,则需要在 Typst 的命令中添加 `--font-path ` 选项来指定字体目录。 16 | 17 | 3. 在`main.typ`填入下列内容,亦可从本仓库目录 `examples` 下得到稍复杂的样例,和本科生模板样例。 18 | 19 | ```typ 20 | #import "./templates/modern-zju-thesis/lib.typ": graduate-general 21 | #import graduate-general: * 22 | 23 | #let info = ( 24 | title: ("毕业论文/设计题目", ""), 25 | title-en: ("Graduation Thesis Title", ""), 26 | grade: "2014级", 27 | student-id: "学号", 28 | author: "姓名", 29 | department: "学院", 30 | major: "专业", 31 | degree: "博士", 32 | supervisor: "指导教师", 33 | submit-date: "递交日期", 34 | ) 35 | 36 | 37 | #let doc = graduate-general( 38 | info: info, 39 | twoside: true, 40 | bibsource: read("ref.bib"), 41 | ) 42 | #show: doc.style 43 | 44 | #doc.pages.cover 45 | #doc.pages.title-zh 46 | #doc.pages.title-en 47 | 48 | #doc.pages.decl 49 | 50 | #show: frontmatter 51 | 52 | #let individual = doc.pages.individual 53 | #individual("致 谢")[] 54 | #individual("摘 要")[] 55 | #individual("Abstract")[] 56 | 57 | #doc.pages.outline 58 | #doc.pages.figure-outline 59 | #doc.pages.table-outline 60 | 61 | #show: mainmatter 62 | 63 | = Hello 64 | == World 65 | 66 | #doc.pages.bibliography 67 | 68 | #individual("附录", outlined: true)[ 69 | #appendix(level: 1)[ 70 | == 一个附录 71 | @app1 72 | == 另一个附录 73 | 74 | ] 75 | ] 76 | 77 | #individual("作者简历", outlined: true)[ 78 | *基本信息:* 79 | - 姓名: 80 | - 性别: 81 | - 民族: 82 | - 出生年月: 83 | - 籍贯: 84 | 85 | *教育经历:* 86 | - 2199.09 - 2203.06:浙江大学攻读学士学位 87 | 88 | *攻读#(info.degree)学位期间主要的研究成果:* 89 | 90 | ] 91 | 92 | ``` 93 | 94 | 4. 编译 `typst compile main.typ` 或 `typst compile --font-dir fonts main.typ` 95 | 96 | ## `bibmode` 97 | 目前 `modern-zju-thesis` 支持三种模式 `citext`(默认) `partbib`(仅适用于本科模板) 和 `bilingual`(仅适用于研究生模板)。 98 | 其中 `citext` 为推荐的模式,使用 https://github.com/Shuenhoy/citext 替代了 Typst 自身的引用功能,实现了双语参考文献等功能,但因使用 QuickJS/WASM,单次编译可能较慢,请充分利用 `typst watch` 或 `tinymist preview` 等增量编译。之后,`citext`预计将作为唯一支持的模式存在。 99 | 100 | ## 已知问题 101 | * (不使用 `citext` 时) 本科模板不支持双语参考文献(英文文献未能显示“et al.”而是“等”)。 102 | * (不使用 `citext` 时) 本科模板仅能以 `@name` 的形式引用参考文献,而不能使用 `cite()` 的形式,否则分部分参考文献编号会有错误。 103 | * (不使用 `citext` 时) Prose citations (即 LaTeX 的 `\citep`,例如 `Alec et al. [5]`) 格式不正确。 104 | * 本模板的部分样式可能与 `zjuthesis` 不同,有待根据学校官方文件分辨哪部分不同是需要处理的。 105 | * 目前仅包含计算机学院本科(论文)与研究生通用模板。 106 | 107 | ## 友情链接 108 | * https://github.com/memset0/ZJU-Project-Report-Template 109 | 110 | ## 致谢 111 | * https://github.com/TheNetAdmin/zjuthesis 112 | * https://github.com/nju-lug/modern-nju-thesis 113 | 114 | ## License 115 | * MIT License -------------------------------------------------------------------------------- /assets/zju-emblem.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /assets/zju-name-graduate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shuenhoy/modern-zju-thesis/1b43af5689b9b665cf134556caafda517aa64039/assets/zju-name-graduate.png -------------------------------------------------------------------------------- /dependency/i-figured.typ: -------------------------------------------------------------------------------- 1 | #import "@preview/i-figured:0.2.4": * -------------------------------------------------------------------------------- /documentclass/graduate-general.typ: -------------------------------------------------------------------------------- 1 | #import "../pages/graduate-cover.typ": graduate-cover 2 | #import "../pages/graduate-title-zh.typ": graduate-title-zh 3 | #import "../pages/graduate-title-en.typ": graduate-title-en 4 | #import "../pages/graduate-decl.typ": graduate-decl 5 | #import "../pages/bibliography.typ": bibliography-page 6 | #import "../pages/template-individual.typ": template-individual 7 | #import "../pages/outline.typ": main-outline, figure-outline, table-outline 8 | 9 | #import "../utils/fonts.typ": * 10 | #import "../utils/header.typ": header, footer 11 | #import "../utils/fakebold.typ": show-cn-fakebold 12 | #import "../utils/supplement.typ": show-set-supplement 13 | #import "../utils/twoside.typ": show-twoside-pagebreak, twoside-numbering-footer, twoside-pagebreak 14 | #import "../utils/near-chapter.typ": near-chapter 15 | #import "../utils/bib-provider.typ": bib-provider 16 | #import "../utils/structure.typ": frontmatter, mainmatter 17 | #import "../utils/appendix.typ": appendix 18 | 19 | 20 | #import "../dependency/i-figured.typ" 21 | 22 | #let show-outline(s) = { 23 | show outline.entry.where(level: 1): set text(weight: "bold") 24 | s 25 | } 26 | 27 | #let graduate-general-default-info = ( 28 | title: ("毕业论文/设计题目", ""), 29 | title-en: ("Graduation Project/Design Title", ""), 30 | grade: "20XX", 31 | student-id: "1234567890", 32 | clc: "O643.12", 33 | unitcode: "10335", 34 | reviewer: ("隐名", "隐名", "隐名", "隐名", "隐名"), 35 | committe: ("主席", "委员", "委员", "委员", "委员", "委员"), 36 | reviewer-en: ("Anonymous", "Anonymous", "Anonymous", "Anonymous", "Anonymous"), 37 | committe-en: ("Chair", "Committeeman", "Committeeman", "Committeeman", "Committeeman", "Committeeman"), 38 | secret-level: "无", 39 | author: "张三", 40 | department: "某学院", 41 | major: "某专业", 42 | degree: "硕士", 43 | field: "某方向", 44 | supervisor: "李四", 45 | submit-date: datetime.today(), 46 | defense-date: ("二一九三年六月", "September 2193"), 47 | ) 48 | 49 | #let graduate-general-set-style( 50 | doc, 51 | degree: "硕士", 52 | twoside: false, 53 | ) = { 54 | // Page geometry 55 | set page( 56 | paper: "a4", 57 | margin: ( 58 | x: 2.5cm, 59 | bottom: 2.54cm + 12pt + 30pt, 60 | top: 2.54cm + 12pt + 4mm, 61 | ), 62 | ) 63 | show: show-twoside-pagebreak.with(twoside: twoside) 64 | 65 | 66 | // Header and footer 67 | set page( 68 | header-ascent: 4mm, 69 | footer-descent: 35pt, 70 | header: header( 71 | left: [浙江大学#(degree)学位论文], 72 | right: near-chapter, 73 | ), 74 | footer: twoside-numbering-footer, 75 | ) 76 | 77 | // Paragraph and text 78 | set par(leading: 1.3em, first-line-indent: (amount: 2em, all: true), justify: true) 79 | set text(font: 字体.仿宋, size: 字号.小四, lang: "zh") 80 | show: show-cn-fakebold 81 | set underline(offset: 0.2em) 82 | 83 | 84 | // Headings 85 | show heading: i-figured.reset-counters 86 | 87 | set heading(numbering: "1.1") 88 | show heading.where(level: 1): set text(size: 字号.小三) 89 | show heading.where(level: 1): x => { 90 | twoside-pagebreak 91 | v(12pt) 92 | x 93 | v(6pt) 94 | } 95 | show heading.where(level: 2): set text(size: 字号.四号) 96 | show heading.where(level: 3): set text(size: 字号.小四) 97 | show heading.where(level: 4): set text(size: 字号.小四) 98 | show heading: set block(above: 1.5em, below: 1.5em) 99 | 100 | 101 | // Reference 102 | show: show-set-supplement 103 | show figure: i-figured.show-figure 104 | show math.equation.where(block: true): i-figured.show-equation 105 | show figure.where(kind: table): set figure.caption(position: top) 106 | 107 | doc 108 | } 109 | 110 | 111 | #let graduate-general( 112 | info: (:), 113 | twoside: false, 114 | bibsource: "", 115 | bibmode: "citext", 116 | ) = { 117 | assert(bibmode == "citext" or bibmode == "bilingual") 118 | let info = graduate-general-default-info + info 119 | let individual = template-individual.with(outlined: true, titlelevel: 1, bodytext-settings: (size: 字号.小四)) 120 | 121 | let bib = bib-provider(bibsource, mode: bibmode) 122 | ( 123 | pages: ( 124 | cover: graduate-cover(info: info), 125 | title-zh: graduate-title-zh(info: info), 126 | title-en: graduate-title-en(info: info), 127 | decl: graduate-decl(), 128 | outline: show-outline(main-outline(outlined: true, titlelevel: 1)), 129 | figure-outline: figure-outline(outlined: true, titlelevel: 1), 130 | table-outline: table-outline(outlined: true, titlelevel: 1), 131 | individual: individual, 132 | bibliography: bibliography-page(bib: bib.bibcontent, individual: individual), 133 | ), 134 | style: doc => { 135 | set document(title: info.title.join()) 136 | let doc = graduate-general-set-style(doc, degree: info.degree, twoside: twoside) 137 | 138 | show: bib.bibshow 139 | bib.hiddenbib + doc 140 | }, 141 | ) 142 | } 143 | -------------------------------------------------------------------------------- /documentclass/undergraduate-cs.typ: -------------------------------------------------------------------------------- 1 | #import "../pages/undergraduate-cover.typ": undergraduate-cover 2 | #import "../pages/undergraduate-decl.typ": undergraduate-decl 3 | #import "../pages/template-individual.typ": template-individual 4 | #import "../pages/outline.typ": main-outline 5 | #import "../pages/bibliography.typ": bibliography-page 6 | #import "../pages/undergraduate-task.typ": undergraduate-task 7 | #import "../pages/undergraduate-eval.typ": undergraduate-eval 8 | #import "../pages/undergraduate-proposal-cover.typ": undergraduate-proposal-cover 9 | #import "../pages/undergraduate-proposal-task.typ": undergraduate-proposal-task 10 | #import "../pages/undergraduate-proposal-eval.typ": undergraduate-proposal-eval 11 | 12 | #import "../utils/fonts.typ": * 13 | #import "../utils/part.typ": show-part, show-outline-with-part, part-and-headings, part, part-bib 14 | #import "../utils/bib-provider.typ": bib-provider 15 | #import "../utils/header.typ": header, footer 16 | #import "../utils/fakebold.typ": show-cn-fakebold 17 | #import "../utils/supplement.typ": show-set-supplement 18 | #import "../utils/twoside.typ": show-twoside-pagebreak, twoside-numbering-footer, twoside-pagebreak 19 | #import "../utils/structure.typ": frontmatter, mainmatter 20 | #import "../utils/appendix.typ": appendix 21 | 22 | #import "../dependency/i-figured.typ" 23 | 24 | 25 | #let undergraduate-cs-set-style(doc, twoside: true, bibmode: "part") = { 26 | // Page geometry 27 | set page( 28 | paper: "a4", 29 | margin: ( 30 | x: 3.18cm, 31 | bottom: 2.54cm + 12pt + 30pt, 32 | top: 2.54cm + 12pt + 4mm, 33 | ), 34 | ) 35 | show: show-twoside-pagebreak.with(twoside: twoside) 36 | 37 | // Header and footer 38 | set page( 39 | header-ascent: 4mm, 40 | footer-descent: 35pt, 41 | header: header( 42 | left: context { 43 | if not calc.even(here().page()) { 44 | "浙江大学本科生毕业论文" 45 | } 46 | }, 47 | right: context { 48 | if calc.even(here().page()) { 49 | document.title 50 | } 51 | }, 52 | ), 53 | footer: twoside-numbering-footer, 54 | ) 55 | 56 | // Paragraph and text 57 | set par(leading: 1.3em, first-line-indent: (amount: 2em, all: true), justify: true) 58 | set text(font: 字体.仿宋, size: 字号.小四, lang: "zh") 59 | show: show-cn-fakebold 60 | set underline(offset: 0.2em) 61 | 62 | 63 | // Headings 64 | show heading: i-figured.reset-counters 65 | 66 | set heading( 67 | numbering: (..numbers) => { 68 | let level = numbers.pos().len() 69 | if (level == 1) { 70 | return numbering("一、", numbers.pos().at(level - 1)) 71 | } else { 72 | return numbering("1.1 ", ..numbers.pos().slice(1)) 73 | } 74 | }, 75 | ) 76 | show heading.where(level: 1): x => { 77 | twoside-pagebreak 78 | v(12pt) 79 | align(center, x) 80 | v(6pt) 81 | } 82 | 83 | show heading.where(level: 2): set text(size: 字号.三号) 84 | show heading.where(level: 3): set text(size: 字号.小三) 85 | show heading.where(level: 4): set text(size: 字号.四号) 86 | 87 | 88 | // Reference 89 | show: show-set-supplement 90 | show figure: i-figured.show-figure 91 | show math.equation.where(block: true): i-figured.show-equation 92 | show figure.where(kind: table): set figure.caption(position: top) 93 | 94 | // Part 95 | show: show-part.with(enable-ref: bibmode == "partbib") 96 | show: show-outline-with-part 97 | 98 | 99 | doc 100 | } 101 | 102 | #let undergraduate-cs-default-info = ( 103 | title: ("毕业论文/设计题目",), 104 | grade: "20XX", 105 | student-id: "1234567890", 106 | author: "张三", 107 | author-en: "Zhang San", 108 | department: "某学院", 109 | major: "某专业", 110 | field: "某方向", 111 | supervisor: "李四", 112 | submit-date: datetime.today(), 113 | ) 114 | 115 | #let undergraduate-cs( 116 | info: (:), 117 | twoside: true, 118 | bibsource: "", 119 | bibmode: "citext", 120 | ) = { 121 | assert(bibmode == "citext" or bibmode == "partbib") 122 | 123 | let info = undergraduate-cs-default-info + info 124 | let bib = bib-provider(bibsource, mode: bibmode) 125 | 126 | ( 127 | pages: ( 128 | cover: undergraduate-cover(info: info), 129 | decl: undergraduate-decl(), 130 | outline: main-outline(target: part-and-headings), 131 | task: undergraduate-task.with(info: info), 132 | individual: template-individual, 133 | eval: undergraduate-eval, 134 | bibliography: bibliography-page(bib: bib.bibcontent, individual: template-individual), 135 | proposal-cover: undergraduate-proposal-cover(info: info), 136 | proposal-task: undergraduate-proposal-task.with(info: info), 137 | proposal-eval: undergraduate-proposal-eval, 138 | ), 139 | components: ( 140 | bibliography: bib.bibcontent, 141 | new-bib: bib.new-bib, 142 | ), 143 | style: doc => { 144 | set document(title: info.title.join()) 145 | 146 | let doc = undergraduate-cs-set-style(doc, twoside: twoside, bibmode: bibmode) 147 | show: bib.bibshow 148 | 149 | bib.hiddenbib + doc 150 | }, 151 | ) 152 | } 153 | -------------------------------------------------------------------------------- /examples/common-body.typ: -------------------------------------------------------------------------------- 1 | #import "../lib.typ": fonts 2 | 3 | #import fonts: * 4 | 5 | = 一个Chapter 6 | 旧历的年底毕竟最像年底,村镇上不必说,就在天空中也显出将到新年的气象来。灰白色的沉重的晚云中间时时发出闪光,接着一声钝响,是送灶的爆竹;近处燃放的可就更强烈了,震耳的大音还没有息,空气里已经散满了幽微的火药香。我是正在这一夜回到我的故乡鲁镇的。虽说故乡,然而已没有家,所以只得暂寓在鲁四老爷的宅子里。他是我的本家,比我长一辈,应该称之曰“四叔”,是一个讲理学的老监生。他比先前并没有甚么大改变,单是老了些,但也还未留胡子,一见面是寒暄,寒暄之后说我“胖了”,说我“胖了”之后即大骂其新党。但我知道,这并非借题在骂我:因为他所骂的还是康有为。但是,谈话是总不投机的了,于是不多久,我便一个人剩在书房里。 7 | == 一个Section 8 | 我们可以用 image 来插入现有的 jpg 等格式的图片,如@fig:zju-logo。 9 | 10 | #figure( 11 | image("../assets/zju-emblem.svg", width: 40%), 12 | caption: [浙江大学 LOGO], 13 | ) 14 | 如@tbl:sample 所示,这是一张自动调节列宽的表格。 15 | 16 | #figure( 17 | table( 18 | columns: (auto, 1fr), 19 | align: (center, center), 20 | stroke: black, 21 | [第一列], [第二列], 22 | [xxx], [xxx], 23 | [xxx], [xxx], 24 | [xxx], [xxx], 25 | ), 26 | caption: "自动调节列宽的表格", 27 | ) 28 | 29 | 30 | 如@eqt:eq:sample 所示,这是一个公式。 31 | $ 32 | A = overbrace((a + b + c) + underbrace(i(d + e + f),"虚数"),"复数") 33 | $ 34 | 35 | 如@lst:code-sample 所示,这是一段代码 @zjuthesis,@floater2005surface,@WANG2022102149,@chCurl。 36 | 37 | #figure( 38 | ``` 39 | #include 40 | 41 | int main(int argc, char *argv[]) 42 | { 43 | printf("Hello, zjuthesis\n"); 44 | return 0; 45 | } 46 | ```, 47 | caption: "simple.c", 48 | ) 49 | 50 | === 关于字体 51 | 英文字体通常提供了粗体和斜体的组合,中文字体通常没有粗体或斜体,本模板使用了 "stroke" 来实现中文伪粗体,但不提供中文斜体。 52 | 53 | #figure( 54 | caption: "一些字体示例", 55 | table( 56 | columns: 5, 57 | [字体], [常规], [粗体], [斜体], [粗斜体], 58 | [Times New Roman], [Regular], [*Bold*], [_Italic_], [*_Bold Italic_*], 59 | [仿宋], 60 | [#show: fangsong; 常规], 61 | [#show: fangsong; *粗体*], 62 | [#show: fangsong; _斜体_], 63 | [#show: fangsong; *_斜粗体_*], 64 | 65 | [宋体], [#show: songti; 常规], [#show: songti; *粗体*], [#show: songti; _斜体_], [#show: songti; *_斜粗体_*], 66 | [黑体], [#show: heiti; 常规], [#show: heiti; *粗体*], [#show: heiti; _斜体_], [#show: heiti; *_斜粗体_*], 67 | [楷体], [#show: kaiti; 常规], [#show: kaiti; *粗体*], [#show: kaiti; _斜体_], [#show: kaiti; *_斜粗体_*], 68 | ), 69 | ) 70 | 71 | == 另一个Section 72 | 第二天我起得很迟,午饭之后,出去看了几个本家和朋友;第三天也照样。他们也都没有甚么大改变,单是老了些;家中却一律忙,都在准备着“祝福”。这是鲁镇年终的大典,致敬尽礼,迎接福神,拜求来年一年中的好运气的。杀鸡,宰鹅,买猪肉,用心细细的洗,女人的臂膊都在水里浸得通红,有的还带着绞丝银镯子。煮熟之后,横七竖八的插些筷子在这类东西上,可就称为“福礼”了,五更天陈列起来,并且点上香烛,恭请福神们来享用,拜的却只限于男人,拜完自然仍然是放爆竹。年年如此,家家如此,——只要买得起福礼和爆竹之类的——今年自然也如此。天色愈阴暗了,下午竟下起雪来,雪花大的有梅花那么大,满天飞舞,夹着烟霭和忙碌的气色,将鲁镇乱成一团糟。我回到四叔的书房里时,瓦楞上已经雪白,房里也映得较光明,极分明的显出壁上挂著的朱拓的大“寿”字,陈抟老祖写的,一边的对联已经脱落,松松的卷了放在长桌上,一边的还在,道是“事理通达心气和平”。我又无聊赖的到窗下的案头去一翻,只见一堆似乎未必完全的《康熙字典》,一部《近思录集注》和一部《四书衬》。无论如何、我明天决计要走了。 73 | 74 | 况且,一直到昨天遇见祥林嫂的事,也就使我不能安住。那是下午,我到镇的东头访过一个朋友,走出来,就在河边遇见她;而且见她瞪着的眼睛的视线,就知道明明是向我走来的。我这回在鲁镇所见的人们中,改变之大,可以说无过于她的了:五年前的花白的头发,即今已经全白,会不像四十上下的人;脸上瘦削不堪,黄中带黑,而且消尽了先前悲哀的神色,仿佛是木刻似的;只有那眼珠间或一轮,还可以表示她是一个活物。她一手提着竹篮。内中一个破碗,空的;一手拄著一支比她更长的竹竿,下端开了裂:她分明已经纯乎是一个乞丐了。我就站住,豫备她来讨钱。 75 | === 一个Subsection 76 | “你回来了?”她先这样问。 77 | 78 | “是的。” 79 | ==== 一个Subsubsection 80 | “你回来了?”她先这样问。 81 | 82 | “是的。” 83 | == 又一个Section 84 | #lorem(100) 85 | 86 | #lorem(120) 87 | 88 | #lorem(130) 89 | = 另一个Chapter 90 | == 又一个Section 91 | @chap:1 92 | @sec:1 93 | === 又一个Subsection 94 | @subsec:1 95 | 96 | “就是——”她走近两步,放低了声音,极秘密似的切切的说,“一个人死了 97 | 之后,究竟有没有魂灵的?” 98 | -------------------------------------------------------------------------------- /examples/graduate-general.typ: -------------------------------------------------------------------------------- 1 | #import "../lib.typ": graduate-general 2 | #import graduate-general: * 3 | 4 | #let info = ( 5 | title: ("毕业论文/设计题目", ""), 6 | title-en: ("Graduation Thesis Title", ""), 7 | grade: "2014级", 8 | student-id: "学号", 9 | author: "姓名", 10 | department: "学院", 11 | major: "专业", 12 | degree: "博士", 13 | supervisor: "指导教师", 14 | submit-date: "递交日期", 15 | ) 16 | 17 | #let doc = graduate-general( 18 | info: info, 19 | twoside: true, 20 | bibsource: read("ref.bib"), 21 | bibmode: "citext", 22 | ) 23 | #show: doc.style 24 | 25 | 26 | #doc.pages.cover 27 | #doc.pages.title-zh 28 | #doc.pages.title-en 29 | 30 | #doc.pages.decl 31 | 32 | #show: frontmatter 33 | 34 | #let individual = doc.pages.individual 35 | #individual("致 谢")[ 36 | 旧历的年底毕竟最像年底,村镇上不必说,就在天空中也显出将到新年的气象来。灰白色的沉重的晚云中间时时发出闪光,接着一声钝响,是送灶的爆竹;近处燃放的可就更强烈了,震耳的大音还没有息,空气里已经散满了幽微的火药香。我是正在这一夜回到我的故乡鲁镇的。 37 | 38 | 虽说故乡,然而已没有家,所以只得暂寓在鲁四老爷的宅子里。他是我的本家,比我长一辈,应该称之曰“四叔”,是一个讲理学的老监生。他比先前并没有甚么大改变,单是老了些,但也还未留胡子,一见面是寒暄,寒暄之后说我“胖了”,说我“胖了”之后即大骂其新党。但我知道,这并非借题在骂我:因为他所骂的还是康有为。但是,谈话是总不投机的了,于是不多久,我便一个人剩在书房里。 39 | ] 40 | #individual("摘 要")[] 41 | #individual("Abstract")[] 42 | 43 | 44 | #doc.pages.outline 45 | #doc.pages.figure-outline 46 | #doc.pages.table-outline 47 | 48 | #show: mainmatter 49 | 50 | #include "common-body.typ" 51 | 52 | #doc.pages.bibliography 53 | 54 | 55 | #individual("附录", outlined: true)[ 56 | #appendix(level: 1)[ 57 | == 一个附录 58 | @app1 59 | == 另一个附录 60 | 61 | ] 62 | ] 63 | 64 | #individual("作者简历", outlined: true)[ 65 | *基本信息:* 66 | - 姓名: 67 | - 性别: 68 | - 民族: 69 | - 出生年月: 70 | - 籍贯: 71 | 72 | *教育经历:* 73 | - 2199.09 - 2203.06:浙江大学攻读学士学位 74 | 75 | *攻读#(info.degree)学位期间主要的研究成果:* 76 | 77 | ] 78 | -------------------------------------------------------------------------------- /examples/ref.bib: -------------------------------------------------------------------------------- 1 | @www{zjuthesisrules, 2 | title = {浙江大学本科生毕业论文(设计)编写规则}, 3 | author = {浙江大学本科生院}, 4 | year = {2018}, 5 | url = {http://bksy.zju.edu.cn/attachments/2018-01/01-1517384518-1149149.pdf} 6 | } 7 | @www{tikz, 8 | title = {tikz宏包}, 9 | author = {Till Tantau}, 10 | year = {2018}, 11 | url = {https://sourceforge.net/projects/pgf/} 12 | } 13 | @www{zjuthesis, 14 | title = {浙江大学毕业设计/论文模板}, 15 | author = {王子轩}, 16 | year = {2019}, 17 | url = {https://github.com/TheNetAdmin/zjuthesis} 18 | } 19 | @www{zjugradthesisrules, 20 | title = {浙江大学研究生学位论文编写规则}, 21 | author = {浙江大学研究生院}, 22 | year = {2008}, 23 | url = {http://grs.zju.edu.cn/redir.php?catalog_id=10038&object_id=12877} 24 | } 25 | 26 | 27 | @article{floater2005surface, 28 | title = {Surface parameterization: a tutorial and survey}, 29 | author = {Floater, Michael S and Hormann, Kai}, 30 | journal = {Advances in multiresolution for geometric modelling}, 31 | pages = {157--186}, 32 | year = {2005}, 33 | publisher = {Springer} 34 | } 35 | 36 | @article{WANG2022102149, 37 | title = {3D mesh cutting for high quality atlas packing}, 38 | journal = {Computer Aided Geometric Design}, 39 | volume = {99}, 40 | pages = {102149}, 41 | year = {2022}, 42 | issn = {0167-8396}, 43 | author = {Shiyi Wang and Jiong Chen and Xifeng Gao and Hujun Bao and Jin Huang}, 44 | keywords = {Atlas packing, Surface cut, Parameterization, Cone singularity}, 45 | language = {en-US} 46 | } 47 | 48 | @article{chCurl, 49 | title = {三维标架场可控去旋方法}, 50 | journal = {中国科学:信息科学}, 51 | volume = {51}, 52 | pages = {263-278}, 53 | number = {02}, 54 | year = {2021}, 55 | author = {方贤忠 and 金耀 and 黄劲 and 鲍虎军} 56 | } -------------------------------------------------------------------------------- /examples/undergraduate-cs.typ: -------------------------------------------------------------------------------- 1 | #import "../lib.typ": undergraduate-cs 2 | #import undergraduate-cs: * 3 | 4 | #let info = ( 5 | title: ("毕业论文/设计题目",), 6 | grade: "2014级", 7 | student-id: "学号", 8 | author: "姓名", 9 | department: "学院", 10 | major: "专业", 11 | supervisor: "指导教师", 12 | submit-date: "递交日期", 13 | ) 14 | 15 | 16 | #let doc = undergraduate-cs( 17 | info: info, 18 | twoside: true, 19 | bibsource: read("ref.bib"), 20 | bibmode: "citext", 21 | ) 22 | #show: doc.style 23 | 24 | #doc.pages.cover 25 | 26 | #show: frontmatter 27 | 28 | #doc.pages.decl 29 | 30 | #let individual = doc.pages.individual 31 | 32 | #individual("致 谢")[] 33 | #individual("摘 要")[] 34 | #individual("Abstract")[] 35 | 36 | #doc.pages.outline 37 | 38 | #show: mainmatter 39 | 40 | #part[毕业论文] 41 | #include "common-body.typ" 42 | 43 | #doc.pages.bibliography 44 | 45 | #individual("附录", outlined: true)[ 46 | #appendix[ 47 | === 一个附录 48 | 这里是附录。 49 | @app1 50 | @WANG2022102149 51 | === 另一个附录 52 | 53 | ] 54 | ] 55 | 56 | #individual("作者简历", outlined: true)[ 57 | *基本信息:* 58 | - 姓名: 59 | - 性别: 60 | - 民族: 61 | - 出生年月: 62 | - 籍贯: 63 | 64 | *教育经历:* 65 | - 2199.09 - 2203.06:浙江大学攻读学士学位 66 | 67 | ] 68 | 69 | #(doc.pages.task)()[任务] 70 | #(doc.pages.eval)(scores: (8, 15, 5, 60))[评价] 71 | 72 | #part[开题报告] 73 | #doc.pages.proposal-cover 74 | #(doc.pages.proposal-task)[ 75 | 内容 76 | ] 77 | 78 | 79 | #counter(page).update(0) 80 | #(doc.components.new-bib)() 81 | 82 | = 文献综述 83 | 84 | 这里是文献综述。 85 | 86 | @zjugradthesisrules 87 | 88 | == 参考文献 89 | #doc.components.bibliography 90 | 91 | = 开题报告 92 | #(doc.components.new-bib)() 93 | 94 | == 参考文献 95 | #doc.components.bibliography 96 | 97 | = 外文翻译 98 | = 外文原文 99 | 100 | 101 | #(doc.pages.proposal-eval)(scores-supervisor: (8, 15, 5))[评价] 102 | -------------------------------------------------------------------------------- /lib.typ: -------------------------------------------------------------------------------- 1 | #import "documentclass/undergraduate-cs.typ" 2 | #import "documentclass/graduate-general.typ" 3 | 4 | #import "utils/fonts.typ" 5 | #import "utils/part.typ" 6 | 7 | #import "utils/appendix.typ": appendix 8 | #import "utils/structure.typ": frontmatter, mainmatter 9 | -------------------------------------------------------------------------------- /pages/bibliography.typ: -------------------------------------------------------------------------------- 1 | #import "./template-individual.typ": template-individual 2 | 3 | #let bibliography-page(bib: auto, individual: auto) = { 4 | individual( 5 | "参考文献", 6 | bib, 7 | ) 8 | } 9 | -------------------------------------------------------------------------------- /pages/graduate-cover.typ: -------------------------------------------------------------------------------- 1 | #import "../utils/fonts.typ": 字号, 字体 2 | #import "../utils/datetime-display.typ": datetime-display 3 | #import "../utils/twoside.typ": * 4 | 5 | #let graduate-cover( 6 | info: (:), 7 | // 其他参数 8 | stoke-width: 0.5pt, 9 | row-gutter: 11.5pt, 10 | ) = { 11 | if type(info.submit-date) == datetime { 12 | info.submit-date = datetime-display(info.submit-date) 13 | } 14 | twoside-pagebreak 15 | 16 | context { 17 | counter(page).update(0) 18 | v(-40pt) 19 | set grid( 20 | row-gutter: row-gutter, 21 | rows: 1em, 22 | stroke: (x, y) => ( 23 | bottom: if x == 1 { 24 | stoke-width 25 | } else { 26 | none 27 | }, 28 | ), 29 | ) 30 | set align(center) 31 | 32 | [ 33 | #set text(size: 字号.小四, font: 字体.宋体) 34 | 35 | #grid( 36 | columns: (auto, auto, 1fr, auto, auto), 37 | align: (left, center, left, left, center), 38 | stroke: (x, y) => ( 39 | bottom: if x == 1 or x == 4 { 40 | stoke-width 41 | } else { 42 | none 43 | }, 44 | ), 45 | [分类号:], [#info.clc], [], [单位代码:], [#info.unitcode], 46 | [密#h(1em)级:], [#info.secret-level], [], [学#h(2em)号:], info.student-id, 47 | ) 48 | ] 49 | 50 | 51 | image("../assets/zju-name-graduate.png", width: page.width * 0.3) 52 | v(-30pt) 53 | 54 | text(size: 字号.小一, font: 字体.宋体)[#(info.degree)学位论文] 55 | 56 | image("../assets/zju-emblem.svg", width: page.width * 0.15) 57 | 58 | v(20pt) 59 | block( 60 | width: 80%, 61 | [ 62 | #set text(size: 字号.小二, weight: "bold") 63 | #grid( 64 | columns: (auto, 1fr), 65 | align: (start, center), 66 | "中文论文题目:", info.title.first(), 67 | ..info.title.slice(1).map(v => (none, v)).flatten(), 68 | grid.cell(stroke: none)[], grid.cell(stroke: none)[], 69 | "英文论文题目:", text(size: 16pt, info.title-en.first()), 70 | ..info.title-en.slice(1).map(v => (none, text(size: 16pt, v))).flatten(), 71 | grid.cell(stroke: none)[], grid.cell(stroke: none)[], 72 | ) 73 | ], 74 | ) 75 | 76 | 77 | block( 78 | width: 60%, 79 | [ 80 | #set text(size: 字号.四号) 81 | #grid( 82 | columns: (auto, 1fr), 83 | align: (start, center), 84 | 85 | "申请人姓名:", info.author, 86 | "指导教师:", info.supervisor, 87 | "专业名称:", info.grade + info.major, 88 | "研究方向:", info.field, 89 | "所在学院:", info.department, 90 | grid.cell(stroke: none)[], grid.cell(stroke: none)[], 91 | ) 92 | #align(right)[ 93 | #set text(size: 字号.小三, weight: "bold") 94 | #grid( 95 | columns: (auto, 10.5em), 96 | align: (start, center), 97 | "论文提交日期", info.submit-date, 98 | ) 99 | ] 100 | ], 101 | ) 102 | } 103 | twoside-emptypage 104 | } 105 | -------------------------------------------------------------------------------- /pages/graduate-decl.typ: -------------------------------------------------------------------------------- 1 | #import "../utils/fonts.typ": 字号, 字体 2 | #import "../utils/datetime-display.typ": datetime-display 3 | #import "../utils/twoside.typ": * 4 | 5 | #let graduate-decl( 6 | outlined: false, 7 | row-gutter: 11.5pt, 8 | ) = { 9 | context { 10 | twoside-pagebreak 11 | set text(font: 字体.宋体) 12 | let zju = underline[#text(font: 字体.楷体, weight: "bold")[浙江大学]] 13 | block(width: 100%)[ 14 | #set par(justify: true) 15 | #set text(size: 字号.小四) 16 | 17 | #align(center)[ 18 | #set text(size: 字号.小二) 19 | 浙江大学研究生学位论文独创性声明 20 | ] 21 | #v(2em) 22 | 23 | 本人声明所呈交的学位论文是本人在导师指导下进行的研究工作及取得的研究成果。除了文中特别加以标注和致谢的地方外,论文中不包含其他人已经发表或撰写过的研究成果,也不包含为获得#(zju)或其他教育机构的学位或证书而使用过的材料。与我一同工作的同志对本研究所做的任何贡献均已在论文中作了明确的说明并表示谢意。 24 | #v(2em) 25 | #align(center)[ 26 | #table( 27 | columns: (0.5fr, 0.4fr, 0.5fr, auto), 28 | align: (start, center), 29 | stroke: none, 30 | row-gutter: row-gutter, 31 | [ 学位论文作者签名: ], [], [ 签字日期: ], [ 年#h(2em)月#h(2em)日], 32 | ) 33 | ] 34 | 35 | #v(4em) 36 | 37 | #align(center)[ 38 | #set text(size: 字号.小二) 39 | 学位论文版权使用授权书 40 | ] 41 | #v(2em) 42 | 43 | 本学位论文作者完全了解#(zju)有权保留并向国家有关部门或机构送交本论文的复印件和磁盘,允许论文被查阅和借阅。本人授权#(zju)可以将学位论文的全部或部分内容编入有关数据库进行检索和传播,可以采用影印、缩印或扫描等复制手段保存、汇编学位论文。 44 | 45 | (保密的学位论文在解密后适用本授权书) 46 | 47 | #v(2em) 48 | 49 | #align(center)[ 50 | #table( 51 | columns: (0.5fr, auto, 0.5fr, auto), 52 | align: (start, center), 53 | stroke: none, 54 | row-gutter: row-gutter, 55 | [ 学位论文作者签名: ], [], [ 导师签名: ], [], 56 | [], [], [], [], 57 | [ 签字日期: ], [ 年#h(2em)月#h(2em)日], [ 签字日期: ], [年#h(2em)月#h(2em)日], 58 | ) 59 | ] 60 | 61 | 62 | ] 63 | } 64 | twoside-emptypage 65 | } 66 | -------------------------------------------------------------------------------- /pages/graduate-title-en.typ: -------------------------------------------------------------------------------- 1 | #import "../utils/fonts.typ": 字号, 字体 2 | #import "../utils/datetime-display.typ": datetime-display 3 | #import "../utils/twoside.typ": * 4 | 5 | #let graduate-title-en( 6 | info: (:), 7 | // 其他参数 8 | stroke-width: 0.5pt, 9 | row-gutter: 11.5pt, 10 | degree: "硕士", 11 | ) = { 12 | if type(info.submit-date) == datetime { 13 | info.submit-date = datetime-display(info.submit-date) 14 | } 15 | 16 | context { 17 | twoside-pagebreak 18 | counter(page).update(0) 19 | v(-40pt) 20 | set grid( 21 | row-gutter: row-gutter, 22 | rows: 1em, 23 | stroke: (x, y) => ( 24 | bottom: if x == 1 { 25 | stroke-width 26 | } else { 27 | none 28 | }, 29 | ), 30 | ) 31 | 32 | 33 | set align(center) 34 | 35 | 36 | v(20pt) 37 | block( 38 | width: 80%, 39 | [ 40 | #set text(size: 16pt, weight: "bold") 41 | #grid( 42 | columns: 1fr, 43 | align: (center), 44 | stroke: (bottom: stroke-width), 45 | info.title-en.first(), 46 | ..info.title-en.slice(1), 47 | grid.cell(stroke: none)[], grid.cell(stroke: none)[], 48 | ) 49 | ], 50 | ) 51 | v(-40pt) 52 | 53 | [#image("../assets/zju-emblem.svg", width: page.width * 0.15)] 54 | 55 | 56 | block( 57 | width: 60%, 58 | [ 59 | #set text(size: 字号.三号, weight: "bold") 60 | #grid( 61 | columns: (auto, 0.8fr), 62 | align: (end, center), 63 | 64 | "Author's signature:", [], 65 | "Supervisor's signature:", [], 66 | grid.cell(stroke: none)[], grid.cell(stroke: none)[], 67 | ) 68 | ], 69 | ) 70 | block( 71 | width: 70%, 72 | [ 73 | #set text(size: 字号.四号) 74 | #grid( 75 | columns: (auto, 1fr), 76 | align: (end, center), 77 | 78 | ..info.reviewer-en.enumerate(start: 0).map(v => ([Thesis reviewer #(v.at(0)+1):], v.at(1))).flatten(), 79 | grid.cell(stroke: none)[], grid.cell(stroke: none)[], 80 | ) 81 | #grid( 82 | columns: (auto, 15em), 83 | align: (end, center), 84 | "Chair:", info.committe-en.at(0), 85 | ) 86 | #v(-1em) 87 | #align(left)[#h(-1em)#text(size: 字号.五号)[(Committee of oral defence)]] 88 | #grid( 89 | columns: (auto, 1fr), 90 | align: (end, center), 91 | 92 | ..info.committe-en.enumerate(start: 0).slice(1).map(v => ([Committeeman #(v.at(0)):], v.at(1))).flatten(), 93 | grid.cell(stroke: none)[], grid.cell(stroke: none)[], 94 | ) 95 | #align(center)[ 96 | #grid( 97 | columns: (auto, 10em), 98 | align: (start, center), 99 | "Date of oral defence:", info.defense-date.at(1), 100 | ) 101 | ] 102 | ], 103 | ) 104 | } 105 | twoside-emptypage 106 | } 107 | -------------------------------------------------------------------------------- /pages/graduate-title-zh.typ: -------------------------------------------------------------------------------- 1 | #import "../utils/fonts.typ": 字号, 字体 2 | #import "../utils/datetime-display.typ": datetime-display 3 | #import "../utils/twoside.typ": * 4 | 5 | #let graduate-title-zh( 6 | info: (:), 7 | // 其他参数 8 | stroke-width: 0.5pt, 9 | row-gutter: 11.5pt, 10 | degree: "硕士", 11 | ) = { 12 | if type(info.submit-date) == datetime { 13 | info.submit-date = datetime-display(info.submit-date) 14 | } 15 | 16 | context { 17 | twoside-pagebreak 18 | counter(page).update(0) 19 | v(-40pt) 20 | set grid( 21 | row-gutter: row-gutter, 22 | rows: 1em, 23 | stroke: (x, y) => ( 24 | bottom: if x == 1 { 25 | stroke-width 26 | } else { 27 | none 28 | }, 29 | ), 30 | ) 31 | 32 | 33 | set align(center) 34 | 35 | 36 | v(20pt) 37 | block( 38 | width: 80%, 39 | [ 40 | #set text(size: 字号.小二, weight: "bold") 41 | #grid( 42 | columns: 1fr, 43 | align: (center), 44 | stroke: (bottom: stroke-width), 45 | info.title.first(), 46 | ..info.title.slice(1), 47 | grid.cell(stroke: none)[], grid.cell(stroke: none)[], 48 | ) 49 | ], 50 | ) 51 | v(-40pt) 52 | 53 | [#image("../assets/zju-emblem.svg", width: page.width * 0.15)] 54 | 55 | 56 | block( 57 | width: 60%, 58 | [ 59 | #set text(size: 字号.三号, weight: "bold") 60 | #grid( 61 | columns: (auto, 0.8fr), 62 | align: (start, center), 63 | 64 | "论文作者签名:", [], 65 | grid.cell(stroke: none)[], grid.cell(stroke: none)[], 66 | "指导教师签名:", [], 67 | grid.cell(stroke: none)[], grid.cell(stroke: none)[], 68 | ) 69 | ], 70 | ) 71 | block( 72 | width: 70%, 73 | [ 74 | #set text(size: 字号.四号) 75 | #grid( 76 | columns: (auto, 1fr), 77 | align: (end, center), 78 | 79 | "论文评阅人1:", info.reviewer.at(0), 80 | ..info.reviewer.enumerate(start: 0).slice(1).map(v => ([评阅人#(v.at(0)+1):], v.at(1))).flatten(), 81 | grid.cell(stroke: none)[], grid.cell(stroke: none)[], 82 | 83 | 84 | "答辩委员会主席 :", info.committe.at(0), 85 | ..info.committe.enumerate(start: 0).slice(1).map(v => ([委员#(v.at(0)):], v.at(1))).flatten(), 86 | grid.cell(stroke: none)[], grid.cell(stroke: none)[], 87 | ) 88 | #align(right)[ 89 | #grid( 90 | columns: (auto, 10em), 91 | align: (start, center), 92 | "答辩日期:", info.defense-date.at(0), 93 | ) 94 | ] 95 | ], 96 | ) 97 | } 98 | twoside-emptypage 99 | } 100 | -------------------------------------------------------------------------------- /pages/outline.typ: -------------------------------------------------------------------------------- 1 | #import "./template-individual.typ": template-individual 2 | #import "../dependency/i-figured.typ" 3 | 4 | 5 | #let main-outline( 6 | title: "目录", 7 | titlelevel: 2, 8 | outlined: false, 9 | ..args, 10 | ) = { 11 | template-individual(outlined: outlined, titlelevel: titlelevel, title, outline(depth: 3, title: none, ..args)) 12 | } 13 | 14 | #let figure-outline( 15 | title: "图目录", 16 | titlelevel: 2, 17 | outlined: false, 18 | ..args, 19 | ) = { 20 | template-individual( 21 | outlined: outlined, 22 | titlelevel: titlelevel, 23 | title, 24 | i-figured.outline(depth: 3, title: none, target-kind: image, ..args), 25 | ) 26 | } 27 | 28 | #let table-outline( 29 | title: "表目录", 30 | titlelevel: 2, 31 | outlined: false, 32 | ..args, 33 | ) = { 34 | template-individual( 35 | outlined: outlined, 36 | titlelevel: titlelevel, 37 | title, 38 | i-figured.outline(depth: 3, title: none, target-kind: table, ..args), 39 | ) 40 | } 41 | ) 42 | -------------------------------------------------------------------------------- /pages/template-individual.typ: -------------------------------------------------------------------------------- 1 | #import "../utils/fonts.typ": 字号, 字体 2 | #import "../utils/datetime-display.typ": datetime-display 3 | #import "../utils/twoside.typ": twoside-pagebreak 4 | 5 | #let template-individual( 6 | outlined: false, 7 | indent-first-par: true, 8 | titlelevel: 2, 9 | bodytext-settings: (size: 字号.四号), 10 | pagetitle, 11 | s, 12 | ) = { 13 | context { 14 | twoside-pagebreak 15 | set text(font: 字体.仿宋) 16 | 17 | 18 | align( 19 | center, 20 | text(size: 字号.三号, weight: "bold")[ 21 | #show heading: x => x.body 22 | #heading(pagetitle, numbering: none, level: titlelevel, outlined: outlined) 23 | #v(1em)], 24 | ) 25 | 26 | block(width: 100%)[ 27 | #set par(justify: true) 28 | #set text(..bodytext-settings) 29 | 30 | #s 31 | ] 32 | 33 | 34 | twoside-pagebreak 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /pages/undergraduate-cover.typ: -------------------------------------------------------------------------------- 1 | #import "../utils/fonts.typ": 字号, 字体 2 | #import "../utils/datetime-display.typ": datetime-display 3 | #import "../utils/twoside.typ": * 4 | 5 | 6 | #let undergraduate-cover( 7 | info: (:), 8 | // 其他参数 9 | stoke-width: 0.5pt, 10 | row-gutter: 11.5pt, 11 | anonymous-info-keys: ("grade", "student-id", "author", "supervisor"), 12 | ) = { 13 | info = ( 14 | ( 15 | title: ("毕业论文/设计", "题目"), 16 | grade: "20XX", 17 | student-id: "1234567890", 18 | author: "张三", 19 | department: "某学院", 20 | major: "某专业", 21 | supervisor: ("李四", "教授"), 22 | submit-date: datetime.today(), 23 | ) 24 | + info 25 | ) 26 | 27 | 28 | if type(info.submit-date) == datetime { 29 | info.submit-date = datetime-display(info.submit-date) 30 | } 31 | 32 | context { 33 | twoside-pagebreak 34 | counter(page).update(0) 35 | 36 | set text(weight: "bold", font: 字体.仿宋) 37 | 38 | align(right)[ 39 | 涉密论文 $square$ #h(1em) 公开论文 $square$ #h(8em) 40 | ] 41 | 42 | set align(center) 43 | 44 | 45 | v(22pt) 46 | image("../assets/zju-name.svg", width: page.width * 0.5) 47 | v(2pt) 48 | 49 | text(size: 字号.小一, font: 字体.黑体, spacing: 50%)[本 科 生 毕 业 论 文] 50 | 51 | image("../assets/zju-emblem.svg", width: page.width * 0.17) 52 | 53 | v(20pt) 54 | 55 | 56 | block( 57 | width: 70%, 58 | [ 59 | #set text(size: 字号.三号) 60 | #grid( 61 | columns: (0.5fr, 1fr), 62 | align: (start, center), 63 | rows: 1em, 64 | stroke: (x, y) => ( 65 | bottom: if x == 1 { 66 | stoke-width 67 | } else { 68 | none 69 | }, 70 | ), 71 | row-gutter: row-gutter, 72 | "题目", info.title.first(), 73 | ..info.title.slice(1).map(v => (none, v)).flatten(), 74 | grid.cell(stroke: none)[], grid.cell(stroke: none)[], 75 | "姓名与学号", info.author + " " + info.student-id, 76 | "指导教师", info.supervisor, 77 | "年级与专业", info.grade + info.major, 78 | "所在学院", info.department, 79 | grid.cell(stroke: none)[], grid.cell(stroke: none)[], 80 | "递交日期", info.submit-date, 81 | ) 82 | ], 83 | ) 84 | } 85 | twoside-emptypage 86 | } 87 | -------------------------------------------------------------------------------- /pages/undergraduate-decl.typ: -------------------------------------------------------------------------------- 1 | #import "../utils/fonts.typ": 字号, 字体 2 | #import "../utils/datetime-display.typ": datetime-display 3 | #import "./template-individual.typ": template-individual 4 | 5 | #let undergraduate-decl( 6 | row-gutter: 11.5pt, 7 | ) = { 8 | template-individual("浙江大学本科生毕业论文(设计)承诺书")[ 9 | #set underline(offset: 0.2em) 10 | #show enum.item: x => [ #x.number. #x.body] 11 | 12 | 1. 本人郑重地承诺所呈交的毕业论文(设计),是在指导教师的指导下严格按照学校和学院有关规定完成的。 13 | 14 | 2. 本人在毕业论文(设计)中除了文中特别加以标注和致谢的地方外,论文中不包含其他人已经发表或撰写过的研究成果,也不包含为获得#underline[*浙江大学*]或其他教育机构的学位或证书而使用过的材料。 15 | 16 | 3. 与我一同工作的同志对本研究所做的任何贡献均已在论文中作了明确的说明并表示谢意。 17 | 18 | 4. 本人承诺在毕业论文(设计)工作过程中没有伪造数据等行为。 19 | 20 | 5. 若在本毕业论文(设计)中有侵犯任何方面知识产权的行为,由本人承担相应的法律责任。 21 | 22 | 6. 本人完全了解#underline[*浙江大学*]有权保留并向有关部门或机构送交本论文(设计)的复印件和磁盘,允许本论文(设计)被查阅和借阅。本人授权#underline[*浙江大学*]可以将本论文(设计)的全部或部分内容编入有关数据库进行检索和传播,可以采用影印、缩印或扫描等复制手段保存、汇编本论文(设计)。 23 | 24 | #v(1fr) 25 | 26 | #align(center)[ 27 | #table( 28 | columns: (0.5fr, 0.4fr, 0.5fr, 0.4fr), 29 | align: (start, center), 30 | stroke: none, 31 | row-gutter: row-gutter, 32 | [ 作者签名: ], [], [ 导师签名: ], [], 33 | [], [], [], [], 34 | [ 签字日期: ], [ 年 #h(1em) 月#h(1em)日], [ 签字日期: ], [ 年#h(1em)月#h(1em)日], 35 | ) 36 | ] 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /pages/undergraduate-eval.typ: -------------------------------------------------------------------------------- 1 | #import "../utils/fonts.typ": 字号, 字体 2 | #import "../utils/datetime-display.typ": datetime-display 3 | #import "./template-individual.typ": template-individual 4 | #import "../utils/twoside.typ": * 5 | 6 | #let undergraduate-eval(scores: none, comment) = { 7 | template-individual("本科生毕业论文(设计)考核", outlined: true)[ 8 | #set text(size: 字号.小四) 9 | #strong[一、指导教师对毕业论文(设计)的评语:] 10 | 11 | #comment 12 | 13 | #v(0.8fr) 14 | #strong( 15 | align(right)[ 16 | 指导教师(签名)#box(width: 5em, stroke: (bottom: 0.5pt))\ 17 | 年#h(2em)月#h(2em)日 18 | ], 19 | ) 20 | 21 | #v(1em) 22 | #strong[#h(-2em)二、答辩小组对毕业论文(设计)的答辩评语及总评成绩:] 23 | #v(1fr) 24 | 25 | #strong[#table( 26 | columns: 6, 27 | align: center, 28 | [成绩比例], 29 | [文献综述#linebreak() (10%)], 30 | [开题报告#linebreak()(15%)], 31 | [外文翻译#linebreak()(5%)], 32 | [毕业论文质量及答辩#linebreak()(70%)], 33 | [总评成绩], 34 | 35 | [分值], ..( 36 | if scores == none { 37 | () 38 | } else { 39 | ( 40 | [#scores.at(0)], 41 | [#scores.at(1)], 42 | [#scores.at(2)], 43 | [#scores.at(3)], 44 | [#scores.sum()], 45 | ) 46 | } 47 | ) 48 | ) 49 | 50 | #align(right)[ 51 | 负责人(签名)#box(width: 5em, stroke: (bottom: 0.5pt))\ 52 | 年#h(2em)月#h(2em)日 53 | ]] 54 | ] 55 | twoside-emptypage 56 | } 57 | -------------------------------------------------------------------------------- /pages/undergraduate-proposal-cover.typ: -------------------------------------------------------------------------------- 1 | #import "../utils/fonts.typ": 字号, 字体 2 | #import "../utils/datetime-display.typ": datetime-display 3 | #import "../utils/twoside.typ": * 4 | 5 | 6 | #let undergraduate-proposal-cover( 7 | info: (:), 8 | // 其他参数 9 | stoke-width: 0.5pt, 10 | row-gutter: 11.5pt, 11 | anonymous-info-keys: ("grade", "student-id", "author", "supervisor"), 12 | ) = { 13 | info = ( 14 | ( 15 | title: ("毕业论文/设计", "题目"), 16 | grade: "20XX", 17 | student-id: "1234567890", 18 | author: "张三", 19 | department: "某学院", 20 | major: "某专业", 21 | supervisor: ("李四", "教授"), 22 | submit-date: datetime.today(), 23 | ) 24 | + info 25 | ) 26 | 27 | 28 | if type(info.submit-date) == datetime { 29 | info.submit-date = datetime-display(info.submit-date) 30 | } 31 | 32 | context { 33 | twoside-pagebreak 34 | counter(page).update(0) 35 | 36 | set text(weight: "bold", font: 字体.仿宋) 37 | 38 | 39 | set align(center) 40 | 41 | 42 | v(22pt) 43 | image("../assets/zju-name.svg", width: page.width * 0.5) 44 | v(2pt) 45 | 46 | text(size: 字号.小一, font: 字体.黑体, spacing: 100%)[本 科 生 毕 业 论 文] 47 | 48 | v(24pt) 49 | text(size: 字号.小一, font: 字体.黑体)[文献综述和开题报告] 50 | 51 | image("../assets/zju-emblem.svg", width: page.width * 0.17) 52 | 53 | v(20pt) 54 | 55 | 56 | block( 57 | width: 70%, 58 | [ 59 | #set text(size: 字号.三号) 60 | #grid( 61 | columns: (0.5fr, 1fr), 62 | align: (start, center), 63 | rows: 1em, 64 | stroke: (x, y) => ( 65 | bottom: if x == 1 { 66 | stoke-width 67 | } else { 68 | none 69 | }, 70 | ), 71 | row-gutter: row-gutter, 72 | "题目", info.title.first(), 73 | ..info.title.slice(1).map(v => (none, v)).flatten(), 74 | grid.cell(stroke: none)[], grid.cell(stroke: none)[], 75 | "姓名与学号", info.author + " " + info.student-id, 76 | "指导教师", info.supervisor, 77 | "年级与专业", info.grade + info.major, 78 | "所在学院", info.department, 79 | grid.cell(stroke: none)[], grid.cell(stroke: none)[], 80 | ) 81 | ], 82 | ) 83 | } 84 | twoside-emptypage 85 | } 86 | -------------------------------------------------------------------------------- /pages/undergraduate-proposal-eval.typ: -------------------------------------------------------------------------------- 1 | #import "../utils/fonts.typ": 字号, 字体 2 | #import "../utils/datetime-display.typ": datetime-display 3 | #import "./template-individual.typ": template-individual 4 | 5 | #let undergraduate-proposal-eval( 6 | comment, 7 | scores-supervisor: none, 8 | scores-college: none, 9 | ) = { 10 | template-individual("毕业论文(设计)文献综述和开题报告考核", outlined: true)[ 11 | #set text(weight: "bold", size: 字号.小四) 12 | 导师对开题报告、外文翻译和文献综述的评语及成绩评定:\ 13 | 14 | #comment 15 | 16 | #v(0.8fr) 17 | #align(right)[ 18 | #table( 19 | columns: 4, 20 | align: center, 21 | [成绩比例], [文献综述#linebreak() (10%)], [开题报告#linebreak()(15%)], [外文翻译#linebreak()(5%)], 22 | [分值], ..( 23 | if scores-supervisor == none { 24 | () 25 | } else { 26 | ( 27 | [#scores-supervisor.at(0)], 28 | [#scores-supervisor.at(1)], 29 | [#scores-supervisor.at(2)], 30 | ) 31 | } 32 | ) 33 | ) 34 | 导师签名#box(width: 5em, stroke: (bottom: 0.5pt))\ 35 | 年#h(2em)月#h(2em)日 36 | ] 37 | 38 | #v(1em) 39 | 学院盲审专家对开题报告、外文翻译和文献综述的评语及成绩评定: 40 | #v(1fr) 41 | 42 | 43 | 44 | #align(right)[ 45 | #table( 46 | columns: 4, 47 | align: center, 48 | [成绩比例], [文献综述#linebreak() (10%)], [开题报告#linebreak()(15%)], [外文翻译#linebreak()(5%)], 49 | [分值], ..( 50 | if scores-college == none { 51 | () 52 | } else { 53 | ( 54 | [#scores-college.at(0)], 55 | [#scores-college.at(1)], 56 | [#scores-college.at(2)], 57 | ) 58 | } 59 | ) 60 | ) 61 | 开题报告审核负责人(签名/签章)#box(width: 5em, stroke: (bottom: 0.5pt))\ 62 | 年#h(2em)月#h(2em)日 63 | ] 64 | ] 65 | } 66 | -------------------------------------------------------------------------------- /pages/undergraduate-proposal-task.typ: -------------------------------------------------------------------------------- 1 | #import "../utils/fonts.typ": 字号, 字体 2 | #import "../utils/datetime-display.typ": datetime-display 3 | #import "../utils/twoside.typ": * 4 | #import "./template-individual.typ": template-individual 5 | 6 | #let undergraduate-proposal-task(info: (:), s) = { 7 | template-individual(none, outlined: false)[ 8 | #set text(size: 字号.小四) 9 | #strong[ 10 | 一、题目:#info.title.join()\ 11 | 二、指导教师对文献综述开题报告、外文翻译的具体要求:] 12 | 13 | #s 14 | 15 | #v(1fr) 16 | 17 | 18 | #strong( 19 | align(right)[ 20 | 指导教师(签名)#box(width: 5em, stroke: (bottom: 0.5pt))], 21 | ) 22 | 23 | 24 | ] 25 | twoside-emptypage 26 | } 27 | -------------------------------------------------------------------------------- /pages/undergraduate-task.typ: -------------------------------------------------------------------------------- 1 | #import "../utils/fonts.typ": 字号, 字体 2 | #import "../utils/datetime-display.typ": datetime-display 3 | #import "../utils/twoside.typ": * 4 | #import "./template-individual.typ": template-individual 5 | 6 | #let undergraduate-task(info: (:), task, comment: none) = { 7 | template-individual("本科生毕业论文(设计)任务书", outlined: true)[ 8 | #set text(size: 字号.小四) 9 | #strong[ 10 | 一、题目:#info.title.join()\ 11 | 二、指导教师对毕业论文(设计)的进度安排及任务要求:] 12 | 13 | #task 14 | 15 | #v(0.8fr) 16 | #strong[起讫日期 20 #h(1.5em) 年 #h(1.5em) 月 #h(1.5em) 日 至 20 #h(1.5em) 年 #h(1.5em) 月 #h(1.5em) 日] 17 | #v(1em) 18 | 19 | #strong( 20 | align(right)[ 21 | 指导教师(签名)#box(width: 5em, stroke: (bottom: 0.5pt)) 职称#box(width: 5em, stroke: (bottom: 0.5pt))], 22 | ) 23 | 24 | #v(2em) 25 | #strong[#h(-2em)三、系或研究所意见:] 26 | 27 | 28 | #v(1fr) 29 | 30 | #strong( 31 | align(right)[ 32 | 负责人(签名)#box(width: 5em, stroke: (bottom: 0.5pt))\ 33 | 年#h(2em)月#h(2em)日 34 | ], 35 | ) 36 | ] 37 | twoside-emptypage 38 | } 39 | -------------------------------------------------------------------------------- /scripts/get-fonts.sh: -------------------------------------------------------------------------------- 1 | mkdir -p fonts 2 | pushd fonts 3 | wget -c https://raw.githubusercontent.com/Haixing-Hu/latex-chinese-fonts/master/english/Serif/TimesNewRoman.ttf 4 | wget -c https://raw.githubusercontent.com/Haixing-Hu/latex-chinese-fonts/master/english/Serif/TimesNewRomanBold.ttf 5 | wget -c https://raw.githubusercontent.com/Haixing-Hu/latex-chinese-fonts/master/english/Serif/TimesNewRomanItalic.ttf 6 | wget -c https://raw.githubusercontent.com/Haixing-Hu/latex-chinese-fonts/master/english/Serif/TimesNewRomanBoldItalic.ttf 7 | wget -c https://raw.githubusercontent.com/Haixing-Hu/latex-chinese-fonts/master/chinese/%E4%BB%BF%E5%AE%8B%E4%BD%93/FangSong.ttf 8 | wget -c https://raw.githubusercontent.com/Haixing-Hu/latex-chinese-fonts/master/chinese/%E5%AE%8B%E4%BD%93/SimSun.ttc 9 | wget -c https://raw.githubusercontent.com//Haixing-Hu/latex-chinese-fonts/master/chinese/%E9%BB%91%E4%BD%93/SimHei.ttf 10 | wget -c https://raw.githubusercontent.com//Haixing-Hu/latex-chinese-fonts/master/chinese/%E6%A5%B7%E4%BD%93/Kaiti.ttf 11 | wget -c https://raw.githubusercontent.com/Halfish/lstm-ctc-ocr/master/fonts/simkai.ttf 12 | popd -------------------------------------------------------------------------------- /utils/appendix.typ: -------------------------------------------------------------------------------- 1 | #let appendix(level: 2, body) = { 2 | counter(heading).update(0) 3 | 4 | show heading: set heading( 5 | numbering: (..numbers) => { 6 | let clevel = numbers.pos().len() 7 | if (clevel <= level) { 8 | return none 9 | } else { 10 | return numbering("A ", ..numbers.pos().slice(level)) 11 | } 12 | }, 13 | supplement: [附录], 14 | ) 15 | 16 | body 17 | } 18 | -------------------------------------------------------------------------------- /utils/bib-provider.typ: -------------------------------------------------------------------------------- 1 | 2 | #let bib-provider(bibsource, mode: "") = { 3 | let typstbib = bibliography(bytes(bibsource), style: "gb-7714-2015-numeric", title: none) 4 | let hiddenbib = [ 5 | #show bibliography: none // to provide hint in the editor 6 | #typstbib 7 | ] 8 | if mode == "bilingual" { 9 | import "./bilingual-bibliography.typ": show-bilingual-bibliography 10 | 11 | ( 12 | bibcontent: typstbib, 13 | bibshow: show-bilingual-bibliography, 14 | hiddenbib: none, 15 | new-bib: () => (), 16 | ) 17 | } else if (mode == "citext") { 18 | import "./citext/lib.typ": * 19 | let bib = init-citation(bibsource) 20 | 21 | ( 22 | bibcontent: extbib(bib), 23 | bibshow: show-extcite.with(bib: bib, gen-id: true), 24 | hiddenbib: hiddenbib, 25 | new-bib: new-citext-session, 26 | ) 27 | } else if (mode == "partbib") { 28 | import "./part.typ": * 29 | ( 30 | bibcontent: part-bib, 31 | bibshow: x => x, 32 | hiddenbib: hiddenbib, 33 | new-bib: () => part-refs.update(()), 34 | ) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /utils/bilingual-bibliography.typ: -------------------------------------------------------------------------------- 1 | // Authors: csimide, OrangeX4 2 | // Tested only on GB-7714-2015-Numeric 3 | // 4 | // 5 | #let to-string(content) = { 6 | if content.has("text") { 7 | content.text 8 | } else if content.has("children") { 9 | content.children.map(to-string).join("") 10 | } else if content.has("child") { 11 | to-string(content.child) 12 | } else if content.has("body") { 13 | to-string(content.body) 14 | } else if content == [ ] { 15 | " " 16 | } 17 | } 18 | 19 | #let show-bilingual-bib-entry(s) = { 20 | // Please fill in the remaining mapping table here 21 | let mapping = ( 22 | //"等": "et al", 23 | "卷": "Vol.", 24 | "册": "Bk.", 25 | // "译": "tran", 26 | // "等译": "et al. tran", 27 | // 注: 请见下方译者数量判断部分。 28 | ) 29 | 30 | 31 | show grid.cell.where(x: 1): it => { 32 | // 后续的操作是对 string 进行的。 33 | let ittext = to-string(it) 34 | // 判断是否为中文文献:去除特定词组后,仍有至少两个连续汉字。 35 | let pureittext = ittext.replace(regex("[等卷册和版本章期页篇译间者(不详)]"), "") 36 | if pureittext.find(regex("\p{sc=Hani}{2,}")) != none { 37 | ittext 38 | } else { 39 | // 若不是中文文献,进行替换 40 | // 第xxx卷、第xxx册的情况:变为 Vol. XXX 或 Bk. XXX。 41 | let reptext = ittext 42 | reptext = reptext.replace( 43 | regex("(第\s?)?\d+\s?[卷册]"), 44 | itt => { 45 | if itt.text.contains("卷") { 46 | "Vol. " 47 | } else { 48 | "Bk. " 49 | } 50 | itt.text.find(regex("\d+")) 51 | }, 52 | ) 53 | 54 | // 第xxx版/第xxx本的情况:变为 1st ed 格式。 55 | reptext = reptext.replace( 56 | regex("(第\s?)?\d+\s?[版本]"), 57 | itt => { 58 | let num = itt.text.find(regex("\d+")) 59 | num 60 | if num.clusters().len() == 2 and num.clusters().first() == "1" { 61 | "th" 62 | } else { 63 | ( 64 | "1": "st", 65 | "2": "nd", 66 | "3": "rd", 67 | ).at(num.clusters().last(), default: "th") 68 | } 69 | " ed" 70 | }, 71 | ) 72 | 73 | // 译者数量判断:单数时需要用 trans,复数时需要用 tran 。 74 | /* 75 | 注: 76 | 1. 目前判断译者数量的方法非常草率,有逗号就是多个作者。但是在部分 GB/T 7714-2015 方言中,姓名中可以含有逗号。 77 | 2. 在 GB/T 7714-2015 原文中有 `等译`(P15 10.1.3 小节 示例 1-[1]),但未给出相应的英文缩写翻译。 78 | 3. CSL 社区库内的 GB/T 7714-2015 会使用 `等, 译` 和 `et al., tran` 的写法。为了保证统一性,这里会译作不带逗号的版本,即 `et al. tran` 79 | 如果工作不正常,可以考虑换为简单关键词替换,即注释这段情况,取消 13 行 mapping 内 `译` 条目的注释。 80 | */ 81 | reptext = reptext.replace( 82 | regex("\].+?译"), 83 | itt => { 84 | // 我想让上面这一行匹配变成非贪婪的,但加问号后没啥效果? 85 | if itt.text.replace(regex(",\s?译"), "").find(",") != none { 86 | itt.text.replace(regex(",?\s?译"), " tran") 87 | } else { 88 | itt.text.replace(regex(",?\s?译"), " trans") 89 | } 90 | }, 91 | ) 92 | 93 | // `等` 特殊处理:`等`后方接内容也需要译作 `et al.`,如 `等译` 需要翻译为 `et al. trans` 94 | reptext = reptext.replace( 95 | regex("等."), 96 | itt => { 97 | "et al." 98 | // 如果原文就是 `等.`,则仅需简单替换,不需要额外处理 99 | // 如果原文 `等` 后没有跟随英文标点,则需要补充一个空格 100 | if not itt.text.last() in (".", ",", ";", ":", "[", "]", "/", "\\", "<", ">", "?", "(", ")", " ", "\"", "'") { 101 | " " 102 | } 103 | // 原文有英文句号时不需要重复句号,否则需要将匹配到的最后一个字符吐回来 104 | if not itt.text.last() == "." { 105 | itt.text.last() 106 | } 107 | }, 108 | ) 109 | 110 | // 其他情况:直接替换 111 | reptext = reptext.replace( 112 | regex("\p{sc=Hani}+"), 113 | itt => { 114 | mapping.at(itt.text, default: itt.text) 115 | // 注意:若替换功能工作良好,应该不会出现 `default` 情形 116 | }, 117 | ) 118 | reptext 119 | } 120 | } 121 | s 122 | } 123 | 124 | #let show-bilingual-bibliography(s) = { 125 | show bibliography: show-bilingual-bib-entry 126 | s 127 | } 128 | -------------------------------------------------------------------------------- /utils/citext/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 mgt 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. -------------------------------------------------------------------------------- /utils/citext/README.md: -------------------------------------------------------------------------------- 1 | This folder is copied from https://github.com/Shuenhoy/citext 2 | 3 | Any changes should be made there first. -------------------------------------------------------------------------------- /utils/citext/dist/index.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shuenhoy/modern-zju-thesis/1b43af5689b9b665cf134556caafda517aa64039/utils/citext/dist/index.bin -------------------------------------------------------------------------------- /utils/citext/dist/third-party-licenses.txt: -------------------------------------------------------------------------------- 1 | Name: @citation-js/core 2 | Version: 0.7.18 3 | License: MIT 4 | Private: false 5 | Description: Convert different bibliographic metadata sources 6 | Repository: https://github.com/citation-js/citation-js.git 7 | Homepage: https://citation.js.org/ 8 | Author: Lars Willighagen 9 | License Copyright: 10 | === 11 | 12 | The MIT License (MIT) 13 | 14 | Copyright (c) 2015-2024 Lars Willighagen 15 | 16 | Permission is hereby granted, free of charge, to any person obtaining a copy 17 | of this software and associated documentation files (the "Software"), to deal 18 | in the Software without restriction, including without limitation the rights 19 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20 | copies of the Software, and to permit persons to whom the Software is 21 | furnished to do so, subject to the following conditions: 22 | 23 | The above copyright notice and this permission notice shall be included in 24 | all copies or substantial portions of the Software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 27 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 31 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 32 | THE SOFTWARE. 33 | 34 | --- 35 | 36 | Name: @citation-js/name 37 | Version: 0.4.2 38 | License: MIT 39 | Private: false 40 | Description: Name parser 41 | Repository: git+https://github.com/citation-js/name.git 42 | Homepage: https://github.com/citation-js/name#readme 43 | Author: Lars Willighagen 44 | 45 | --- 46 | 47 | Name: buffer 48 | Version: 5.7.1 49 | License: MIT 50 | Private: false 51 | Description: Node.js Buffer API, for the browser 52 | Repository: git://github.com/feross/buffer.git 53 | Homepage: https://github.com/feross/buffer 54 | Author: Feross Aboukhadijeh (https://feross.org) 55 | Contributors: 56 | Romain Beauxis 57 | James Halliday 58 | License Copyright: 59 | === 60 | 61 | The MIT License (MIT) 62 | 63 | Copyright (c) Feross Aboukhadijeh, and other contributors. 64 | 65 | Permission is hereby granted, free of charge, to any person obtaining a copy 66 | of this software and associated documentation files (the "Software"), to deal 67 | in the Software without restriction, including without limitation the rights 68 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 69 | copies of the Software, and to permit persons to whom the Software is 70 | furnished to do so, subject to the following conditions: 71 | 72 | The above copyright notice and this permission notice shall be included in 73 | all copies or substantial portions of the Software. 74 | 75 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 76 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 77 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 78 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 79 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 80 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 81 | THE SOFTWARE. 82 | 83 | --- 84 | 85 | Name: base64-js 86 | Version: 1.5.1 87 | License: MIT 88 | Private: false 89 | Description: Base64 encoding/decoding in pure JS 90 | Repository: git://github.com/beatgammit/base64-js.git 91 | Homepage: https://github.com/beatgammit/base64-js 92 | Author: T. Jameson Little 93 | License Copyright: 94 | === 95 | 96 | The MIT License (MIT) 97 | 98 | Copyright (c) 2014 Jameson Little 99 | 100 | Permission is hereby granted, free of charge, to any person obtaining a copy 101 | of this software and associated documentation files (the "Software"), to deal 102 | in the Software without restriction, including without limitation the rights 103 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 104 | copies of the Software, and to permit persons to whom the Software is 105 | furnished to do so, subject to the following conditions: 106 | 107 | The above copyright notice and this permission notice shall be included in 108 | all copies or substantial portions of the Software. 109 | 110 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 111 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 112 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 113 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 114 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 115 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 116 | THE SOFTWARE. 117 | 118 | --- 119 | 120 | Name: ieee754 121 | Version: 1.2.1 122 | License: BSD-3-Clause 123 | Private: false 124 | Description: Read/write IEEE754 floating point numbers from/to a Buffer or array-like object 125 | Repository: git://github.com/feross/ieee754.git 126 | Author: Feross Aboukhadijeh (https://feross.org) 127 | Contributors: 128 | Romain Beauxis 129 | License Copyright: 130 | === 131 | 132 | Copyright 2008 Fair Oaks Labs, Inc. 133 | 134 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 135 | 136 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 137 | 138 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 139 | 140 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 141 | 142 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 143 | 144 | --- 145 | 146 | Name: sync-fetch 147 | Version: 0.4.5 148 | License: MIT 149 | Private: false 150 | Description: Synchronous version of the Fetch API 151 | Repository: git+https://github.com/larsgw/sync-fetch.git 152 | Homepage: https://github.com/larsgw/sync-fetch#readme 153 | Author: Lars Willighagen 154 | License Copyright: 155 | === 156 | 157 | MIT License 158 | 159 | Copyright (c) 2019 Lars Willighagen 160 | 161 | Permission is hereby granted, free of charge, to any person obtaining a copy 162 | of this software and associated documentation files (the "Software"), to deal 163 | in the Software without restriction, including without limitation the rights 164 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 165 | copies of the Software, and to permit persons to whom the Software is 166 | furnished to do so, subject to the following conditions: 167 | 168 | The above copyright notice and this permission notice shall be included in all 169 | copies or substantial portions of the Software. 170 | 171 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 172 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 173 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 174 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 175 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 176 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 177 | SOFTWARE. 178 | 179 | --- 180 | 181 | Name: fetch-ponyfill 182 | Version: 7.1.0 183 | License: MIT 184 | Private: false 185 | Description: A ponyfill (doesn't overwrite the native fetch) for the Fetch specification https://fetch.spec.whatwg.org. 186 | Repository: git://github.com/qubyte/fetch-ponyfill.git 187 | Author: Mark Stanley Everitt 188 | License Copyright: 189 | === 190 | 191 | The MIT License (MIT) 192 | 193 | Copyright (c) 2017 Mark Stanley Everitt 194 | 195 | Permission is hereby granted, free of charge, to any person obtaining a copy 196 | of this software and associated documentation files (the "Software"), to deal 197 | in the Software without restriction, including without limitation the rights 198 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 199 | copies of the Software, and to permit persons to whom the Software is 200 | furnished to do so, subject to the following conditions: 201 | 202 | The above copyright notice and this permission notice shall be included in all 203 | copies or substantial portions of the Software. 204 | 205 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 206 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 207 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 208 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 209 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 210 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 211 | SOFTWARE. 212 | 213 | --- 214 | 215 | Name: @citation-js/plugin-csl 216 | Version: 0.7.18 217 | License: MIT 218 | Private: false 219 | Description: Plugin for CSL output for Citation.js 220 | Repository: https://github.com/citation-js/citation-js.git 221 | Homepage: https://citation.js.org/ 222 | Author: Lars Willighagen 223 | License Copyright: 224 | === 225 | 226 | The MIT License (MIT) 227 | 228 | Copyright (c) 2015-2024 Lars Willighagen 229 | 230 | Permission is hereby granted, free of charge, to any person obtaining a copy 231 | of this software and associated documentation files (the "Software"), to deal 232 | in the Software without restriction, including without limitation the rights 233 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 234 | copies of the Software, and to permit persons to whom the Software is 235 | furnished to do so, subject to the following conditions: 236 | 237 | The above copyright notice and this permission notice shall be included in 238 | all copies or substantial portions of the Software. 239 | 240 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 241 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 242 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 243 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 244 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 245 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 246 | THE SOFTWARE. 247 | 248 | --- 249 | 250 | Name: citeproc 251 | Version: 2.4.63 252 | License: CPAL-1.0 OR AGPL-1.0 253 | Private: false 254 | Description: The citeproc-js citation formatting module, in CommonJS format. This version is based on citeproc-js 1.4.63 255 | Repository: https://github.com/juris-m/citeproc-js.git 256 | Author: Michael McMillan (http://michaelmcmillan.net/) 257 | Contributors: 258 | Frank Bennett (https://juris-m.github.io) 259 | License Copyright: 260 | === 261 | 262 | Copyright (c) 2009-2019 Frank Bennett 263 | 264 | This program is free software: you can redistribute it and/or 265 | modify it under EITHER 266 | 267 | * the terms of the Common Public Attribution License (CPAL) as 268 | published by the Open Source Initiative, either version 1 of 269 | the CPAL, or (at your option) any later version; OR 270 | 271 | * the terms of the GNU Affero General Public License (AGPL) 272 | as published by the Free Software Foundation, either version 273 | 3 of the AGPL, or (at your option) any later version. 274 | 275 | This program is distributed in the hope that it will be useful, 276 | but WITHOUT ANY WARRANTY; without even the implied warranty of 277 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 278 | Affero General Public License for more details. 279 | 280 | You should have received copies of the Common Public Attribution 281 | License and of the GNU Affero General Public License along with 282 | this program. If not, see or 283 | respectively. 284 | 285 | --- 286 | 287 | Name: moo 288 | Version: 0.5.2 289 | License: BSD-3-Clause 290 | Private: false 291 | Description: Optimised tokenizer/lexer generator! 🐄 Much performance. Moo! 292 | Repository: undefined 293 | Author: Tim Radvan 294 | Contributors: 295 | Nathan 296 | License Copyright: 297 | === 298 | 299 | BSD 3-Clause License 300 | 301 | Copyright (c) 2017, Tim Radvan (tjvr) 302 | All rights reserved. 303 | 304 | Redistribution and use in source and binary forms, with or without 305 | modification, are permitted provided that the following conditions are met: 306 | 307 | * Redistributions of source code must retain the above copyright notice, this 308 | list of conditions and the following disclaimer. 309 | 310 | * Redistributions in binary form must reproduce the above copyright notice, 311 | this list of conditions and the following disclaimer in the documentation 312 | and/or other materials provided with the distribution. 313 | 314 | * Neither the name of the copyright holder nor the names of its 315 | contributors may be used to endorse or promote products derived from 316 | this software without specific prior written permission. 317 | 318 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 319 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 320 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 321 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 322 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 323 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 324 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 325 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 326 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 327 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 328 | 329 | --- 330 | 331 | Name: @citation-js/plugin-bibtex 332 | Version: 0.7.18 333 | License: MIT 334 | Private: false 335 | Description: Plugin for BibTeX formats for Citation.js 336 | Repository: https://github.com/citation-js/citation-js.git 337 | Homepage: https://citation.js.org/ 338 | Author: Lars Willighagen 339 | License Copyright: 340 | === 341 | 342 | The MIT License (MIT) 343 | 344 | Copyright (c) 2015-2024 Lars Willighagen 345 | 346 | Permission is hereby granted, free of charge, to any person obtaining a copy 347 | of this software and associated documentation files (the "Software"), to deal 348 | in the Software without restriction, including without limitation the rights 349 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 350 | copies of the Software, and to permit persons to whom the Software is 351 | furnished to do so, subject to the following conditions: 352 | 353 | The above copyright notice and this permission notice shall be included in 354 | all copies or substantial portions of the Software. 355 | 356 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 357 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 358 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 359 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 360 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 361 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 362 | THE SOFTWARE. 363 | 364 | --- 365 | 366 | Name: @citation-js/date 367 | Version: 0.5.1 368 | License: MIT 369 | Private: false 370 | Description: Date parser and formatter 371 | Repository: git+https://github.com/citation-js/date.git 372 | Homepage: https://github.com/citation-js/date#readme 373 | Author: Lars Willighagen -------------------------------------------------------------------------------- /utils/citext/gb-t-7714-2015-numeric-bilingual.csl: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /utils/citext/lib.typ: -------------------------------------------------------------------------------- 1 | #import "@preview/ctxjs:0.3.1" 2 | #import "@preview/mitex:0.2.4": mi 3 | 4 | 5 | #let cite-src = read("./dist/index.bin", encoding: none) 6 | 7 | 8 | #let gb-t-7714-2015-numeric-bilingual = read("gb-t-7714-2015-numeric-bilingual.csl") 9 | #let locales-zh-CN = read("locales-zh-CN.xml") 10 | 11 | #let simple-split(bs) = { 12 | str.split("\n" + bs, "\n@").map(str.trim).filter(it => it != "").map(it => "@" + it) 13 | // for each element x, first line must be @{, 14 | // make a dict with key as key and value as x 15 | } 16 | 17 | #let init-citation(bib, csl: gb-t-7714-2015-numeric-bilingual, locales: locales-zh-CN, mode: "lazy") = { 18 | let ctx = ctxjs.new-context( 19 | load: ( 20 | ctxjs.load.load-module-bytecode(cite-src), 21 | ctxjs.load.call-module-function("citext", "initConfig", (gb-t-7714-2015-numeric-bilingual, locales-zh-CN)), 22 | ), 23 | ) 24 | 25 | if mode == "stable" { 26 | let cites = ctxjs.ctx.call-module-function(ctx, "citext", "citex", (bib.replace("$", "\\$"),)) 27 | 28 | ( 29 | get: id => cites.at(id), 30 | ) 31 | } else { 32 | let bibs = simple-split(bib.replace("$", "\\$")) 33 | 34 | if mode == "lazy" { 35 | let bibs = bibs 36 | .map(x => { 37 | let key = str.split(x, "{").at(1).split(",").at(0) 38 | (key.trim(), x) 39 | }) 40 | .to-dict() 41 | 42 | ( 43 | get: id => { 44 | let v = bibs.at(str(id)) 45 | ctxjs.ctx.call-module-function(ctx, "citext", "citeone", (v,)).at(1) 46 | }, 47 | ) 48 | } else if mode == "eager" { 49 | let cites = bibs 50 | .map(v => { 51 | ctxjs.ctx.call-module-function(ctx, "citext", "citeone", (v,)) 52 | }) 53 | .to-dict() 54 | ( 55 | get: id => cites.at(str(id)), 56 | ) 57 | } 58 | } 59 | } 60 | 61 | 62 | #let extcitefull(bib, id) = { 63 | show regex("\$.+?\$"): it => mi(it) 64 | (bib.get)(id).at("bibliography") 65 | } 66 | #let citeauthor-one-two-more(authors, ETAL: none, AND: none) = { 67 | let len = authors.len() 68 | if len > 2 { 69 | return authors.at(0).family + ETAL 70 | } else if len == 2 { 71 | return authors.at(0).family + AND + authors.at(1).family 72 | } else { 73 | return authors.at(0).family 74 | } 75 | } 76 | #let en-US-citeauthor = citeauthor-one-two-more.with(AND: " and ", ETAL: " et al.") 77 | #let zh-CN-citeauthor = citeauthor-one-two-more.with(AND: "和", ETAL: "等") 78 | 79 | #let extciteauthor( 80 | bib, 81 | id, 82 | mapping: ( 83 | en-US: zh-CN-citeauthor, 84 | zh-CN: zh-CN-citeauthor, 85 | ), 86 | ) = { 87 | let entry = (bib.get)(id) 88 | mapping.at(entry.at("language"), default: mapping.en-US)(entry.at("author")) 89 | } 90 | 91 | #let cite-targets = state("cite-targets", ()) 92 | #let new-citext-session() = { 93 | cite-targets.update(()) 94 | } 95 | 96 | #let get-ref-id(key, loc) = { 97 | str(cite-targets.at(loc).position(x => x == key) + 1) 98 | } 99 | 100 | 101 | #let show-extcite(s, bib: (:), gen-id: false) = { 102 | let updatecite(key) = { 103 | cite-targets.update(old => { 104 | if key not in old { 105 | old.push(key) 106 | } 107 | old 108 | }) 109 | } 110 | let numeric-cite(key) = { 111 | updatecite(key) 112 | if gen-id { 113 | context { 114 | super("[" + get-ref-id(key, here()) + "]") 115 | } 116 | } else { 117 | it 118 | } 119 | } 120 | show ref: it => { 121 | if it.element != none { 122 | // Citing a document element like a figure, not a bib key 123 | // So don't update refs 124 | it 125 | return 126 | } 127 | numeric-cite(it.target) 128 | } 129 | 130 | show cite.where(form: "normal"): it => { 131 | numeric-cite(it.key) 132 | } 133 | 134 | show ref.where(label: ): it => { 135 | extciteauthor(bib, str(it.target)) 136 | } 137 | show cite.where(form: "author"): it => { 138 | extciteauthor(bib, str(it.key)) 139 | } 140 | 141 | show ref.where(label: ): it => { 142 | cite(it.target, form: "year") 143 | } 144 | 145 | show ref.where(label: ): it => { 146 | [#extciteauthor(bib, str(it.target)) #cite(it.target)] 147 | } 148 | 149 | show cite.where(form: "prose"): it => { 150 | [#extciteauthor(bib, str(it.key)) #cite(it.key)] 151 | } 152 | 153 | show ref.where(label: ): it => { 154 | show super: it => it.body 155 | [#extciteauthor(bib, str(it.target)) #cite(it.target)] 156 | } 157 | 158 | show ref.where(label: ): it => { 159 | [#footnote[#extcitefull(bib, str(it.target))]] 160 | } 161 | 162 | show cite.where(form: "full"): it => { 163 | extcitefull(bib, str(it.key)) 164 | } 165 | s 166 | } 167 | 168 | 169 | 170 | #let extbib(bib) = { 171 | context { 172 | grid( 173 | columns: 2, 174 | column-gutter: 0.65em, 175 | row-gutter: 1.2em, 176 | ..cite-targets 177 | .at(here()) 178 | .enumerate() 179 | .map(x => { 180 | let i = x.at(0) + 1 181 | let target = x.at(1) 182 | ([\[#i\]], extcitefull(bib, str(target))) 183 | }) 184 | .flatten() 185 | ) 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /utils/citext/locales-zh-CN.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | rongls 6 | 7 | 8 | sati-bodhi 9 | 10 | 11 | Heromyth 12 | 13 | This work is licensed under 14 | a Creative Commons Attribution-ShareAlike 3.0 License 15 | 2014-05-15T23:31:02+00:00 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | advance online publication 30 | album 31 | audio recording 32 | film 33 | henceforth 34 | loc. cit. 36 | no place 37 | n.p. 38 | no publisher 39 | n.p. 40 | on 41 | op. cit. 42 | original work published 43 | 的私人交流 44 | podcast 45 | podcast episode 46 | preprint 47 | radio broadcast 48 | radio series 49 | radio series episode 50 | special issue 51 | special section 52 | television broadcast 53 | television series 54 | television series episode 55 | video 56 | working paper 57 | 见于 58 | 59 | 及其他 60 | 作者不详 61 | 无名氏 62 | 63 | 载于 64 | 65 | 介于 66 | 67 | 见引于 68 | 69 | reference 70 | references 71 | 72 | 73 | number 74 | numbers 75 | 76 | 版本 77 | 78 | ref. 79 | refs. 80 | 81 | 82 | no. 83 | nos. 84 | 85 | 86 | 87 | 即将出版 88 | 89 | 同上 90 | 收入 91 | 送印中 92 | 网际网络 93 | 信函 94 | 日期不详 95 | 不详 96 | 在线 97 | 发表于 98 | 参考 99 | 100 | review of 101 | rev. of 102 | 取读于 103 | 比例 104 | 105 | 106 | 107 | preprint 108 | journal article 109 | magazine article 110 | newspaper article 111 | bill 112 | 113 | broadcast 114 | 115 | classic 116 | collection 117 | dataset 118 | document 119 | entry 120 | dictionary entry 121 | encyclopedia entry 122 | event 123 | 124 | graphic 125 | hearing 126 | 访谈 127 | legal case 128 | legislation 129 | manuscript 130 | map 131 | video recording 132 | musical score 133 | pamphlet 134 | conference paper 135 | patent 136 | performance 137 | periodical 138 | 的私人交流 139 | post 140 | blog post 141 | regulation 142 | report 143 | review 144 | book review 145 | software 146 | audio recording 147 | presentation 148 | standard 149 | thesis 150 | treaty 151 | webpage 152 | 153 | 154 | journal art. 155 | mag. art. 156 | newspaper art. 157 | 158 | 159 | doc. 160 | 161 | graph. 162 | interv. 163 | MS 164 | video rec. 165 | rep. 166 | rev. 167 | bk. rev. 168 | audio rec. 169 | 170 | 171 | 172 | testimony of 173 | review of 174 | review of the book 175 | 176 | 177 | 公元 178 | 公元前 179 | BCE 180 | CE 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | : 189 | , 190 | ; 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | act 210 | acts 211 | 212 | 213 | appendix 214 | appendices 215 | 216 | 217 | article 218 | articles 219 | 220 | 221 | canon 222 | canons 223 | 224 | 225 | location 226 | locations 227 | 228 | 229 | equation 230 | equations 231 | 232 | 233 | rule 234 | rules 235 | 236 | 237 | scene 238 | scenes 239 | 240 | 241 | table 242 | tables 243 | 244 | 245 | 246 | 247 | 248 | 249 | title 250 | titles 251 | 252 | 253 | 254 | 255 | 图表 256 | 257 | 258 | 259 | 注脚 260 | 作品 261 | 262 | 263 | volume 264 | volumes 265 | 266 | 267 | page 268 | pages 269 | 270 | 271 | printing 272 | printings 273 | 274 | 275 | 276 | chap. 277 | chaps. 278 | 279 | 280 | cit. 281 | cits. 282 | 283 | 284 | 总页数 285 | 段落 286 | 部分 287 | 288 | 289 | supplement 290 | supplements 291 | 292 | 另见 293 | 294 | 295 | 296 | 297 | 298 | app. 299 | apps. 300 | 301 | 302 | art. 303 | arts. 304 | 305 | 306 | loc. 307 | locs. 308 | 309 | 310 | eq. 311 | eqs. 312 | 313 | 314 | r. 315 | rr. 316 | 317 | 318 | sc. 319 | scs. 320 | 321 | 322 | tbl. 323 | tbls. 324 | 325 | 326 | 327 | 328 | 329 | 330 | tit. 331 | tits. 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | op. 342 | 343 | 344 | vol. 345 | vols. 346 | 347 | 348 | p. 349 | pp. 350 | 351 | 352 | print. 353 | prints. 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | supp. 363 | supps. 364 | 365 | 另见 366 | 367 | 368 | 369 | 370 | 371 | 372 | ¶¶ 373 | 374 | 375 | chapter 376 | chapters 377 | 378 | 379 | citation 380 | citations 381 | 382 | 383 | 384 | § 385 | §§ 386 | 387 | 388 | 389 | 390 | ed. 391 | eds. 392 | 393 | 394 | chair 395 | chairs 396 | 397 | 398 | compiler 399 | compilers 400 | 401 | 402 | contributor 403 | contributors 404 | 405 | 406 | curator 407 | curators 408 | 409 | 410 | executive producer 411 | executive producers 412 | 413 | 414 | guest 415 | guests 416 | 417 | 418 | host 419 | hosts 420 | 421 | 422 | narrator 423 | narrators 424 | 425 | 426 | organizer 427 | organizers 428 | 429 | 430 | performer 431 | performers 432 | 433 | 434 | producer 435 | producers 436 | 437 | 438 | writer 439 | writers 440 | 441 | 442 | series creator 443 | series creators 444 | 445 | 导演 446 | 编辑 447 | 主编 448 | 绘图 449 | 翻译 450 | 编译 451 | 452 | 453 | 454 | comp. 455 | comps. 456 | 457 | 458 | contrib. 459 | contribs. 460 | 461 | 462 | cur. 463 | curs. 464 | 465 | 466 | exec. prod. 467 | exec. prods. 468 | 469 | 470 | narr. 471 | narrs. 472 | 473 | 474 | org. 475 | orgs. 476 | 477 | 478 | perf. 479 | perfs. 480 | 481 | 482 | prod. 483 | prods. 484 | 485 | 486 | writ. 487 | writs. 488 | 489 | 490 | cre. 491 | cres. 492 | 493 | 导演 494 | 495 | 主编 496 | 497 | 498 | 编译 499 | 500 | 501 | edited by 502 | chaired by 503 | compiled by 504 | with 505 | curated by 506 | executive produced by 507 | with guest 508 | hosted by 509 | narrated by 510 | organized by 511 | performed by 512 | produced by 513 | written by 514 | created by 515 | 516 | 指导 517 | 编辑 518 | 主编 519 | 绘图 520 | 采访 521 | 受函 522 | 校订 523 | ed. by 524 | 翻译 525 | 编译 526 | 527 | 528 | comp. by 529 | w. 530 | cur. by 531 | exec. prod. by 532 | w. guest 533 | hosted by 534 | narr. by 535 | org. by 536 | perf. by 537 | prod. by 538 | writ. by 539 | cre. by 540 | 541 | 542 | 主编 543 | 544 | 545 | 编译 546 | 547 | 548 | 549 | 一月 550 | 二月 551 | 三月 552 | 四月 553 | 五月 554 | 六月 555 | 七月 556 | 八月 557 | 九月 558 | 十月 559 | 十一月 560 | 十二月 561 | 562 | 563 | 1月 564 | 2月 565 | 3月 566 | 4月 567 | 5月 568 | 6月 569 | 7月 570 | 8月 571 | 9月 572 | 10月 573 | 11月 574 | 12月 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | -------------------------------------------------------------------------------- /utils/citext/typst.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "citext" 3 | version = "0.2.0" 4 | compiler = "0.13.0" 5 | entrypoint = "lib.typ" 6 | authors = ["Shuenhoy"] 7 | license = "MIT" 8 | description = "Use citation.js for CSL-M and citep" 9 | 10 | repository = "https://github.com/Shuenhoy/citext" 11 | 12 | keywords = ["javascript", "citation"] 13 | -------------------------------------------------------------------------------- /utils/datetime-display.typ: -------------------------------------------------------------------------------- 1 | // 显示中文日期 2 | #let datetime-display(date) = { 3 | date.display("[year] 年 [month] 月 [day] 日") 4 | } 5 | 6 | // 显示英文日期 7 | #let datetime-en-display(date) = { 8 | date.display("[month repr:short] [day], [year]") 9 | } 10 | -------------------------------------------------------------------------------- /utils/fakebold.typ: -------------------------------------------------------------------------------- 1 | // Orignal source: https://github.com/csimide/cuti 2 | 3 | #let fakebold(base-weight: none, s, ..params) = { 4 | set text(weight: base-weight) if base-weight != none 5 | set text(..params) if params != () 6 | context { 7 | set text(stroke: 0.02857 * 4 / 3 * text.size + text.fill) 8 | s 9 | } 10 | } 11 | 12 | #let regex-fakebold(reg-exp: ".", base-weight: none, s, ..params) = { 13 | show regex(reg-exp): it => { 14 | fakebold(base-weight: base-weight, it, ..params) 15 | } 16 | s 17 | } 18 | 19 | #let show-fakebold(reg-exp: ".", base-weight: none, s, ..params) = { 20 | show text.where(weight: "bold").or(strong): it => { 21 | regex-fakebold(reg-exp: reg-exp, base-weight: base-weight, it, ..params) 22 | } 23 | s 24 | } 25 | 26 | #let cn-fakebold(s, ..params) = { 27 | regex-fakebold(reg-exp: "[\p{script=Han}!-・〇-〰—]+", base-weight: "regular", s, ..params) 28 | } 29 | 30 | #let show-cn-fakebold(s, ..params) = { 31 | show-fakebold(reg-exp: "[\p{script=Han}!-・〇-〰—]+", base-weight: "regular", s, ..params) 32 | } 33 | -------------------------------------------------------------------------------- /utils/fonts.typ: -------------------------------------------------------------------------------- 1 | #let 字号 = ( 2 | 初号: 42pt, 3 | 小初: 36pt, 4 | 一号: 26pt, 5 | 小一: 24pt, 6 | 二号: 22pt, 7 | 小二: 18pt, 8 | 三号: 16pt, 9 | 小三: 15pt, 10 | 四号: 14pt, 11 | 中四: 13pt, 12 | 小四: 12pt, 13 | 五号: 10.5pt, 14 | 小五: 9pt, 15 | 六号: 7.5pt, 16 | 小六: 6.5pt, 17 | 七号: 5.5pt, 18 | 小七: 5pt, 19 | ) 20 | 21 | #let 字体 = ( 22 | 宋体: ( 23 | ( 24 | name: "Times New Roman", 25 | covers: "latin-in-cjk", 26 | ), 27 | "SimSun", 28 | ), 29 | 黑体: ( 30 | ( 31 | name: "Arial", 32 | covers: "latin-in-cjk", 33 | ), 34 | "SimHei", 35 | ), 36 | // 楷体 37 | 楷体: ( 38 | ( 39 | name: "Times New Roman", 40 | covers: "latin-in-cjk", 41 | ), 42 | "KaiTi", 43 | ), 44 | // 仿宋 45 | 仿宋: ( 46 | ( 47 | name: "Times New Roman", 48 | covers: "latin-in-cjk", 49 | ), 50 | "FangSong", 51 | ), 52 | 等宽: ( 53 | "Courier New", 54 | "Menlo", 55 | "IBM Plex Mono", 56 | "Source Han Sans HW SC", 57 | "Source Han Sans HW", 58 | "Noto Sans Mono CJK SC", 59 | "SimHei", 60 | "Heiti SC", 61 | "STHeiti", 62 | ), 63 | ) 64 | 65 | #let songti(s) = { 66 | set text(font: 字体.宋体) 67 | s 68 | } 69 | 70 | #let heiti(s) = { 71 | set text(font: 字体.黑体) 72 | s 73 | } 74 | 75 | #let kaiti(s) = { 76 | set text(font: 字体.楷体) 77 | s 78 | } 79 | 80 | #let fangsong(s) = { 81 | set text(font: 字体.仿宋) 82 | s 83 | } 84 | -------------------------------------------------------------------------------- /utils/header.typ: -------------------------------------------------------------------------------- 1 | #import "./fonts.typ": 字号, 字体 2 | 3 | #let header( 4 | stroke: 0.5pt, 5 | spacing: 0.5em, 6 | font: 字体.宋体, 7 | size: 字号.小五, 8 | left: none, 9 | right: none, 10 | center: none, 11 | ) = { 12 | context { 13 | if query().filter(el => el.location().page() == here().page()) == () { 14 | set text(font: font, size: size) 15 | stack( 16 | spacing: spacing, 17 | grid( 18 | columns: ( 19 | 1fr, 20 | if center == none { 21 | 0.01fr 22 | } else { 23 | 1fr 24 | }, 25 | 1fr, 26 | ), 27 | align: (alignment.left, alignment.center, alignment.right), 28 | left, center, right, 29 | ), 30 | line(length: 100%, stroke: stroke), 31 | ) 32 | } 33 | } 34 | } 35 | 36 | #let footer( 37 | left: none, 38 | right: none, 39 | center: none, 40 | ) = context { 41 | if query().filter(el => el.location().page() == here().page()) == () { 42 | let fleft(numbering) = { 43 | if type(left) == function { 44 | left(numbering) 45 | } else { 46 | left 47 | } 48 | } 49 | let fcenter(numbering) = { 50 | if type(center) == function { 51 | center(numbering) 52 | } else { 53 | center 54 | } 55 | } 56 | let fright(numbering) = { 57 | if type(right) == function { 58 | right(numbering) 59 | } else { 60 | right 61 | } 62 | } 63 | context [ 64 | #set text(字号.小五) 65 | #let page-numbering = page.numbering 66 | #if page-numbering == none { 67 | page-numbering = "1" 68 | } 69 | #let numbering = counter(page).display(page-numbering) 70 | #grid( 71 | columns: (1fr, 1fr, 1fr), 72 | align: (alignment.left, alignment.center, alignment.right), 73 | fleft(numbering), fcenter(numbering), fright(numbering), 74 | ) 75 | ] 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /utils/near-chapter.typ: -------------------------------------------------------------------------------- 1 | #let near-chapter = context { 2 | let headings_after = query(selector(heading.where(level: 1)).after(here())) 3 | let headings_before = query(selector(heading.where(level: 1)).before(here())) 4 | 5 | 6 | if headings_after.len() == 0 { 7 | return 8 | } 9 | 10 | let heading = headings_after.first() 11 | if heading.location().page() > here().page() { 12 | if headings_before.len() == 0 { 13 | return 14 | } 15 | headings_before.last().body 16 | } else { 17 | heading.body 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /utils/part.typ: -------------------------------------------------------------------------------- 1 | #import "./fonts.typ": 字号, 字体 2 | #import "./twoside.typ": * 3 | #let part = figure.with( 4 | kind: "part", 5 | // same as heading 6 | numbering: "第一部分", 7 | // this cannot use auto to translate this automatically as headings can, auto also means something different for figures 8 | supplement: "Part", 9 | // empty caption required to be included in outline 10 | caption: [], 11 | ) 12 | 13 | #let part-refs = state("part-refs", ()) 14 | 15 | #let show-part-ref(s) = { 16 | show ref: it => { 17 | if it.element != none { 18 | // Citing a document element like a figure, not a bib key 19 | // So don't update refs 20 | it 21 | return 22 | } 23 | part-refs.update(old => { 24 | if it.target not in old { 25 | old.push(it.target) 26 | } 27 | old 28 | }) 29 | 30 | //I think the following is how the reference index should be obtained correctly. 31 | 32 | let get_ref_id(loc) = { 33 | //str(part-refs.at(loc).len()) 34 | str(part-refs.at(loc).position(x => (x == it.target)) + 1) 35 | } 36 | 37 | 38 | context { 39 | "[" + get_ref_id(here()) + "]" 40 | } 41 | } 42 | s 43 | } 44 | 45 | #let show-part(s, enable-ref: true) = { 46 | show: x => if enable-ref { show-part-ref(x) } else { x } 47 | 48 | // emulate element function by creating show rule 49 | show figure.where(kind: "part"): it => { 50 | twoside-pagebreak 51 | counter(heading).update(0) 52 | if it.numbering != none { 53 | [ 54 | #v(0.1fr) 55 | #set align(center) 56 | #set text(font: 字体.黑体, size: 48pt) 57 | #strong(it.counter.display(it.numbering)) 58 | 59 | #set text(font: 字体.仿宋, size: 字号.小初) 60 | #strong(it.body) 61 | #v(0.2fr) 62 | ] 63 | } 64 | 65 | twoside-emptypage 66 | counter(page).update(0) 67 | } 68 | s 69 | } 70 | 71 | #let show-outline-with-part(s) = { 72 | show outline.entry: it => { 73 | if it.element.func() == figure { 74 | // we're configuring chapter printing here, effectively recreating the default show impl with slight tweaks 75 | let res = link( 76 | it.element.location(), 77 | // we must recreate part of the show rule from above once again 78 | if it.element.numbering != none { 79 | numbering(it.element.numbering, ..it.element.counter.at(it.element.location())) 80 | } 81 | + [ ] 82 | + it.element.body, 83 | ) 84 | set par(first-line-indent: 0em) 85 | 86 | text(size: 字号.三号, weight: "bold", res) 87 | } else { 88 | it 89 | } 90 | } 91 | s 92 | } 93 | 94 | #let part-bib = { 95 | //https://github.com/typst/typst/issues/1097 96 | 97 | let ref-counter = counter("part-refs") 98 | ref-counter.update(1) 99 | show regex("^\[(\d+)\]\s"): it => [ 100 | [#context ref-counter.display()] 101 | ] 102 | context { 103 | for target in part-refs.at(here()) { 104 | block(cite(target, form: "full")) 105 | ref-counter.step() 106 | } 107 | } 108 | } 109 | 110 | #let part-and-headings = figure.where(kind: "part", outlined: true).or(heading.where(outlined: true)) 111 | -------------------------------------------------------------------------------- /utils/structure.typ: -------------------------------------------------------------------------------- 1 | #let frontmatter(s) = { 2 | set page(numbering: "I") 3 | counter(page).update(1) 4 | s 5 | } 6 | 7 | #let mainmatter(s) = { 8 | set page(numbering: "1") 9 | set par(spacing: 1.3em) 10 | counter(page).update(1) 11 | s 12 | } 13 | -------------------------------------------------------------------------------- /utils/supplement.typ: -------------------------------------------------------------------------------- 1 | #let show-set-supplement(s) = { 2 | show heading.where(level: 1): set heading(supplement: [章]) 3 | show heading.where(level: 2): set heading(supplement: [节]) 4 | show heading.where(level: 3): set heading(supplement: [小节]) 5 | show heading.where(level: 4): set heading(supplement: [小小节]) 6 | s 7 | } 8 | -------------------------------------------------------------------------------- /utils/twoside.typ: -------------------------------------------------------------------------------- 1 | #import "../utils/header.typ": footer 2 | 3 | #let twoside-pagebreak = metadata() 4 | #let twoside-emptypage = metadata() 5 | #let twoside-numbering-footer = metadata() 6 | 7 | 8 | #let show-twoside-pagebreak(s, twoside: true) = { 9 | show metadata.where(value: ): pagebreak( 10 | weak: true, 11 | to: if twoside { 12 | "odd" 13 | }, 14 | ) 15 | 16 | show metadata.where(value: ): [ 17 | #if twoside { 18 | [ #pagebreak()#[#v(100%)] ] 19 | } 20 | ] 21 | 22 | show metadata.where(value: ): [ 23 | #if twoside { 24 | footer( 25 | left: numbering => if calc.even(here().page()) { 26 | numbering 27 | }, 28 | right: numbering => if not calc.even(here().page()) { 29 | numbering 30 | }, 31 | ) 32 | } else { 33 | footer(center: numbering => numbering) 34 | } 35 | ] 36 | s 37 | } 38 | --------------------------------------------------------------------------------