|
| 1 | +<h1 align="center"> |
| 2 | +Scripst |
| 3 | +</h1> |
| 4 | + |
| 5 | +**Scripst** is a template package based on **Typst**, offering a set of simple and efficient document templates suitable for everyday documents, assignments, notes, papers, and other scenarios. |
| 6 | + |
| 7 | +<div align="center"> |
| 8 | + |
| 9 | +[](https://github.com/An-314/scripst/releases/tag/v1.1.0) |
| 10 | +[](https://github.com/An-314/scripst/blob/main/LICENSE) |
| 11 | +[](https://an-314.github.io/scripst) |
| 12 | +[](https://github.com/An-314/scripst/releases/latest) |
| 13 | + |
| 14 | +[简体中文](https://github.com/An-314/scripst/blob/main/README_zh-CN.md) | English |
| 15 | + |
| 16 | +</div> |
| 17 | + |
| 18 | +## 📑 Contents |
| 19 | + |
| 20 | +- [📑 Contents](#-contents) |
| 21 | +- [🚀 Features](#-features) |
| 22 | +- [📦 Installation](#-installation) |
| 23 | + - [Install Typst](#install-typst) |
| 24 | + - [Download Scripst Template](#download-scripst-template) |
| 25 | + - [Method 1: Download Manually](#method-1-download-manually) |
| 26 | + - [Method 2: Use Typst Local Package Management](#method-2-use-typst-local-package-management) |
| 27 | +- [📄 Using Scripst](#-using-scripst) |
| 28 | + - [Import Scripst Template](#import-scripst-template) |
| 29 | + - [Create `article` Document](#create-article-document) |
| 30 | +- [🔧 Template Parameters](#-template-parameters) |
| 31 | +- [🆕 `countblock` Module](#-countblock-module) |
| 32 | + - [Creating and Registering a `countblock`](#creating-and-registering-a-countblock) |
| 33 | + - [Using `countblock`](#using-countblock) |
| 34 | + - [Encapsulating the `countblock` Module](#encapsulating-the-countblock-module) |
| 35 | +- [✨ Template Examples and Explanations](#-template-examples-and-explanations) |
| 36 | + - [Article](#article) |
| 37 | + - [Book](#book) |
| 38 | + - [Report](#report) |
| 39 | +- [📜 Contributing](#-contributing) |
| 40 | +- [📌 Fonts](#-fonts) |
| 41 | +- [🔗 Dependencies](#-dependencies) |
| 42 | +- [📝 License](#-license) |
| 43 | +- [🎯 TODO](#-todo) |
| 44 | +* * * |
| 45 | + |
| 46 | +## 🚀 Features |
| 47 | + |
| 48 | +* High Extensibility: Modular design, easy to extend the templates. |
| 49 | +* Multilingual Design: Localization for different languages. |
| 50 | +* Supports module `countblock`, which allows custom names and colors, includes a built-in counter, and can be referenced anywhere in the document. It can be used for theorems, problems, notes, etc. For more details, see [🆕 `countblock` Module](#-countblock-module). |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +## 📦 Installation |
| 57 | + |
| 58 | +### Install Typst |
| 59 | + |
| 60 | +Make sure Typst is installed. You can install it using the following commands: |
| 61 | + |
| 62 | +```bash |
| 63 | +sudo apt install typst # Debian/Ubuntu |
| 64 | +sudo pacman -S typst # Arch Linux |
| 65 | +winget install --id Typst.Typst # Windows |
| 66 | +brew install typst # macOS |
| 67 | +``` |
| 68 | + |
| 69 | +Or refer to the [Typst official documentation](https://github.com/typst/typst) for more information. |
| 70 | + |
| 71 | +### Download Scripst Template |
| 72 | + |
| 73 | +Should you need to use the template locally, or should you need to make adjustments to the template, you can download the Scripst template manually. |
| 74 | + |
| 75 | +#### Method 1: Download Manually |
| 76 | + |
| 77 | +1. Visit the [Scripst GitHub repository](https://github.com/An-314/scripst) |
| 78 | +2. Click the `<> Code` button |
| 79 | +3. Choose `Download ZIP` |
| 80 | +4. After extraction, place the template files into your project directory. |
| 81 | + |
| 82 | +**Suggested directory structure** |
| 83 | +```plaintext |
| 84 | +project/ |
| 85 | +├── src/ |
| 86 | +│ ├── main.typ |
| 87 | +│ ├── components.typ |
| 88 | +├── pic/ |
| 89 | +│ ├── image.jpg |
| 90 | +├── main.typ |
| 91 | +├── chap1.typ |
| 92 | +├── chap2.typ |
| 93 | +``` |
| 94 | + |
| 95 | +If the template is stored in the `src/` directory, import it like this: |
| 96 | + |
| 97 | +```typst |
| 98 | +#import "src/main.typ": * |
| 99 | +``` |
| 100 | + |
| 101 | +#### Method 2: Use Typst Local Package Management |
| 102 | + |
| 103 | +You can manually download Scripst and store it in: |
| 104 | + |
| 105 | +``` |
| 106 | +~/.local/share/typst/packages/preview/scripst/1.1.0 # Linux |
| 107 | +%APPDATA%\typst\packages\preview\scripst\1.1.0 # Windows |
| 108 | +~/Library/Application Support/typst/packages/preview/scripst/1.1.0 # macOS |
| 109 | +``` |
| 110 | + |
| 111 | +or using these commands: |
| 112 | + |
| 113 | +```bash |
| 114 | +cd {data-dir}/typst/packages/preview/scripst |
| 115 | +git clone https://github.com/An-314/scripst.git 1.1.0 |
| 116 | +``` |
| 117 | + |
| 118 | +Where `data-dir` refers to Typst's data directory, such as `~/.local/share/typst` for Linux, `%APPDATA%\typst` for Windows, and `~/Library/Application Support/typst` for macOS. |
| 119 | + |
| 120 | +Then import directly in your Typst file: |
| 121 | +```typst |
| 122 | +#import "@preview/scripst:1.1.0": * |
| 123 | +``` |
| 124 | +Now you can use the Scripst template. |
| 125 | + |
| 126 | +Use `typst init` to quickly create a project: |
| 127 | + |
| 128 | +```bash |
| 129 | +typst init @preview/scripst:1.1.0 project_name |
| 130 | +``` |
| 131 | + |
| 132 | +* * * |
| 133 | + |
| 134 | +## 📄 Using Scripst |
| 135 | + |
| 136 | +### Import Scripst Template |
| 137 | + |
| 138 | +Import the template at the beginning of your Typst file: |
| 139 | +```typst |
| 140 | +#import "@preview/scripst:1.1.0": * |
| 141 | +``` |
| 142 | + |
| 143 | +### Create `article` Document |
| 144 | + |
| 145 | +```typst |
| 146 | +#show: scripst.with( |
| 147 | + title: [How to Use Scripst], |
| 148 | + info: [This is an article template], |
| 149 | + author: ("Author1", "Author2", "Author3"), |
| 150 | + time: datetime.today().display(), |
| 151 | + abstract: [Abstract content], |
| 152 | + keywords: ("Keyword1", "Keyword2", "Keyword3"), |
| 153 | + contents: true, |
| 154 | + content-depth: 2, |
| 155 | + matheq-depth: 2, |
| 156 | + lang: "en", |
| 157 | +) |
| 158 | +``` |
| 159 | + |
| 160 | +* * * |
| 161 | + |
| 162 | +## 🔧 Template Parameters |
| 163 | + |
| 164 | +| Parameter | Type | Default Value | Description | |
| 165 | +| --- | --- | --- | --- | |
| 166 | +| `template` | `str` | `"article"` | Choose template (`"article"`, `"book"`, `"report"`) | |
| 167 | +| `title` | `content`, `str`, `none` | `""` | Document title | |
| 168 | +| `info` | `content`, `str`, `none` | `""` | Document subtitle or supplementary information | |
| 169 | +| `author` | `array` | `()` | List of authors | |
| 170 | +| `time` | `content`, `str`, `none` | `""` | Document date | |
| 171 | +| `abstract` | `content`, `str`, `none` | `none` | Document abstract | |
| 172 | +| `keywords` | `array` | `()` | Keywords | |
| 173 | +| `preface` | `content`, `str`, `none` | `none` | Preface | |
| 174 | +| `font-size` | `length` | `11pt` | Font size | |
| 175 | +| `contents` | `bool` | `false` | Whether to generate a table of contents | |
| 176 | +| `content-depth` | `int` | `2` | Table of contents depth | |
| 177 | +| `matheq-depth` | `int` | `2` | Math equation numbering depth | |
| 178 | +| `lang` | `str` | `"zh"` | Language (`"zh"`, `"en"`, `"fr"`, etc.) | |
| 179 | + |
| 180 | +* * * |
| 181 | + |
| 182 | +## 🆕 `countblock` Module |
| 183 | + |
| 184 | +The `countblock` module is a customizable module where you can set the name and color, and it comes with a built-in counter that can be referenced anywhere in the document. It can be used to create blocks for theorems, definitions, problems, notes, and more. |
| 185 | + |
| 186 | +Below is an example of a `countblock` module: |
| 187 | + |
| 188 | + |
| 189 | + |
| 190 | +### Creating and Registering a `countblock` |
| 191 | + |
| 192 | +Scripst provides several default `countblock` modules, which already have preset names, colors, and registered counters: |
| 193 | + |
| 194 | +```typst |
| 195 | +#let cb = ( |
| 196 | + "thm": ("Theorem", color.blue), |
| 197 | + "def": ("Definition", color.green), |
| 198 | + "prob": ("Problem", color.purple), |
| 199 | + "prop": ("Proposition", color.purple-grey), |
| 200 | + "ex": ("Example", color.green-blue), |
| 201 | + "note": ("Note", color.grey), |
| 202 | + "cau": ("⚠️", color.red), |
| 203 | +) |
| 204 | +``` |
| 205 | + |
| 206 | +You can also define your own `countblock` modules: |
| 207 | + |
| 208 | +```typst |
| 209 | +#let cb = add-countblock("test", "This is a test", teal) // Define a "test" countblock |
| 210 | +#show: register-countblock.with("test") // Register the countblock |
| 211 | +``` |
| 212 | + |
| 213 | +This allows you to use the `test` module in your document. |
| 214 | + |
| 215 | +### Using `countblock` |
| 216 | + |
| 217 | +You can use the `countblock` module in the document as follows: |
| 218 | + |
| 219 | +```typst |
| 220 | +#countblock( |
| 221 | + name, |
| 222 | + subname, |
| 223 | + count: true, |
| 224 | + cb: cb, |
| 225 | + lab: none, |
| 226 | +)[...] |
| 227 | +``` |
| 228 | + |
| 229 | +Parameter descriptions: |
| 230 | + |
| 231 | +| Parameter | Type | Default Value | Description | |
| 232 | +| --- | --- | --- | --- | |
| 233 | +| `name` | `str` | `""` | Name of the module | |
| 234 | +| `subname` | `str` | `""` | The name of the specific block | |
| 235 | +| `count` | `bool` | `true` | Whether to count or not | |
| 236 | +| `cb` | `dict` | `cb` | The `countblock` dictionary | |
| 237 | +| `lab` | `str`, `none` | `none` | Label | |
| 238 | + |
| 239 | +For example: |
| 240 | + |
| 241 | +```typst |
| 242 | +#countblock("thm", subname: [_Fermat's Last Theorem_], lab: "fermat", cb)[ |
| 243 | +
|
| 244 | + No three $a, b, c \in \mathbb{N}^+$ can satisfy the equation |
| 245 | + $ |
| 246 | + a^n + b^n = c^n |
| 247 | + $ |
| 248 | + for any integer value of $n$ greater than 2. |
| 249 | +] |
| 250 | +#proof[Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet.] |
| 251 | +Fermat did not provide a public proof for @fermat. |
| 252 | +``` |
| 253 | + |
| 254 | +This will create a theorem block and allow it to be referenced in the document. |
| 255 | + |
| 256 | +### Encapsulating the `countblock` Module |
| 257 | + |
| 258 | +You can encapsulate the `countblock` module into a function for repeated use in the document: |
| 259 | + |
| 260 | +```typst |
| 261 | +#let test = countblock.with("test", cb) |
| 262 | +``` |
| 263 | + |
| 264 | +This allows you to use the `test` function in the document: |
| 265 | + |
| 266 | +```typst |
| 267 | +#test[...] |
| 268 | +``` |
| 269 | + |
| 270 | +Additionally, the default `countblock` modules provided by Scripst have already been encapsulated, allowing you to use them directly as `#theorem`, `#definition`, `#problem`, `#proposition`, `#example`, `#note`, and `#caution`. |
| 271 | + |
| 272 | + |
| 273 | +* * * |
| 274 | + |
| 275 | +## ✨ Template Examples and Explanations |
| 276 | + |
| 277 | +### Article |
| 278 | + |
| 279 | +  |
| 280 | +[Aritcle Demo](./docs/locale/builds/article-en.pdf) |
| 281 | + |
| 282 | +### Book |
| 283 | + |
| 284 | +  |
| 285 | +[Book Demo](./docs/builds/book.pdf) *(Only in Simplified Chinese)* |
| 286 | + |
| 287 | + |
| 288 | +### Report |
| 289 | + |
| 290 | +  |
| 291 | +[Report Demo](./docs/builds/report.pdf) *(Only in Simplified Chinese)* |
| 292 | + |
| 293 | +## 📜 Contributing |
| 294 | + |
| 295 | +Feel free to submit issues or pull requests! If you have any improvement suggestions, join the discussion. |
| 296 | + |
| 297 | +* **GitHub Repository**: [Scripst](https://github.com/An-314/scripst) |
| 298 | +* **Issue Feedback**: Submit an issue to discuss |
| 299 | + |
| 300 | +## 📌 Fonts |
| 301 | + |
| 302 | +This project uses the following fonts by default: |
| 303 | + |
| 304 | +* Primary fonts: [CMU Serif](https://en.wikipedia.org/wiki/Computer_Modern), [Consolas](https://en.wikipedia.org/wiki/Consolas) |
| 305 | +* Alternative fonts: [Linux Libertine](https://en.wikipedia.org/wiki/Linux_Libertine) |
| 306 | +* Chinese fonts such as SimSun, SimHei, KaiTi, etc. |
| 307 | + |
| 308 | +If using these default fonts, please make sure they are correctly installed. Otherwise, replace them if needed in `./src/configs.typ`. |
| 309 | + |
| 310 | +## 🔗 Dependencies |
| 311 | + |
| 312 | +For certain content, Scripst uses the following Typst packages: |
| 313 | + |
| 314 | +* [tablem](https://typst.app/universe/package/tablem) |
| 315 | +* [physica](https://typst.app/universe/package/physica) |
| 316 | + |
| 317 | +## 📝 License |
| 318 | + |
| 319 | +This project is licensed under the MIT License. |
| 320 | + |
| 321 | +## 🎯 TODO |
| 322 | + |
| 323 | +* [ ] Add `beamer` template |
| 324 | +* [ ] Add more configuration options |
0 commit comments