-
Notifications
You must be signed in to change notification settings - Fork 558
simple-ecnu-thesis:0.1.0 #2094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JackyLee3362
wants to merge
2
commits into
typst:main
Choose a base branch
from
JackyLee3362:simple-ecnu-thesis-0.1.0
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
simple-ecnu-thesis:0.1.0 #2094
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) [year] [fullname] | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# 一份简单的华东师范大学论文模板 | ||
|
||
项目地址:[JackyLee3362/simple-ecnu-thesis](https://github.com/JackyLee3362/simple-ecnu-thesis) | ||
|
||
 | ||
|
||
## 🔍️ 项目介绍 | ||
|
||
本项目基于 [华东师范大学本科 / 研究生学位论文 Typst 模板](https://github.com/jtchen2k/modern-ecnu-thesis), | ||
进行了以下的 **重构与优化**: | ||
|
||
- 💄 开箱即用,重新设计了界面,更加美观 | ||
- ⚡️ 使用中文变量,易于理解,对无编程经验的小白非常友好 | ||
- 🗃️ 重构了项目结构,可读性更好 | ||
- 💡 扩展性好,易于深度定制 | ||
|
||
本项目非常适合**边写论文边学习** Typst 语法, | ||
并且可以定制自己的样式。 | ||
|
||
## 🙈 快速开始 | ||
|
||
### 本地项目 | ||
|
||
```sh | ||
git clone https://github.com/JackyLee3362/simple-ecnu-thesis | ||
code simple-typst-thesis-template | ||
``` | ||
|
||
在 `vscode` 中搜索插件 `Tinymist Typst` | ||
|
||
, | ||
|
||
|
||
安装并下载后, | ||
在 `vscode` 中打开 `main.typ`, | ||
并点击 `预览`, | ||
如下所示 | ||
|
||
 | ||
|
||
## 🔧 如何配置? | ||
|
||
本地:在项目中选择 `template/用户配置.typ` 文件, | ||
在线:选择 `用户配置.typ` 文件 | ||
|
||
## 🧐 关于字体 | ||
|
||
本项目的字体在 `package/font.typ` 中定义, | ||
建议下载以下字体 | ||
|
||
- 新罗马字体:`Times New Roman`,用于所有英文字体 | ||
- 华文宋体: `Songti SC`,用于标题 | ||
- 方正宋体: `FZShuSong-Z01S`,用于正文 | ||
- 方正楷体`FZKai-Z03S`,用于中文斜体 | ||
- 方正黑体: `FZHei-B01S`,用于中文加粗 | ||
- JetBrains Mono: `JetBrains Mono`,用于代码块 | ||
|
||
## 🗃️ 项目结构 | ||
|
||
```sh | ||
├───assets ... README 文件文件 | ||
├───package ... 项目样式、库等的定义 | ||
├───public ... 缩略图片存放 | ||
├───style ... 子样式文件 | ||
├───template ... 模板 | ||
├───test ... 测试文件 | ||
└─── lib.typ ... 模板入口文件 | ||
``` | ||
|
||
## 为什么会有该项目? | ||
|
||
Typst 作为一款排版工具, | ||
网上的中文教程依然较少, | ||
对于即将毕业的学生来说, | ||
很难花费大量的时间和精力研究其中的语法, | ||
即使存在相关论文模板, | ||
也很难进行自定义的定制。 | ||
|
||
## FAQ | ||
|
||
## 感谢 | ||
|
||
- [The Raindrop-Blue Book (Typst 中文教程)](https://typst-doc-cn.github.io/tutorial/) | ||
- [Typst 中文社区导航](https://typst-doc-cn.github.io/guide/) | ||
- [nju-lug/modern-nju-thesis: 南京大学学位论文 Typst 模板 modern-nju-thesis](https://github.com/nju-lug/modern-nju-thesis) | ||
- [jtchen2k/modern-ecnu-thesis: 华东师范大学本科 / 研究生学位论文 Typst 模板 modern-ecnu-thesis](https://github.com/jtchen2k/modern-ecnu-thesis) | ||
- Typst qq 中文讨论群 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// 第三方库导入 | ||
#import "package/lib.typ": * | ||
// 字体导入 | ||
#import "package/font.typ": * | ||
// 工具导入 | ||
#import "package/util.typ": * | ||
// 样式导入 | ||
#import "package/style.typ": * |
75 changes: 75 additions & 0 deletions
75
packages/preview/simple-ecnu-thesis/0.1.0/package/font.typ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// --------------------- 字号 --------------------- | ||
#let 初号 = 42pt | ||
#let 小初 = 36pt | ||
#let 一号 = 26pt | ||
#let 小一 = 24pt | ||
#let 二号 = 22pt | ||
#let 小二 = 18pt | ||
#let 三号 = 16pt | ||
#let 小三 = 15pt | ||
#let 四号 = 14pt | ||
#let 中四 = 13pt | ||
#let 小四 = 12pt | ||
#let 五号 = 10.5pt | ||
#let 小五 = 9pt | ||
#let 六号 = 7.5pt | ||
#let 小六 = 6.5pt | ||
#let 七号 = 5.5pt | ||
#let 小七 = 5pt | ||
|
||
// --------------------- 具体的字体 --------------------- | ||
// 英文字体 | ||
#let Times-New-Roman = "Times New Roman" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The most common convention for variable names in Typst package is lowercase-kebab-case. It would be nice if you could rename the few variables in this file so that they don't have capital letters. |
||
// 宋体 | ||
#let 方正宋体 = "FZShuSong-Z01S" | ||
#let 华文宋体 = "STSong" | ||
#let 华文宋体-2 = "Songti SC" // Mac 上的华文宋体 | ||
#let 中易宋体 = "SimSun" // Windows 上的宋体 | ||
// 仿宋 | ||
#let 方正仿宋 = "FZFangSong-Z02S" | ||
#let 华文仿宋 = "STFangSong" | ||
#let 华文仿宋-2 = "FangSong SC" | ||
#let 仿宋 = "FangSong" | ||
#let 仿宋-2 = "FangSong_GB2312" | ||
// 中宋 | ||
#let 华文中宋 = "STZhongsong" | ||
// 黑体 | ||
#let 方正黑体 = "FZHei-B01S" | ||
#let 华文黑体 = "STHeiti" | ||
#let 华文黑体-2 = "Heiti SC" | ||
#let 中易黑体 = "SimHei" | ||
#let 微软雅黑 = "Microsoft YaHei" | ||
#let 阿里巴巴普惠体 = "Alibaba PuHuiTi 2.0" | ||
// 楷体 | ||
#let 方正楷体 = "FZKai-Z03S" | ||
#let 华文楷体 = "STKaiti" | ||
#let 华文楷体-2 = "Kaiti SC" | ||
#let 中易楷体 = "SimKai" | ||
#let 楷体 = "Kaiti" | ||
#let 楷体-2 = "Kaiti_GB2312" | ||
// 等宽 | ||
#let JetBrains-Mono = "JetBrains Mono" | ||
#let JetBrains-Mono-NL = "JetBrains Mono NL" | ||
#let Consolas = "Consolas" | ||
#let Inconsolata = "Inconsolata" | ||
#let Courier-New = "Courier New" | ||
|
||
// ---------------------- Fallback 字体 ------------------------ | ||
// 从左到右依次查找,直到找不到 | ||
#let 宋体 = (Times-New-Roman, 方正宋体, 华文宋体, 华文宋体-2, 中易宋体) | ||
#let 仿宋 = (Times-New-Roman, 方正仿宋, 华文仿宋, 华文仿宋-2, 仿宋, 仿宋-2) | ||
#let 中宋 = (Times-New-Roman, 华文中宋, 中易宋体) | ||
#let 黑体 = (Times-New-Roman, 方正黑体, 华文黑体, 华文黑体-2, 中易黑体) | ||
#let 楷体 = (Times-New-Roman, 方正楷体, 华文楷体, 华文楷体-2, 楷体, 楷体-2) | ||
#let 封面字体 = (Times-New-Roman, 华文宋体-2, 方正宋体, 中易宋体) | ||
#let 等宽 = ( | ||
JetBrains-Mono, | ||
JetBrains-Mono-NL, | ||
Consolas, | ||
Inconsolata, | ||
Courier-New, | ||
阿里巴巴普惠体, | ||
微软雅黑, | ||
方正黑体, | ||
华文黑体-2, | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// 实现章节编号的功能 | ||
#import "@preview/numbly:0.1.0": numbly | ||
// 实现根据章节显示页面的功能 | ||
#import "@preview/hydra:0.6.0": hydra | ||
// 实现子图功能 | ||
#import "@preview/subpar:0.2.1" | ||
// 实现伪代码功能 | ||
#import "@preview/lovelace:0.3.0": pseudocode, pseudocode-list | ||
// 修复 bib 等的问题 | ||
#import "@preview/modern-nju-thesis:0.3.4": bilingual-bibliography |
27 changes: 27 additions & 0 deletions
27
packages/preview/simple-ecnu-thesis/0.1.0/package/style.typ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// 导入 | ||
#import "/package/lib.typ": * | ||
#import "/package/font.typ": * | ||
#import "/package/util.typ": * | ||
// // 自定义变量和样式 | ||
// #import "/template/用户设置.typ": * | ||
// 拆分定义,更好理解 | ||
#import "/style/页面样式.typ": * | ||
#import "/style/标题样式.typ": * | ||
#import "/style/内容样式.typ": * | ||
#import "/style/图形样式.typ": * | ||
#import "/style/页眉页脚样式.typ": * | ||
|
||
// 全局样式 | ||
#let global-style(doc) = { | ||
// 设置页面样式 | ||
show: page-style | ||
// 设置标题样式 | ||
show: heading-style.with(sans-serif: 黑体, h-size: 小四, h1-size: 三号, h2-size: 四号) | ||
// 设置内容样式 | ||
show: content-style.with(serif: 宋体, sans-serif: 黑体, raw-font: 等宽, emph-font: 楷体, size: 小四) | ||
// 设置图形样式 | ||
show: figure-style | ||
// 设置中文字符换行修复 | ||
show: cjk-fix | ||
doc | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/preview/simple-ecnu-thesis/0.1.0/package/util.typ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// 双页模式 | ||
#let switch-two-side(to-page) = { | ||
if to-page { | ||
pagebreak(weak: true, to: "odd") | ||
} else { | ||
pagebreak(weak: true) | ||
} | ||
} | ||
|
||
// CJK 换行问题修复 | ||
#let han-or-punct = "[-\p{sc=Hani}。.,、:;!‼?⁇⸺——……⋯⋯~–—·・‧//「」『』“”‘’()《》〈〉【】〖〗〔〕[]{}_﹏●•]" | ||
#let cjk-fix(doc) = { | ||
show regex(han-or-punct + " " + han-or-punct): it => { | ||
let (a, _, b) = it.text.clusters() | ||
a + b | ||
} | ||
doc | ||
} | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 定义全局内容样式 | ||
#let content-style( | ||
doc, | ||
serif: "", | ||
sans-serif: "", | ||
raw-font: "", | ||
emph-font: "", | ||
size: 0pt, | ||
) = { | ||
// 设置地区和语言 | ||
set text(region: "CN", lang: "zh") | ||
// 设置基本字体和字号 | ||
set text(font: serif, size: size) | ||
// 设置段落样式 - 首段缩进 + 段间距 | ||
set par( | ||
justify: true, | ||
// 首段缩进 | ||
first-line-indent: (amount: 2em, all: true), | ||
// 段间距 | ||
spacing: 1.5em, | ||
// 行间距 | ||
leading: 1.5em, | ||
) | ||
// 设置中文粗体样式:建议使用黑体 | ||
show strong: set text(font: sans-serif, weight: "regular") | ||
// 设置中文斜体样式:建议使用楷体 | ||
show emph: set text(font: emph-font) | ||
// 设置代码样式:建议使用等宽字体 | ||
show raw: set text(font: raw-font) | ||
show raw.where(block: true): set par(leading: 1em) | ||
// 设置列表样式 | ||
set enum(indent: 2em, numbering: it => text(baseline: .2em, numbering("1.", it))) | ||
set list(indent: 2em, marker: it => text(baseline: .2em)[•]) | ||
doc | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#import "/package/lib.typ": subpar | ||
|
||
// 定义计数函数 | ||
#let sub-figure-numbering = (super, sub) => numbering("1.1a", counter(heading).get().first(), super, sub) | ||
#let figure-numbering = super => numbering("1.1", counter(heading).get().first(), super) | ||
#let equation-numbering = super => numbering("(1.1)", counter(heading).get().first(), super) | ||
#let algorithm-numbering = super => numbering("1.1", counter(heading).get().first(), super) | ||
#let subpar-grid = subpar.grid.with( | ||
numbering: figure-numbering, | ||
numbering-sub-ref: sub-figure-numbering, | ||
) | ||
|
||
// 定义子图样式 | ||
#let figure-style(doc) = { | ||
// 设置新章节重新计数 | ||
show heading.where(level: 1): it => { | ||
counter(math.equation).update(0) | ||
counter(figure.where(kind: image)).update(0) | ||
counter(figure.where(kind: table)).update(0) | ||
counter(figure.where(kind: raw)).update(0) | ||
counter(figure.where(kind: "algorithm")).update(0) | ||
it | ||
} | ||
// 设置 figure 计数器 | ||
show figure: set figure(numbering: figure-numbering) | ||
// 设置 equation 计数器 | ||
show math.equation: set math.equation(numbering: equation-numbering) | ||
|
||
// 设置 figure/table 表格表头 | ||
show figure.where(kind: table): set figure.caption(position: top) | ||
// 设置 figure/raw 的样式 | ||
show raw.where(block: true): set block(fill: rgb("#f0f0f0"), inset: 1em, radius: .5em, width: 100%) | ||
// 设置 figure 标题样式 | ||
show figure.caption: c => { | ||
block(inset: (top: .4em, bottom: .4em))[ | ||
#emph[#c.supplement #context c.counter.display(c.numbering) #h(.3em) #c.body] | ||
] | ||
} | ||
doc | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#import "/package/util.typ": switch-two-side | ||
|
||
// 定义全局标题样式 | ||
#let heading-style( | ||
doc, | ||
sans-serif: "", | ||
h-size: 0pt, | ||
h1-size: 0pt, | ||
h2-size: 0pt, | ||
two-side: false, | ||
weight: "semibold", | ||
) = { | ||
// ---------------- 字体/字号/字重设置 ----------------- | ||
// 标题字体 + 字重设置 | ||
show heading: set text(font: sans-serif, size: h-size, weight: weight) | ||
// 设置一级标题字号 | ||
show heading.where(level: 1): set text(size: h1-size) | ||
// 设置二级标题字号 | ||
show heading.where(level: 2): set text(size: h2-size) | ||
// ----------------- 对齐设置 ------------------ | ||
// 设置一级标题居中 | ||
show heading.where(level: 1): set align(center) | ||
// ----------------- 间距设置 ------------------ | ||
// 设置标题间距 | ||
show heading: set block(spacing: 25pt) | ||
show heading: set block(spacing: 25pt) | ||
// 设置一级标题间距和自动换页 | ||
show heading.where(level: 1): it => { | ||
// 这里不使用 above 是因为靠近页边距,不生效 | ||
switch-two-side(two-side) | ||
v(1.5em) | ||
it | ||
v(1em) | ||
} | ||
doc | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should update this line with actual information.