├── .gitignore ├── LICENSE ├── README.md ├── examples ├── example.typ ├── homework.typ ├── output │ ├── example-1.png │ ├── example-2.png │ ├── example-3.png │ ├── example.pdf │ ├── homework-1.png │ ├── homework-2.png │ ├── homework-3.png │ └── homework.pdf ├── ref.bib ├── sample.svg └── simplepaper.typ └── simplepaper.typ /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 1bitbool 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 | ## 模版简介 2 | 3 | SimplePaper 是 [Typst](https://github.com/typst/typst) 的模版,用于编写简单的论文/报告/作业。 4 | 5 | ## 使用说明 6 | 7 | ### 如何使用 8 | 9 | 下载 [simplepaper.typ](https://github.com/1bitbool/SimplePaper/blob/main/simplepaper.typ) 到本地,可以参考仓库中的示例 [论文示例](https://github.com/1bitbool/SimplePaper/blob/main/examples/example.typ) [作业示例](https://github.com/1bitbool/SimplePaper/blob/main/examples/homework.typ) 进行编写即可。 10 | 11 | ### 字体 12 | 13 | 使用前请先确认已经安装了模板所需字体! 14 | 15 | 当前模板的中文字体使用了 5 款方正字体:[方正黑体](https://www.foundertype.com/index.php/FontInfo/index/id/131)、[方正书宋](https://www.foundertype.com/index.php/FontInfo/index/id/151)、[方正楷体](https://www.foundertype.com/index.php/FontInfo/index/id/137)、[方正仿宋](https://www.foundertype.com/index.php/FontInfo/index/id/128)、[方正小标宋](https://www.foundertype.com/index.php/FontInfo/index/id/164),你需要到[方正官网](https://www.foundertype.com/)安装这些字体。 16 | 17 | 模板英文字体使用了 "Georgia", "Times New Roman", "Courier New", "Menlo", 通常系统已经内置了这些字体,如发现异常可及时安装对应字体。 18 | 19 | 如果你想更换其他字体,你需要在模版中直接修改字体。 20 | 21 | ### 使用环境 22 | 23 | 由于网页版 Typst 没有内置这些中文字体,你需要手动上传字体以编译,这会导致每次打开模板的时候都会全量下载一遍字体。因此**不推荐在网页版上使用该模板**。 24 | 25 | ## 模版效果 26 | 27 | ### 论文效果 28 | 29 | ![example-1](examples/output/example-1.png) 30 | 31 | ![example-2](examples/output/example-2.png) 32 | 33 | ![example-3](examples/output/example-3.png) 34 | 35 | ### 作业效果 36 | 37 | ![homework-1](examples/output/homework-1.png) 38 | 39 | ![homework-2](examples/output/homework-2.png) 40 | 41 | ![homework-3](examples/output/homework-3.png) -------------------------------------------------------------------------------- /examples/example.typ: -------------------------------------------------------------------------------- 1 | #import "simplepaper.typ": * 2 | 3 | #show: project.with( 4 | title: "SimplePaper 模版使用说明", 5 | authors: ( 6 | ( 7 | name: "张三", 8 | organization: [Typst Group], 9 | email: "zs@typst.app" 10 | ), 11 | ( 12 | name: "李四", 13 | organization: [Rust Group], 14 | email: "ls@typst.app" 15 | ), 16 | ), 17 | abstract: "本文详细描述了 SimplePaper 模版的使用方法。", 18 | keywords: ( 19 | "Typst", 20 | "模板", 21 | "使用说明", 22 | ), 23 | ) 24 | 25 | = 模版简介 26 | 27 | SimplePaper#cite() 是 Typst 的模版,用于生成简单的论文。 28 | 29 | = 使用说明 30 | 31 | 使用前确保已经安装了对应的字体!详细字体列表参考 #link("https://github.com/1bitbool/SimplePaper/tree/main")[README] 或模板文件。 32 | 33 | = 使用示例 34 | 35 | == 特殊标记 36 | 37 | 你可以 Typst 的语法对文本进行特殊标记,模板设定了几种语法的样式:*突出*、_强调_、引用@example。 38 | 39 | 40 | == 图片 41 | 42 | 图片标题默认设置了方正楷体,效果如@img 如果你想要使用其他字体,你可以自行修改模版。 43 | 44 | #figure(image("sample.svg"), 45 | caption: [ 46 | 示例图片 47 | ], 48 | ) 49 | 50 | 图片后的文字。 51 | 52 | == 表格 53 | 54 | #figure( 55 | table( 56 | columns: (auto, 1fr, 1fr, 1fr, 1fr, 1fr), 57 | inset: 10pt, 58 | align: horizon, 59 | [], [周一], [周二],[周三],[周四],[周五], 60 | "早上", "编译原理", "操作系统", "计算机网络", "操作系统", "计算机网络", 61 | "下午", "数据挖掘", "计算机网络", "操作系统", "计算机网络", "分布式系统" 62 | ), 63 | caption: "示例表格" 64 | ) 65 | 66 | 表格后的文字。 67 | 68 | == 代码 69 | 70 | 我们为代码添加了如下简单的样式。 71 | 72 | ```c 73 | #include 74 | int main() 75 | { 76 | // printf() 中字符串需要引号 77 | printf("Hello, World!"); 78 | return 0; 79 | } 80 | ``` 81 | 82 | 代码后的文字。 83 | 84 | == 列表 85 | 86 | 下面是有序列表的示例: 87 | 88 | + 第一项 89 | + 第二项 90 | + 第三项 91 | 92 | 列表后的文字。 93 | 94 | 下面是无序列表的示例: 95 | 96 | - 第一项 97 | - 第二项 98 | - 第三项 99 | 100 | 无序列表后的文字。 101 | 102 | 下面是等式的示例: 103 | 104 | $ a^2 + b^2 = c^2 $ 105 | 106 | 等式之后的文字。 107 | 108 | 下面是项目列表的示例: 109 | 110 | / 名称: 水果 111 | / 介绍: 水果一词指的是主要供应人类生食用途之植物果实;而主要供应人类熟食用途之植物果实,如苦瓜、南瓜等,则会被归类为蔬菜。生产水果的木本植物称为果树。大多数水果是甜的,含有大量的果糖,有些也带酸味或其他味道,很多还含有挥发性芳香物质。 112 | / 食用: 在中式饮食中,水果通常是在饭后单独食用。另外,水果也可以打成果汁、煮成果酱、凉拌或放入沙拉中、或是做成水果蛋糕等糕点。 113 | 114 | 项目列表之后的文字。 115 | 116 | #bibliography("ref.bib") -------------------------------------------------------------------------------- /examples/homework.typ: -------------------------------------------------------------------------------- 1 | #import "simplepaper.typ": * 2 | 3 | #show: project.with( 4 | title: "编译原理作业", 5 | authors: ( 6 | ( 7 | name: "张三", 8 | ), 9 | ), 10 | ) 11 | 12 | #problem[ 13 | 下列文法是一个无符号二进制浮点数的文法。试根据该文法,编写一个语法制导定义,描述由 S 生成的二进制数(浮点数)的数值计算。 14 | $ 15 | S -> L . L \ 16 | L -> L B | B \ 17 | B -> 0 | 1 18 | $ 19 | ] 20 | 21 | #solution[ 22 | 设L具有继承属性side和综合属性m 23 | 24 | L.side表示小数点的左边或右边(1表示左边0表示右边),L.m二进制串的长度即幂次。 25 | 26 | #table( 27 | columns: (auto, 1fr), 28 | inset: 10pt, 29 | align: center, 30 | [产生式], [语义规则], 31 | [$S -> L_1 . L_2$], [ 32 | $ 33 | L_1 . "side" = 1 \ 34 | L_2 . "side" = 0 \ 35 | S . "val" = L . "val" 36 | $ 37 | ], 38 | [$S -> L$], [ 39 | $ 40 | L . "side" = 1, \ 41 | S . "val" = L . "val" 42 | $ 43 | ], 44 | [$L -> L_1 B$], [ 45 | $ 46 | L_1 . "side" = L . "side" \ 47 | L . m = L_1 . m + 1 \ 48 | L . "val" = L_1 . "side" ? L_1 . "val" * 2 + B . "val" : L_1 . "val" + (B . "val" >> m) 49 | $ 50 | ], 51 | [$L -> B$], [ 52 | $ 53 | L . m = 1 \ 54 | L . "val" = L . "side" ? B . "val" : B . "val" \/ 2 55 | $ 56 | ], 57 | [$B -> 0$], [ 58 | $ 59 | B . "val" = 0 60 | $ 61 | ], 62 | [$B -> 1$], [ 63 | $ 64 | B . "val" = 1 65 | $ 66 | ] 67 | ) 68 | ] 69 | 70 | #problem[ 71 | 设下列文法生成变量的类型说明: 72 | $ 73 | D -> "id" L \ 74 | L -> , "id" L | : T \ 75 | T -> "integer" | "real" 76 | $ 77 | 构造一个翻译模式,把每个标识符的类型存入符号表。 78 | ] 79 | 80 | #solution[ 81 | 设 D, L, T 有综合属性 type。 82 | 83 | addtype(id, type)将标识符 id 及其类型 type 填入符号表中。 84 | 85 | 翻译模式如下: 86 | #table( 87 | columns: (auto, 1fr), 88 | inset: 10pt, 89 | align: center, 90 | [$D -> "id" L$], [${"addtype"("id" . "entry", L . "type")}$], 91 | [$L -> , "id" L_1$], [${"addtype"("id" . "entry", L_1 . "type" ; L . "type" := L_1 . "type")}$], 92 | [$L -> :T$], [${L . "type" := T . "type"}$], 93 | [$T -> "integer"$], [${T . "type" := "integer"}$], 94 | [$T -> "real"$], [${T . "type" := "real"}$] 95 | ) 96 | 97 | ] 98 | 99 | #problem[ 100 | 文法G的产生式如下: 101 | $ 102 | S -> (L) | a \ 103 | L -> L , S | S 104 | $ 105 | + 试写出一个语法制导定义,它输出配对括号个数; 106 | + 写一个翻译方案,打印每个a的嵌套深度。如((a),a),打印2,1。(思考:如果要求出a出现的次数,怎么办?) 107 | ] 108 | 109 | #solution[ 110 | 1. 111 | #table( 112 | columns: (auto, 1fr), 113 | inset: 10pt, 114 | align: center, 115 | [产生式], [语法规则], 116 | [$S -> (L)$], [$S.h := L.h + 1$], 117 | [$S -> a$], [$S.h := 0$], 118 | [$L -> L_1 , S$], [$L.h := L_1.h + S.h$], 119 | [$L->S$], [$L.h := S.h$], 120 | [$S' -> S$], [$"print"(S.h)$] 121 | ) 122 | 123 | 2. 124 | $ 125 | S'->{S.d:=0;}S \ 126 | S -> ({L.d := S.d + 1} L) \ 127 | S -> a {"print"(S.d)} \ 128 | L -> {L_1.d := L.d} L_1 , {S.d := L.d}S \ 129 | L -> {S.d := L.d} S 130 | $ 131 | ] -------------------------------------------------------------------------------- /examples/output/example-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jinhao-huang/SimplePaper/2e72c65032ef8ab19bc24fdd0cdb182f8cec27a7/examples/output/example-1.png -------------------------------------------------------------------------------- /examples/output/example-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jinhao-huang/SimplePaper/2e72c65032ef8ab19bc24fdd0cdb182f8cec27a7/examples/output/example-2.png -------------------------------------------------------------------------------- /examples/output/example-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jinhao-huang/SimplePaper/2e72c65032ef8ab19bc24fdd0cdb182f8cec27a7/examples/output/example-3.png -------------------------------------------------------------------------------- /examples/output/example.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jinhao-huang/SimplePaper/2e72c65032ef8ab19bc24fdd0cdb182f8cec27a7/examples/output/example.pdf -------------------------------------------------------------------------------- /examples/output/homework-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jinhao-huang/SimplePaper/2e72c65032ef8ab19bc24fdd0cdb182f8cec27a7/examples/output/homework-1.png -------------------------------------------------------------------------------- /examples/output/homework-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jinhao-huang/SimplePaper/2e72c65032ef8ab19bc24fdd0cdb182f8cec27a7/examples/output/homework-2.png -------------------------------------------------------------------------------- /examples/output/homework-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jinhao-huang/SimplePaper/2e72c65032ef8ab19bc24fdd0cdb182f8cec27a7/examples/output/homework-3.png -------------------------------------------------------------------------------- /examples/output/homework.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jinhao-huang/SimplePaper/2e72c65032ef8ab19bc24fdd0cdb182f8cec27a7/examples/output/homework.pdf -------------------------------------------------------------------------------- /examples/ref.bib: -------------------------------------------------------------------------------- 1 | @software{SimplePaper, 2 | title = {SimplePaper}, 3 | url = {https://github.com/1bitbool/SimplePaper}, 4 | author = {1bitbool}, 5 | } -------------------------------------------------------------------------------- /examples/sample.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 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 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 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | -------------------------------------------------------------------------------- /examples/simplepaper.typ: -------------------------------------------------------------------------------- 1 | ../simplepaper.typ -------------------------------------------------------------------------------- /simplepaper.typ: -------------------------------------------------------------------------------- 1 | #let project( 2 | title: "", 3 | authors: (), 4 | abstract: none, 5 | keywords: (), 6 | body 7 | ) = { 8 | let zh_shusong = ("FZShuSong-Z01", "FZShuSong-Z01S") 9 | let zh_xiaobiansong = ("FZXiaoBiaoSong-B05", "FZXiaoBiaoSong-B05S") 10 | let zh_kai = ("FZKai-Z03", "FZKai-Z03S") 11 | let zh_hei = ("FZHei-B01", "FZHei-B01S") 12 | let zh_fangsong = ("FZFangSong-Z02", "FZFangSong-Z02S") 13 | let en_sans_serif = "Georgia" 14 | let en_serif = "Times New Roman" 15 | let en_typewriter = "Courier New" 16 | let en_code = "Menlo" 17 | // Moidfy the following to change the font. 18 | let title-font = (en_serif, ..zh_hei) 19 | let author-font = (en_typewriter, ..zh_fangsong) 20 | let body-font = (en_serif, ..zh_shusong) 21 | let heading-font = (en_serif, ..zh_xiaobiansong) 22 | let caption-font = (en_serif, ..zh_kai) 23 | let header-font = (en_serif, ..zh_kai) 24 | let strong-font = (en_serif, ..zh_hei) 25 | let emph-font = (en_serif, ..zh_kai) 26 | let raw-font = (en_code, ..zh_hei) 27 | 28 | set document(author: authors.map(author => author.name), title: title) 29 | set page(numbering: "1", number-align: center, header: align(left)[ 30 | #set text(font: header-font) 31 | #title 32 | ]) 33 | set heading(numbering: "1.1") 34 | set text(font: body-font, lang: "zh", region: "cn") 35 | set bibliography(style: "gb-7714-2015-numeric") 36 | 37 | show heading: it => box(width: 100%)[ 38 | #v(0.50em) 39 | #set text(font: heading-font) 40 | #if it.numbering != none { counter(heading).display() } 41 | #h(0.75em) 42 | #it.body 43 | ] 44 | 45 | show heading.where( 46 | level: 1 47 | ): it => box(width: 100%)[ 48 | #v(0.5em) 49 | #set align(center) 50 | #set heading(numbering: "一") 51 | #it 52 | #v(0.75em) 53 | ] 54 | 55 | // Title 56 | align(center)[ 57 | #block(text(font: title-font, weight: "bold", 1.75em, title)) 58 | #v(0.5em) 59 | ] 60 | 61 | // Display the authors list. 62 | for i in range(calc.ceil(authors.len() / 3)) { 63 | let end = calc.min((i + 1) * 3, authors.len()) 64 | let is-last = authors.len() == end 65 | let slice = authors.slice(i * 3, end) 66 | grid( 67 | columns: slice.len() * (1fr,), 68 | gutter: 12pt, 69 | ..slice.map(author => align(center, { 70 | text(12pt, author.name, font: author-font) 71 | if "organization" in author [ 72 | \ #text(author.organization, font: author-font) 73 | ] 74 | if "email" in author [ 75 | \ #text(link("mailto:" + author.email), font: author-font) 76 | ] 77 | })) 78 | ) 79 | 80 | if not is-last { 81 | v(16pt, weak: true) 82 | } 83 | } 84 | v(2em, weak: true) 85 | 86 | // Main body 87 | set enum(indent: 2em) 88 | set list(indent: 2em) 89 | set figure(gap: 0.8cm) 90 | 91 | // 定义空白段,解决首段缩进问题 92 | let blank_par = par()[#text()[#v(0em, weak: true)];#text()[#h(0em)]] 93 | 94 | show figure: it => [ 95 | #v(12pt) 96 | #set text(font: caption-font) 97 | #it 98 | #blank_par 99 | #v(12pt) 100 | ] 101 | 102 | show image: it => [ 103 | #it 104 | #blank_par 105 | ] 106 | 107 | show list: it => [ 108 | #it 109 | #blank_par 110 | ] 111 | 112 | show enum: it => [ 113 | #it 114 | #blank_par 115 | ] 116 | 117 | show terms: it => [ 118 | #it 119 | #blank_par 120 | ] 121 | 122 | show math.equation.where(block: true): it => [ 123 | #it 124 | #blank_par 125 | ] 126 | 127 | show table: it => [ 128 | #set text(font: body-font) 129 | #it 130 | #blank_par 131 | ] 132 | 133 | show strong: set text(font: strong-font) 134 | show emph: set text(font: emph-font) 135 | show ref: set text(red) 136 | show raw.where(block: true): block.with( 137 | width: 100%, 138 | fill: luma(240), 139 | inset: 10pt, 140 | ) 141 | 142 | show raw.where(block: true): it => [ 143 | #it 144 | #blank_par 145 | ] 146 | 147 | show raw: set text(font: raw-font) 148 | show link: underline 149 | show link: set text(blue) 150 | set par(first-line-indent: 2em, justify: true) 151 | 152 | if abstract != none [ 153 | #v(2pt) 154 | #h(2em) *摘要:* #abstract 155 | 156 | #if keywords!= () [ 157 | *关键字:* #keywords.join(";") 158 | ] 159 | #v(2pt) 160 | ] 161 | 162 | body 163 | } 164 | 165 | #let problem-counter = counter("problem") 166 | #let problem(body) = block( 167 | fill: rgb(241, 241, 255), 168 | inset: 8pt, 169 | radius: 2pt, 170 | width: 100%, 171 | )[ 172 | #problem-counter.step() 173 | *题目 #context problem-counter.display().* 174 | #h(0.75em) 175 | #body 176 | ] 177 | 178 | #let solution(body) = { 179 | set enum(numbering: "(1)") 180 | block( 181 | inset: 8pt, 182 | width: 100% 183 | )[*解答.* #h(0.75em) #body] 184 | } 185 | --------------------------------------------------------------------------------