Skip to content

Commit 5b860bf

Browse files
authored
modern-hfut-report:0.1.0 (#3491)
1 parent b6b1e13 commit 5b860bf

File tree

14 files changed

+1183
-0
lines changed

14 files changed

+1183
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 HPCesia
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.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# 合肥工业大学课程现代设计报告模板
2+
3+
A modern report template for HFUT (unofficial)
4+
5+
这是合肥工业大学的现代课程设计报告模板(非官方)
6+
7+
## 使用方法
8+
9+
开始使用模板时,请先完整阅读 `template/guide.typ`及其预览,了解如何从模板开始编写自己的报告
10+
11+
### 在线编辑
12+
13+
[Typst Web App](https://typst.app/) 提供在线编辑和编译功能,适合不想在本地安装软件的用户
14+
15+
只需在 Web App 的 [Templates](https://typst.app/universe/search/?kind=templates) 中搜索「modern-hfut-report」,点击「Create project in app」即可在线创建模板
16+
17+
### 本地编辑
18+
19+
推荐使用 [VSCode](https://code.visualstudio.com/download) + [Tinymist](https://marketplace.visualstudio.com/items?itemName=myriad-dreamin.tinymist) 插件进行本地编辑
20+
21+
#### 方法一:使用 typst init(推荐)
22+
23+
```bash
24+
typst init @preview/modern-hfut-report:0.1.0
25+
cd modern-hfut-report
26+
```
27+
28+
#### 方法二:在 VSCode 中创建
29+
30+
按下「Ctrl + Shift + P」打开命令面板,输入「Typst: Show Available Typst Templates」,从列表中选择 modern-hfut-report,点击「+」号创建项目
31+
32+
最后用 VSCode 打开生成的目录,打开 `template/report.typ` 文件,等待插件激活后点击顶部预览按钮进行预览
33+
34+
### 本地开发
35+
36+
如果你想要开发本模板,请从 [GitHub 仓库](https://github.com/KercyDing/modern-hfut-report) 克隆代码到本地,将 `template/report.typ` 首行的导入路径更换为 `"../lib.typ"`
37+
38+
## 致谢
39+
- [modern-xmu-thesis](https://typst.app/universe/package/modern-xmu-thesis) by HPCesia,本模板借鉴了该模板的部分思路
40+
- [i-figured](https://typst.app/universe/package/i-figured) by RubixDev,使用起来确实很方便,功能也很强大
41+
- [zh-format](https://typst.app/universe/package/zh-format) by me,自己为了这碗醋才包的这顿饺子(bushi
42+
43+
## 环境要求
44+
45+
- Typst 版本:0.13.1+
46+
- 首次使用需联网下载依赖库
47+
48+
## 许可证
49+
50+
[MIT License](LICENSE)
Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
// ===========================
2+
// HFUT 课程设计报告模板库
3+
// ===========================
4+
5+
// ===========================
6+
// 第三方库导入
7+
// ===========================
8+
// 导入i-figured库用于公式和图表编号管理
9+
#import "@preview/i-figured:0.2.4"
10+
// 导入格式化工具库(包含中文加粗、斜体、下划线等功能)
11+
#import "@preview/zh-format:0.1.0": *
12+
13+
// ===========================
14+
// 主函数:报告模板配置
15+
// ===========================
16+
#let hfut-report(
17+
// 基本信息(默认为空)
18+
title: "",
19+
department: "",
20+
major: "",
21+
class: "",
22+
author: "",
23+
student-id: "",
24+
supervisor: "",
25+
date: "",
26+
// 摘要和关键词
27+
abstract: [摘要内容...],
28+
keywords: ("关键词1", "关键词2"),
29+
// 摘要页开关(true:显示摘要页,false:不显示摘要页)
30+
show-abstract: true,
31+
// 目录页开关(true:显示目录页,false:不显示目录页)
32+
show-contents: true,
33+
// 页眉配置参数
34+
header-logo-height: 0.8cm,
35+
header-title-size: 9pt,
36+
header-line-stroke: 0.4pt,
37+
// 段落首行缩进配置
38+
first-line-indent: 0em,
39+
// equation 计数
40+
show-equation: i-figured.show-equation,
41+
body,
42+
) = {
43+
// ===========================
44+
// 全局样式配置
45+
// ===========================
46+
47+
// 应用中文格式化(粗体、下划线、斜体)
48+
show: zh-format
49+
50+
// 文档元数据
51+
set document(author: author, title: title)
52+
53+
// 页面设置
54+
set page(
55+
paper: "a4",
56+
margin: (top: 2.5cm, bottom: 2.5cm, left: 2.2cm, right: 2.2cm),
57+
)
58+
59+
// 正文字体设置:Times New Roman + 宋体
60+
set text(
61+
font: ("Times New Roman", "SimSun"),
62+
lang: "zh",
63+
size: 12pt,
64+
)
65+
66+
// 段落格式设置:两端对齐
67+
set par(
68+
justify: true,
69+
leading: 0.65em,
70+
first-line-indent: 0em, // 默认不缩进
71+
)
72+
73+
// 标题间距设置
74+
show heading: set block(above: 1.4em, below: 1em)
75+
76+
// 代码块样式设置
77+
show raw.where(block: true): block.with(
78+
fill: luma(240),
79+
inset: 10pt,
80+
radius: 4pt,
81+
width: 100%,
82+
stroke: 0.5pt + luma(200),
83+
)
84+
85+
// 行内代码样式
86+
show raw.where(block: false): box.with(
87+
fill: luma(240),
88+
inset: (x: 3pt, y: 0pt),
89+
outset: (y: 3pt),
90+
radius: 2pt,
91+
)
92+
93+
// 脚注格式设置:[1] [2] 格式的蓝色上标
94+
show footnote: set text(blue)
95+
set footnote(numbering: "[1]")
96+
97+
// 每个标题时重置计数器
98+
show heading: i-figured.reset-counters
99+
100+
// 设置 equation 的编号(只对块级公式编号,<-> 标签取消编号)
101+
show math.equation.where(block: true): show-equation.with(
102+
only-labeled: false,
103+
unnumbered-label: "-",
104+
)
105+
106+
// 图表标题样式
107+
show figure.caption: set text(font: ("Times New Roman", "SimHei"), size: 10pt)
108+
109+
// 表格样式
110+
show table: set text(size: 10pt)
111+
112+
// ===========================
113+
// 封面页
114+
// ===========================
115+
{
116+
set align(center)
117+
set page(header: none, footer: none, numbering: none)
118+
119+
v(0.5cm)
120+
image("template/assets/HFUT_badge_zh&en_Vertical.svg", width: 7cm)
121+
v(1cm)
122+
123+
text(22pt, font: ("Times New Roman", "SimSun"))[
124+
*#underline[#title] 课程设计报告*
125+
]
126+
127+
v(3cm)
128+
129+
grid(
130+
columns: (auto, 14em),
131+
rows: auto,
132+
gutter: 1em,
133+
row-gutter: 1.2em,
134+
align: (right, center),
135+
136+
text(18pt, font: ("Times New Roman", "SimSun"))[*学  院:*],
137+
u(width: 15em, offset: 0.35em)[#text(16pt)[#department]],
138+
139+
text(18pt, font: ("Times New Roman", "SimSun"))[*专  业:*],
140+
u(width: 15em, offset: 0.35em)[#text(16pt)[#major]],
141+
142+
text(18pt, font: ("Times New Roman", "SimSun"))[*班  级:*],
143+
u(width: 15em, offset: 0.35em)[#text(16pt)[#class]],
144+
145+
text(18pt, font: ("Times New Roman", "SimSun"))[*姓  名:*],
146+
u(width: 15em, offset: 0.35em)[#text(16pt)[#author]],
147+
148+
text(18pt, font: ("Times New Roman", "SimSun"))[*学  号:*],
149+
u(width: 15em, offset: 0.35em)[#text(16pt)[#student-id]],
150+
151+
text(18pt, font: ("Times New Roman", "SimSun"))[*指导教师:*],
152+
u(width: 15em, offset: 0.35em)[#text(16pt)[#supervisor]],
153+
)
154+
155+
v(2cm)
156+
text(16pt)[#if date == "today" { datetime.today().display("[year]年[month]月[day]日") } else { date }]
157+
158+
pagebreak()
159+
}
160+
161+
// ===========================
162+
// 摘要页
163+
// ===========================
164+
if show-abstract {
165+
set page(header: none, footer: none, numbering: none)
166+
set align(center)
167+
168+
text(18pt, font: ("Times New Roman", "SimSun"))[*摘 要*]
169+
v(1.5em)
170+
171+
set align(left)
172+
set par(first-line-indent: 0em)
173+
174+
abstract
175+
v(2em)
176+
177+
set par(first-line-indent: 0em)
178+
text(font: ("Times New Roman", "SimSun"))[*关键词:*] + keywords.join("")
179+
180+
pagebreak()
181+
}
182+
183+
// ===========================
184+
// 正文页眉页脚设置
185+
// ===========================
186+
set page(
187+
header: [
188+
#grid(
189+
columns: (auto, 1fr),
190+
align: (left + top, right + top),
191+
gutter: 0.5em,
192+
image("template/assets/HFUT_badge_zh_Horizontal.svg", height: header-logo-height),
193+
[
194+
#v(0.8em)
195+
#text(15pt, font: ("Times New Roman", "SimSun"))[*#title*]
196+
],
197+
)
198+
#v(-1.0em)
199+
#line(length: 100%, stroke: header-line-stroke)
200+
],
201+
footer: context align(center)[
202+
#text(10pt)[合肥工业大学 - 第 #counter(page).display("1") 页]
203+
],
204+
numbering: "1",
205+
)
206+
207+
counter(page).update(1)
208+
209+
// ===========================
210+
// 目录页
211+
// ===========================
212+
if show-contents {
213+
// 居中显示目录标题
214+
align(center)[
215+
#text(18pt, font: ("Times New Roman", "SimSun"))[*目 录*]
216+
]
217+
218+
v(1.5em)
219+
220+
outline(
221+
title: none,
222+
depth: 3,
223+
indent: auto,
224+
)
225+
226+
pagebreak()
227+
}
228+
229+
// ===========================
230+
// 标题样式配置
231+
// ===========================
232+
// 设置标题自动编号
233+
set heading(numbering: "1.1.1")
234+
235+
show heading.where(level: 1): it => {
236+
// 一级标题:黑体加粗,视觉突出
237+
set text(font: ("Times New Roman", "SimHei"), weight: "bold", size: 18pt)
238+
set align(center)
239+
240+
v(0.5em)
241+
if it.numbering != none {
242+
block[#counter(heading).display() #it.body]
243+
} else {
244+
block[#it.body]
245+
}
246+
v(0.5em)
247+
}
248+
249+
show heading.where(level: 2): it => {
250+
// 二级标题:宋体加粗,避免与一级标题冲突
251+
set text(font: ("Times New Roman", "SimSun"), weight: "bold", size: 15pt)
252+
if it.numbering != none {
253+
block[#counter(heading).display() #it.body]
254+
} else {
255+
block[#it.body]
256+
}
257+
}
258+
259+
show heading.where(level: 3): it => {
260+
// 三级标题:宋体加粗,保持层次一致性
261+
set text(font: ("Times New Roman", "SimSun"), weight: "bold", size: 13pt)
262+
if it.numbering != none {
263+
block[#counter(heading).display() #it.body]
264+
} else {
265+
block[#it.body]
266+
}
267+
}
268+
269+
// ===========================
270+
// 正文内容
271+
// ===========================
272+
body
273+
}

packages/preview/modern-hfut-report/0.1.0/template/assets/HFUT_badge.svg

Lines changed: 1 addition & 0 deletions
Loading

packages/preview/modern-hfut-report/0.1.0/template/assets/HFUT_badge_zh&en_Horizontal.svg

Lines changed: 1 addition & 0 deletions
Loading

packages/preview/modern-hfut-report/0.1.0/template/assets/HFUT_badge_zh&en_Vertical.svg

Lines changed: 1 addition & 0 deletions
Loading

packages/preview/modern-hfut-report/0.1.0/template/assets/HFUT_badge_zh_Horizontal.svg

Lines changed: 31 additions & 0 deletions
Loading

packages/preview/modern-hfut-report/0.1.0/template/assets/HFUT_badge_zh_Vertical.svg

Lines changed: 19 additions & 0 deletions
Loading

packages/preview/modern-hfut-report/0.1.0/template/assets/HFUT_zh&en.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)