-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.typ
207 lines (171 loc) · 4.44 KB
/
template.typ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#let project(
title: "",
author: "",
infos: (
),
coverTable_display: true,
outline_display: true,
header_display: true,
body
) = {
// 文本和代码的字体
let text_font = "Times New Roman"
let code_font = "DejaVu Sans Mono"
let title_font = "STXinwei"
let songti = "SimSun"
let heiti = "SimHei"
let 字号 = (
四号: 14pt, 小四: 12pt,
)
// 设置正文和代码的字体
set text(font: (text_font, songti), size: 12pt, lang: "zh", region: "cn")
show strong: it => {
show regex("[\p{hani}\s]+"): set text(stroke: 0.3pt)
it
}
show raw: set text(font: (code_font, songti), 10pt)
// 设置文档元数据和参考文献格式
set document(author: author, title: title)
set bibliography(style: "gb-7714-2015-numeric")
// 设置页面
set page(
paper: "a4",
margin: auto,
header: context {
if here().page() == 1 {
return
}
let elems = query(heading.where(level: 1).after(here()))
let chapter-title = ""
if (elems == () or elems.first().location().page() != here().page()) {
let elems = query(heading.where(level: 1).before(here()))
chapter-title = elems.last().body
} else {
chapter-title = elems.first().body
}
emph(chapter-title) + h(1fr) + emph(title)
v(-7pt)
align(center)[#line(length: 105%, stroke: (thickness: 1pt, dash: "solid"))]
},
footer: context {
if here().page() == 1 {return}
align(center)[#counter(page).display("1 / 1",both: true,)]
}
)
//设置标题
set heading(numbering: "1.1 ")
show heading: it => box(width: 100%)[
#set text(font: (text_font, heiti))
#if it.numbering != none { counter(heading).display() }
#it.body
#v(8pt)
]
show heading.where(
level: 1
): it => box(width: 100%)[
#set heading(numbering: "一、")
#set align(center)
#v(4pt)
#it
]
// 配置公式的编号和间距
show math.equation: eq => {
set block(spacing: 0.65em)
eq
}
show math.equation: it => {
show regex("[\p{hani}\s]+"): set text(font: songti)
it
}
// Cover
let underlineField(key, value) = [
#set align(center + horizon)
#set text(size: 字号.小四)
#grid(
columns: (80pt, 250pt),
align(right + top)[
#text(size: 字号.四号)[#key]
],
grid(
rows: (10pt, auto),
row-gutter: 0.2em,
value,
line(length: 98%, stroke: 0.5pt)
)
)
#v(12pt)
]
block(width: 100%, height: 15%, spacing: 0pt)[
#set align(center + bottom)
#box()[
#image("figures/heu_title.png", width: 10.5cm, height: 1.4cm, fit: "stretch")
]
]
block(width: 100%, height: 25%, spacing: 0pt)[
#set align(center + horizon)
#set text(size: 50pt)
#text(font: title_font)[#title]
]
block(width: 100%, height: 35%, spacing: 0pt)[
#set align(center + horizon)
#for i in infos{
underlineField(i.key, i.value)
}
]
block(width: 100%,height: 25%, spacing: 0pt)[
#set align(center + horizon)
#if coverTable_display == true {
set text(size: 字号.小四)
table(
columns: 425pt,
rows: (35pt, 140pt),
stroke: 0.5pt,
align: left + horizon,
[大作业成绩:],
table.cell(
align: top,
inset: (y: 12pt),
)[任课教师评语:],
)
}else{
set text(size: 字号.四号)
underline(offset: 2pt)[哈尔滨工程大学本科生院]
}
]
pagebreak()
counter(page).update(1)
// 显示目录
if outline_display{
outline(indent: auto)
pagebreak()
}
// Main body
set par(first-line-indent: 2em, justify: true)
set enum(tight:false, indent: 2em, body-indent: 8pt)
set list(tight:false, indent: 2em, body-indent: 8pt)
show figure: it => [
#v(12pt)
#it
#par()[#text(size: 0.0em)[#h(0.0em)]]
#v(-8pt)
]
show image: it => [
#it
#v(-12pt)
#par()[#text(size: 0.0em)[#h(0.0em)]]
]
show figure.where(
kind: raw
): it => {
set block(width: 100%, breakable: true)
it
}
// 配置行内代码块、行间代码块
show raw.where(block: false): it => box(fill: luma(240), inset: (x: 2pt), outset: (y: 3pt), radius: 1pt)[#it]
show raw.where(block: true): it => block(width: 100%, fill: luma(240), inset: 10pt, radius: 3pt, breakable: true)[#it]
body
}
// 公式编号
#let equation(it) = {
math.equation(numbering: "(1)", block: true, it)
}