Skip to content

Commit f2d1cc8

Browse files
committed
hfut-report-template:0.1.0
1 parent fb25c8b commit f2d1cc8

File tree

14 files changed

+1178
-0
lines changed

14 files changed

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

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

Lines changed: 1 addition & 0 deletions
Loading

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

Lines changed: 1 addition & 0 deletions
Loading

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

Lines changed: 1 addition & 0 deletions
Loading

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

Lines changed: 31 additions & 0 deletions
Loading

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

Lines changed: 19 additions & 0 deletions
Loading

packages/preview/hfut-report-template/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)