├── LICENSE ├── README.md ├── content ├── chapter1.typ └── chapter2.typ ├── figures ├── content1.jpg ├── content2.jpg ├── cover-image.png ├── cover.jpg └── typst.png ├── fonts ├── NotoSansCJKsc-Bold.ttf ├── NotoSansCJKsc-BoldItalic.ttf ├── NotoSansCJKsc-Italic.ttf └── NotoSansCJKsc-Regular.ttf ├── main.pdf ├── main.typ ├── refs.bib ├── resource.typ └── template.typ /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 模板介绍 2 | 3 | SimpleNote 是为撰写简易课程笔记而设计的 Typst 模板,修改自 [jsk-lecnotes](https://github.com/jskherman/jsk-lecnotes),有问题欢迎提交 Issue。 4 | 5 | ## 使用方法 6 | 7 | > [!NOTE] 8 | > 9 | > 此模板需要使用 Typst 0.11.0 及以上版本进行编译。 10 | 11 | 页面右边点击:**Clone or download -> Download Zip**,将模板文件下载到本地并解压 12 | 13 | 模板文件夹内主要包含以下七部分: 14 | - main.typ 主文件 15 | - refs.bib 参考文献 16 | - template.typ 文档格式控制,包括一些基础的设置、函数 17 | - resource.typ 存放模板 svg 资源 18 | - /content 正文文件夹,存放正文章节 19 | - /fonts 字体文件夹 20 | - /figures 图片文件夹 21 | 22 | 使用模板首先需配置 `main.typ`,设置标题、描述、作者等信息,如需要进一步更改文档格式,请修改 `template.typ`。撰写文档请修改 `/content` 文件夹内的文件。 23 | 24 | 本地编辑建议使用 VSCode 编辑器,并推荐安装 [Tinymist](https://marketplace.visualstudio.com/items?itemName=mgt19937.typst-preview) 与 [Typst Preview](https://marketplace.visualstudio.com/items?itemName=mgt19937.typst-preview) 插件。 25 | 26 | ## 模板预览 27 | 28 | | [封面](https://github.com/a-kkiri/SimpleNote/blob/main/figures/cover.jpg) | [正文1](https://github.com/a-kkiri/SimpleNote/blob/main/figures/content1.jpg) | [正文2](https://github.com/a-kkiri/SimpleNote/blob/main/figures/content2.jpg) | 29 | |:---:|:---:|:---:| 30 | | ![cover](https://github.com/a-kkiri/SimpleNote/blob/main/figures/cover.jpg?raw=true) | ![content1](https://github.com/a-kkiri/SimpleNote/blob/main/figures/content1.jpg?raw=true) | ![content2](https://github.com/a-kkiri/SimpleNote/blob/main/figures/content2.jpg?raw=true) | 31 | 32 | > [!CAUTION] 33 | > 34 | >如果要将文档拆分为多个文件进行组织,需要将 `#import "../template.typ": *` 添加到每个文件的顶部,以使某些函数(例如 `blockquote()`)正常工作。 35 | > 36 | > 例如,假设你在项目根目录下有一个 `./content/chapter.typ` 文件和一个 `./template.typ` 文件,那么你需要在 `chapter.typ` 文件顶部添加 `#import "../template.typ": *`。 37 | 38 | ## 更改记录 39 | 40 | 2025-4-4(PR from MicroBlueee & vectorpikachu) 41 | - 修复 template.typ 没有应用 bibstyle 42 | - 更新 typst 包 43 | - showybox: 2.0.1 ——> 2.0.4 44 | - codelst: 2.0.1 ——> 2.0.2 45 | - ctheorems: 1.1.2 ——> 1.1.3 46 | 47 | 2024-5-13 48 | - 修复页眉章节标题显示问题 49 | - 修复公式编号记数问题 50 | - 调整定理环境标题显示位置 51 | 52 | 2024-4-30 53 | - 更新 typst 包 54 | - codelst: 2.0.0 ——> 2.0.1 55 | - ctheorems: 1.1.0 ——> 1.1.2 56 | - 移除 mitex 包 57 | - 替换默认封面图片 58 | - 更改封面日期显示格式 59 | - 优化页眉章节标题显示逻辑 60 | - 将变量名中的下横线替换为连字号 61 | - 默认使用 codelst 包显示行间代码块 -------------------------------------------------------------------------------- /content/chapter1.typ: -------------------------------------------------------------------------------- 1 | #import "../template.typ": * 2 | 3 | = 模板说明 4 | 5 | #link("https://github.com/a-kkiri/SimpleNote")[SimpleNote] #cite() 修改自 #link("https://github.com/jskherman/jsk-lecnotes")[jsk-lecnotes],是一个简单的 Typst 模板。本模板主要适用于编写课程笔记,默认页边距为2.5cm,默认使用的中文字体为 Noto Sans CJK SC,英文字体为 Linux Libertine,字号为12pt(小四),你可以根据自己的需求进行更改,如需使用伪粗体或伪斜体,可以使用外部包 #link("https://typst.app/universe/package/cuti")[cuti]。封面图片由 #link("https://tabbied.com/")[Tabbied] 生成。 6 | 7 | 默认模板文件由主要以下六部分组成: 8 | 9 | #list( 10 | [main.typ 主文件], 11 | [template.typ 文档格式控制,包括一些基础的设置、函数], 12 | [refs.bib 参考文献], 13 | [content 正文文件夹,存放正文章节], 14 | [fonts 字体文件夹], 15 | [figures 图片文件夹] 16 | )\ #v(-16pt) 17 | 18 | 使用模板首先需配置 main.typ,设置标题、描述、作者等信息。如需要进一步更改文档格式,请修改 template.typ。 -------------------------------------------------------------------------------- /content/chapter2.typ: -------------------------------------------------------------------------------- 1 | #import "../template.typ": * 2 | 3 | = 使用示例 4 | 5 | == 特殊记号 6 | 7 | 你可以 Typst 的语法对文本进行#highlight[特殊标记],我们为如下标记设定了样式: 8 | 9 | #enum( 10 | [*突出*], 11 | [_强调_], 12 | [引用 @figure], 13 | [脚注 #footnote("脚注例")], 14 | ) 15 | 16 | == 代码 17 | 18 | 行内代码使用例 `println!("Hello, typst!")`,下面是代码块使用例: 19 | 20 | #figure( 21 | ```rust 22 | fn main() { 23 | println!("Hello, typst!"); 24 | } 25 | ```, 26 | 27 | caption: [代码块插入例] 28 | ) 29 | 30 | == 图片
31 | 32 | #figure(caption: [图片插入例])[#image("../figures/typst.png")] 33 | 34 | == 表格 35 | 36 | #figure(caption: [表格插入例])[ 37 | #table( 38 | columns: (1fr, 1fr, 1fr), 39 | [表头1] , [表头2] , [表头3], 40 | [单元格1], [单元格2], [单元格3], 41 | [单元格1], [单元格2], [单元格3], 42 | [单元格1], [单元格2], [单元格3], 43 | )] 44 | 45 | == 引用块 46 | 47 | #blockquote[ 48 | 引用块例 49 | 50 | #blockquote[ 51 | 二级引用块 52 | ] 53 | ] 54 | 55 | == 公式 56 | 57 | 行内公式,例如 $integral_123^123a+b+c$ $a^2 + b^2 = c^2$。行内公式使用 `$$` 包裹,公式和两端的 `$$` 之间没有空格$$。 58 | 59 | 行间公式,例如:$ integral.triple_(Omega)\(frac(diff P, diff x) + frac(diff Q, diff y) + frac(diff R, diff z)\)d v = integral.surf_(Sigma)P d y d z + Q d z d x + R d x d y $ @eq 是高斯公式。行间公式使用 `$$` 环境包裹,公式和两端的 `$$` 之间至少有一个空格。 60 | 61 | 以上仅为一些简单的公式示例,更多的公式使用方法可以查看 #link("https://typst.app/docs/reference/math/")[typst/docs/math] 62 | 63 | 另外,如果需要插入 LaTeX 公式可以使用外部包 #link("https://typst.app/universe/package/mitex")[mitex]。 64 | 65 | 66 | == 定理环境 67 | 68 | 69 | #definition("定义")[#lorem(30)] 70 | 71 | #example("示例")[#lorem(30)] 72 | 73 | #tip("提示")[#lorem(30)] 74 | 75 | #attention("注意")[#lorem(30)] 76 | 77 | #quote("引用")[#lorem(30)] 78 | 79 | #theorem("定理")[#lorem(30)] 80 | 81 | #proposition("命题")[#lorem(30)] 82 | 83 | #sectionline -------------------------------------------------------------------------------- /figures/content1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-kkiri/SimpleNote/d0f387e0499088f09166907622b2cbeba88e9811/figures/content1.jpg -------------------------------------------------------------------------------- /figures/content2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-kkiri/SimpleNote/d0f387e0499088f09166907622b2cbeba88e9811/figures/content2.jpg -------------------------------------------------------------------------------- /figures/cover-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-kkiri/SimpleNote/d0f387e0499088f09166907622b2cbeba88e9811/figures/cover-image.png -------------------------------------------------------------------------------- /figures/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-kkiri/SimpleNote/d0f387e0499088f09166907622b2cbeba88e9811/figures/cover.jpg -------------------------------------------------------------------------------- /figures/typst.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-kkiri/SimpleNote/d0f387e0499088f09166907622b2cbeba88e9811/figures/typst.png -------------------------------------------------------------------------------- /fonts/NotoSansCJKsc-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-kkiri/SimpleNote/d0f387e0499088f09166907622b2cbeba88e9811/fonts/NotoSansCJKsc-Bold.ttf -------------------------------------------------------------------------------- /fonts/NotoSansCJKsc-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-kkiri/SimpleNote/d0f387e0499088f09166907622b2cbeba88e9811/fonts/NotoSansCJKsc-BoldItalic.ttf -------------------------------------------------------------------------------- /fonts/NotoSansCJKsc-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-kkiri/SimpleNote/d0f387e0499088f09166907622b2cbeba88e9811/fonts/NotoSansCJKsc-Italic.ttf -------------------------------------------------------------------------------- /fonts/NotoSansCJKsc-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-kkiri/SimpleNote/d0f387e0499088f09166907622b2cbeba88e9811/fonts/NotoSansCJKsc-Regular.ttf -------------------------------------------------------------------------------- /main.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/a-kkiri/SimpleNote/d0f387e0499088f09166907622b2cbeba88e9811/main.pdf -------------------------------------------------------------------------------- /main.typ: -------------------------------------------------------------------------------- 1 | #import "template.typ": * 2 | 3 | #show: template.with( 4 | // 笔记标题 5 | title: [SimpleNote], 6 | // 在页眉展示的短标题(选填) 7 | short-title: "SimepleNote", 8 | // 笔记描述(选填) 9 | description: [ 10 | 此模板修改自 #link("https://github.com/jskherman/jsk-lecnotes")[jsk-lecnotes] \ Winter 2023 11 | ], 12 | // 笔记创建日期(选填) 13 | date: datetime(year: 2023, month: 12, day: 19), 14 | // 作者信息(除 name 外,其他参数选填) 15 | authors: ( 16 | ( 17 | name: "Akkiri", 18 | github: "https://github.com/a-kkiri", 19 | homepage: "https://github.com/a-kkiri", 20 | affiliations: "1,2", 21 | ), 22 | ), 23 | 24 | // 所属组织列表,每一项包括一个 id 和 name。这些将显示在作者下方。 25 | affiliations: ( 26 | (id: "1", name: "Example University"), 27 | (id: "2", name: "Example Inc."), 28 | ), 29 | 30 | // 参考书目文件路径及引用样式 31 | bibliography-file: "refs.bib", 32 | bibstyle: "gb-7714-2015-numeric", 33 | 34 | // 页面尺寸,同时会影响页边距。 35 | paper-size: "a4", 36 | 37 | // 中英文文本和代码的字体 38 | fonts: ( 39 | ( 40 | en-font: "Linux Libertine", 41 | zh-font: "Noto Sans CJK SC", 42 | code-font: "DejaVu Sans Mono", 43 | ) 44 | ), 45 | 46 | // 主题色 47 | accent: orange, 48 | // 封面背景图片(选填图片路径或 none) 49 | cover-image: "./figures/cover-image.png", 50 | // 正文背景颜色(选填 HEX 颜色或 none) 51 | background-color: "#FAF9DE" 52 | ) 53 | 54 | #include "content/chapter1.typ" 55 | #include "content/chapter2.typ" -------------------------------------------------------------------------------- /refs.bib: -------------------------------------------------------------------------------- 1 | @template{SimpleNote, 2 | title = {SimpleNote}, 3 | url = {https://github.com/a-kkiri/SimpleNote}, 4 | author = {akkiri}, 5 | date = {2023-12-19}, 6 | year = {2023}, 7 | month = {12}, 8 | day = {19}, 9 | } 10 | 11 | @article{netwok2020, 12 | title={At-scale impact of the {Net Wok}: A culinarically holistic investigation of distributed dumplings}, 13 | author={Astley, Rick and Morris, Linda}, 14 | journal={Armenian Journal of Proceedings}, 15 | volume={61}, 16 | pages={192--219}, 17 | year=2020, 18 | publisher={Automatic Publishing Inc.} 19 | } 20 | -------------------------------------------------------------------------------- /resource.typ: -------------------------------------------------------------------------------- 1 | // Github Logo 2 | #let githubSvg = ``````.text 3 | 4 | #let defSvg = ``` 5 | 6 | ```.text 7 | 8 | #let egSvg = ``` 9 | 10 | ```.text 11 | 12 | #let tipSvg = ``````.text 13 | 14 | #let cautionSvg = ``````.text 15 | 16 | #let quoteSvg = ``````.text 17 | 18 | #let thmSvg = ``` 19 | 20 | ```.text 21 | 22 | #let propSvg = ``` 23 | 24 | ```.text 25 | 26 | -------------------------------------------------------------------------------- /template.typ: -------------------------------------------------------------------------------- 1 | #import "@preview/showybox:2.0.4": showybox 2 | #import "@preview/codelst:2.0.2": sourcecode 3 | #import "@preview/ctheorems:1.1.3": * 4 | #import "resource.typ": * 5 | 6 | /* 7 | 本模板修改自 jsk-lecnotes 8 | + 添加中文环境 9 | + 修改封面布局 10 | + 添加必要字体 11 | */ 12 | 13 | #let template( 14 | // 笔记标题 15 | title: "Lecture Notes Title", 16 | short-title: none, 17 | description: none, 18 | date: none, 19 | 20 | authors: ( 21 | 22 | ), 23 | 24 | affiliations: ( 25 | 26 | ), 27 | 28 | bibliography-file: none, 29 | bibstyle: "gb-7714-2015-numeric", 30 | 31 | paper-size: "a4", 32 | 33 | fonts: ( 34 | ( 35 | en-font: "Linux Libertine", 36 | zh-font: "Noto Sans CJK SC", 37 | code-font: "DejaVu Sans Mono", 38 | ) 39 | ), 40 | 41 | accent: "#000000", 42 | cover-image: none, 43 | background-color: none, 44 | 45 | body 46 | ) = { 47 | 48 | let accent-color = rgb(accent) 49 | 50 | // 使用 ctheorems 包 51 | show: thmrules 52 | 53 | // 设置正文和代码的字体 54 | set text(font: (fonts.en-font, fonts.zh-font), size: 12pt, lang: "zh", region: "cn") 55 | show raw: set text(font: fonts.code-font, 10pt) 56 | 57 | // 设置中文粗体,斜体 58 | show strong: set text(fill: accent-color, font: (fonts.en-font, fonts.zh-font)) 59 | show emph: set text(font: (fonts.en-font, fonts.zh-font)) 60 | 61 | // 设置文档元数据 62 | set document(title: title, author: authors.map(author => author.name)) 63 | 64 | // 将链接设置蓝色并加下划线,并且对于作者列表禁用此设置。 65 | show link: it => { 66 | let author-names = () 67 | for author in authors { 68 | author-names.push(author.name) 69 | } 70 | 71 | if it.body.has("text") and it.body.text in author-names { 72 | it 73 | } else { 74 | underline(stroke: (dash: "densely-dotted"), text(fill: blue, it)) 75 | } 76 | } 77 | 78 | // 文本高亮 79 | // set highlight(fill: accent-color.lighten(50%)) 80 | 81 | // 计数器 82 | let chaptercounter = counter("chapter") 83 | 84 | // 配置页面 85 | set page( 86 | paper: paper-size, 87 | numbering: "1 / 1", 88 | number-align: center, 89 | // 页边距 90 | margin: (x:1.6cm, y:2.3cm), 91 | 92 | // 封面图片和背景图片 93 | background: context { 94 | if here().page() == 1 and cover-image != none { 95 | block(width:100%, height: 100%)[#image(cover-image, width: 100%, height: 100%)] 96 | } else if background-color != none{ 97 | block(width:100%, height:100%, fill: rgb(background-color)) 98 | } 99 | }, 100 | 101 | header: context { 102 | if here().page() == 1 { 103 | return 104 | } 105 | 106 | let elems = query(heading.where(level: 1).after(here())) 107 | 108 | let chapter-title = "" 109 | 110 | if (elems == () or elems.first().location().page() != here().page()) { 111 | let elems = query(heading.where(level: 1).before(here())) 112 | chapter-title = elems.last().body 113 | } else { 114 | chapter-title = elems.first().body 115 | } 116 | 117 | let head-title = text()[ 118 | #if short-title != none { 119 | short-title 120 | } else { 121 | title 122 | } 123 | ] 124 | 125 | if calc.even(here().page()) == true { 126 | emph(chapter-title) + h(1fr) + emph(head-title) 127 | } else { 128 | emph(head-title) + h(1fr) + emph(chapter-title) 129 | } 130 | 131 | v(-8pt) 132 | align(center)[#line(length: 105%, stroke: (thickness: 1pt, dash: "solid"))] 133 | 134 | }, 135 | 136 | footer: context { 137 | if here().page() == 1 {return} 138 | [ 139 | #if calc.even(here().page()) == true { 140 | align(left)[#counter(page).display("1 / 1",both: true,)] 141 | }else{ 142 | align(right)[#counter(page).display("1 / 1",both: true,)] 143 | } 144 | ] 145 | }) 146 | 147 | // 配置列表 148 | set list(tight: true, indent: 2em) 149 | show list: it => [ 150 | #set text(top-edge: "ascender") 151 | #it 152 | ] 153 | 154 | set enum(tight: true, indent: 2em) 155 | show enum: it => [ 156 | #set text(top-edge: "ascender") 157 | #it 158 | ] 159 | 160 | // 配置标题 161 | set heading(numbering: "1.1.1.1.1.") 162 | 163 | show heading: it => box(width: 100%)[ 164 | #if it.numbering != none { counter(heading).display() } 165 | #it.body 166 | 167 | #if it.level == 1 and it.numbering != none{ 168 | chaptercounter.step() 169 | counter(math.equation).update(0) 170 | } 171 | ] 172 | 173 | // 配置一级标题 174 | show heading.where( 175 | level: 1 176 | ): it => box(width: 100%)[ 177 | #set align(left) 178 | #set text(fill: accent-color) 179 | #set heading(numbering: "章节 1. ") 180 | #it 181 | #v(-12pt) 182 | #line(length:100%, stroke: gray) 183 | ] 184 | 185 | // 配置公式的编号和间距 186 | set math.equation(numbering: (..nums) => ( 187 | context { 188 | numbering("(1.1)", chaptercounter.at(here()).first(), ..nums) 189 | } 190 | )) 191 | 192 | 193 | show math.equation: eq => { 194 | set block(spacing: 0.65em) 195 | eq 196 | } 197 | 198 | // 配置图像和图像编号 199 | set figure( 200 | numbering: (..nums) => context { 201 | numbering("1.1", chaptercounter.at(here()).first(), ..nums) 202 | }) 203 | 204 | 205 | // 配置表格 206 | set table( 207 | fill: (_, row) => if row == 0 {accent-color.lighten(40%)} else {accent-color.lighten(80%)}, 208 | stroke: 1pt + white 209 | ) 210 | 211 | // set figure(placement: auto) 212 | show figure.where( 213 | kind: table 214 | ): set figure.caption(position: bottom) 215 | show figure.where( 216 | kind: raw 217 | ): it => { 218 | set block(width: 100%, breakable: true) 219 | it 220 | } 221 | 222 | // 配置行内代码块 223 | show raw.where( 224 | block: false, 225 | ): it => box(fill: luma(245), inset: (x: 2pt), outset: (y: 3pt), radius: 1pt)[#it] 226 | 227 | show raw.where(block: true): it => sourcecode[#it] 228 | 229 | 230 | //------------------------------------------------------------------ 231 | box(width: 100%, height: 40%)[ 232 | // 显示论文的标题和描述。 233 | #align(right+bottom)[ 234 | #text(36pt, weight: "bold")[#title] 235 | #parbreak() 236 | #if description != none { 237 | text(size: 16pt, style: "italic")[#description] 238 | } 239 | ] 240 | ] 241 | 242 | box(width: 100%, height: 50%)[ 243 | #align(right+top)[ 244 | #if authors.len() > 0 { 245 | box(inset: (y: 10pt), { 246 | authors.map(author => { 247 | text(16pt, weight: "semibold")[ 248 | #if "homepage" in author { 249 | [#link(author.homepage)[#author.name]] 250 | } else { author.name }] 251 | if "affiliations" in author { 252 | super(author.affiliations) 253 | } 254 | if "github" in author { 255 | link(author.github, box(height: 1.1em, baseline: 13.5%)[#image.decode(githubSvg)]) 256 | } 257 | }).join(", ", last: { 258 | if authors.len() > 2 { 259 | ", and" 260 | } else { 261 | " and" 262 | } 263 | }) 264 | }) 265 | } 266 | #v(-2pt, weak: true) 267 | #if affiliations.len() > 0 { 268 | box(inset: (bottom: 10pt), { 269 | affiliations.map(affiliation => { 270 | text(12pt)[ 271 | #super(affiliation.id)#h(1pt)#affiliation.name 272 | ] 273 | }).join(", ") 274 | }) 275 | } 276 | ] 277 | ] 278 | 279 | box(width: 100%)[ 280 | #if date != none { 281 | text(size: 12pt, "最初写作于:") 282 | text( 283 | size: 12pt, 284 | fill: accent-color, 285 | weight: "semibold", 286 | date.display("[year]年[month]月[day]日") 287 | ) 288 | parbreak() 289 | text(size: 12pt, "最后更新于:") 290 | text( 291 | size: 12pt, 292 | fill: accent-color, 293 | weight: "semibold", 294 | datetime.today().display("[year]年[month]月[day]日") 295 | ) 296 | } else { 297 | text(size: 11pt)[最后更新于:#h(5pt)] + text( 298 | size: 11pt, 299 | fill: accen-color, 300 | weight: "semibold", 301 | datetime.today().display("[month repr:long] [day padding:zero], [year repr:full]") 302 | ) 303 | } 304 | ] 305 | 306 | pagebreak() 307 | 308 | // 显示笔记的目录 309 | outline(indent: auto) 310 | 311 | 312 | v(24pt, weak: true) 313 | 314 | // 将段落设置为两端对齐,并设置换行。 315 | set par(justify: true, linebreaks: "optimized", first-line-indent:2em, leading: 0.8em) 316 | 317 | pagebreak() 318 | 319 | // 显示笔记的内容 320 | body 321 | 322 | // 显示参考文献 323 | if bibliography-file != none { 324 | pagebreak() 325 | show bibliography: set text(10.5pt) 326 | bibliography(bibliography-file, title: "参考文献", style: bibstyle) // apply bibstyle here. 327 | } 328 | } 329 | 330 | 331 | // 函数=========================================================== 332 | 333 | // 配置块引用 334 | #let blockquote(cite: none, body) = [ 335 | #set text(size: 10.5pt) 336 | #pad(left: 0.5em)[ 337 | #block( 338 | breakable: true, 339 | width: 100%, 340 | fill: gray.lighten(95%), 341 | radius: (left: 4pt, right: 4pt), 342 | stroke: (left: 4pt + eastern.darken(20%), rest: 1pt + silver), 343 | inset: 1em 344 | )[#body] 345 | ] 346 | ] 347 | 348 | // 水平标尺 349 | #let horizontalrule = [#v(0.5em) #line(start: (20%,0%), end: (80%,0%)) #v(0.5em)] 350 | 351 | // 另外的水平标尺 352 | #let sectionline = align(center)[#v(0.5em) * \* #sym.space.quad \* #sym.space.quad \* * #v(0.5em)] 353 | 354 | // ==== 使用 showybox 和 ctheorems 包创建盒子 ==== 355 | // 356 | // | 环境 | 强调色 | 357 | // |---------|-----------------------| 358 | // | 定义 | orange | 359 | // | 示例 | blue | 360 | // | 提示 | olive | 361 | // | 注意 | red | 362 | // | 引用 | eastern | 363 | // | 定理 | yellow | 364 | // | 命题 | navy | 365 | 366 | #let boxnumbering = "1.1.1.1.1.1" 367 | #let boxcounting = "heading" 368 | 369 | #let notebox(name, number, body, ntype, nicon, ncolor) = { 370 | showybox( 371 | title-style: ( 372 | weight: 1000, 373 | color: ncolor.darken(20%), 374 | sep-thickness: 0pt, 375 | ), 376 | frame: ( 377 | border-color: ncolor.darken(20%), 378 | title-color: ncolor.lighten(80%), 379 | body-color: ncolor.lighten(80%), 380 | thickness: (left: 4pt), 381 | radius: 4pt 382 | ), 383 | title: [#box(height: 0.85em)[#image.decode(nicon)] #name #h(1fr) #ntype #number], 384 | body 385 | ) 386 | } 387 | 388 | #let definition = thmenv( 389 | "definition", 390 | boxcounting, //base counter name 391 | 2, // number of base number levels to use 392 | (name, number, body) => { 393 | notebox(name, number, body, "定义", defSvg, orange) 394 | } 395 | ).with(numbering: boxnumbering) 396 | 397 | #let example = thmenv( 398 | "example", 399 | boxcounting, 400 | 2, 401 | (name, number, body, ..args) => { 402 | notebox(name, number, body, "示例", egSvg, blue) 403 | } 404 | ).with(numbering: boxnumbering) 405 | 406 | #let tip = thmenv( 407 | "tip", 408 | boxcounting, 409 | 2, 410 | (name, number, body) => { 411 | notebox(name, number, body, "提示", tipSvg, olive) 412 | } 413 | ).with(numbering: boxnumbering) 414 | 415 | #let attention = thmenv( 416 | "attention", 417 | boxcounting, 418 | 2, 419 | (name, number, body) => { 420 | notebox(name, number, body, "注意", cautionSvg, red) 421 | } 422 | ).with(numbering: boxnumbering) 423 | 424 | #let quote = thmenv( 425 | "quote", 426 | boxcounting, 427 | 2, 428 | (name, number, body) => { 429 | notebox(name, number, body, "引用", quoteSvg, eastern) 430 | } 431 | ).with(numbering: boxnumbering) 432 | 433 | #let theorem = thmenv( 434 | "theorem", 435 | boxcounting, 436 | 2, 437 | (name, number, body) => { 438 | notebox(name, number, body, "定理", thmSvg, yellow) 439 | } 440 | ).with(numbering: boxnumbering) 441 | 442 | #let proposition = thmenv( 443 | "proposition", 444 | boxcounting, 445 | 2, 446 | (name, number, body) => { 447 | notebox(name, number, body, "命题", propSvg, navy) 448 | } 449 | ).with(numbering: boxnumbering) 450 | --------------------------------------------------------------------------------