Repository navigation
Expand file tree
/
Copy pathlib.typ
More file actions
235 lines (209 loc) · 5.24 KB
/
Copy pathlib.typ
File metadata and controls
235 lines (209 loc) · 5.24 KB
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#import "@preview/cuti:0.2.1": show-cn-fakebold
#show: show-cn-fakebold
#set par(first-line-indent: 2em)
#import "@preview/codly:1.3.0": *
#import "@preview/codly-languages:0.1.1": *
#show: codly-init.with()
#import "@preview/numbly:0.1.0": numbly
#set heading(numbering: numbly(
"{1:一}、",
"{1}.{2}",
"({3:a})",
))
#let set_my_page(xuehao:"2024111111", experiment: "实验名称") = (content) => {
set text(font: (
(name: "Consolas", covers: "latin-in-cjk"),
"Microsoft YaHei" // 中文字体
), lang: "zh")
set text(size: 14pt)
set heading(numbering: numbly(
"{1:一}、",
"{1}.{2}",
"({3:a})",
))
set page(
margin: (x:1cm,y:1.5cm),
foreground:repeat(
rotate(60deg,
text(xuehao,
size: 135pt ,
fill: rgb(0, 0, 0, 30)
)
) ),
header: context if (counter(page).get().first() == 1) {
""
v(-1em)
line(stroke: 1pt + gray, length:100%)
} else {
experiment
h(1fr)
"学号" + xuehao
v(-1em)
line(stroke: 1pt + gray, length:100%)
},
footer: context align("第" + counter(page).display("1") + "页," + "共"+ str(counter(page).final().at(0))+"页", center)
)
show raw: (content) => {
//set text(size: 12pt)
//highlight(content, fill:rgb(200,200,200,100))
let newline = content.text.contains("\n")
if newline {
content
} else {
box(fill:rgb(140,140,140,80),
outset:3pt,
content
)
}
}
// show: codly-init.with()
//codly(
// languages: (
// verilog: (name: "Verilog", icon: "", color: rgb("#b665ab")),
// )
//)
show raw.where(block: true): it => { set par(justify: false); rect(grid(
columns: (100%, 100%),
column-gutter: -100%,
block(width: 100%, inset: 1em, for (i,line) in it.text.split("\n").enumerate() {
box(width: 0pt, align(right, str(i + 1) + h(2em)))
hide(line)
linebreak()
}),
block(fill: rgb(10, 10, 10, 30), width: 100%, inset: 1em, it),
)
,outset: -5pt)}
//show raw.where(block: true): (content) => {
// block(content, fill:rgb(0,0,0,))
//}
//
set figure.caption(
separator: [:]
)
show figure.where(kind: "subfigure"): set figure(supplement: "图")
// use bold "Figure 1:" caption for parent figure.
show figure.caption: it => context {
[#it.supplement#it.counter.display(it.numbering)#it.separator]
[ ]
it.body
}
// use nesting level of figure to infer numbering of subfigures.
show figure.where(kind: image): outer => {
counter(figure.where(kind: "subfigure")).update(0) // reset subfigure counter
set figure(numbering: (..nums) => {
let outer-nums = counter(figure.where(kind: image)).at(outer.location())
std.numbering("1a", ..outer-nums, ..nums)
})
show figure.where(kind: "subfigure"): inner => {
// use bold "(a)" caption for subfigures.
show figure.caption: it => context {
strong(std.numbering("(a)", it.counter.at(inner.location()).last()))
[ ]
it.body
}
inner
}
outer
}
set figure(numbering:"(1)")
show ref: it => {
let el = it.element
if (el != none and el.func() == figure) {
"图"+numbering(el.numbering, ..counter(figure).at(el.location()))
}else {
it
}
}
content
}
#let subfigure(body, outlined: false, ..args, label: none) = {
let fig = figure(body, kind: "subfigure", outlined: outlined, ..args)
if label == none {
return fig
}
[ #fig #label ]
}
#let info(
name: "张三",
id: "2023001",
class: "计算机科学1班",
experiment: "实验一"
) = {
rect(
fill: rgb(200, 200, 200, 100),
stroke: silver,
radius: 8pt,
inset: 14pt,
stack(
// 标题行
align(center, text(20pt, weight: "bold", experiment)),
v(6pt),
// 分隔线
line(length: 100%, stroke: silver),
v(4pt),
// 信息网格aling
text(weight: "bold", "姓名: ", size: 15pt)+text(name, size: 15pt),
v(6pt),
text(weight: "bold", "学号: ", size: 15pt) + text(id, size: 15pt),
v(6pt),
text(weight: "bold", "班级: ", size: 15pt) + text(class, size: 15pt)
)
)
}
#show raw: (content) => {
box(
fill:gray(90%),
content
)
}
// 定义 answer 函数
#let answer(content) = {
rect(
width: 100%, // 宽度占满整行
stroke: black, // 边框颜色
inset: 10pt, // 内边距
radius: 4pt, // 边框圆角
stack(
grid(
columns: (auto, 1fr),
text(weight: "bold", "答:"), content
)
)
)
}
#let question-counter = counter("question")
// 定义 question 函数
#let question(
content,
title: none,
numbering: true
) = {
let heading = if title != none {
title
} else if numbering {
question-counter.step()
context"问题" + question-counter.display()
} else {
"问题"
}
rect(
width: 100%,
radius: 6pt,
inset: 12pt,
stack(
text(14pt, weight: "bold", heading + ":"),
v(6pt),
h(2em) + content
)
)
}
#show raw.where(block: true): it => { set par(justify: false); grid(
columns: (100%, 100%),
column-gutter: -100%,
block(width: 100%, inset: 1em, for (i,line) in it.text.split("\n").enumerate() {
box(width: 0pt, align(right, str(i + 1) + h(2em)))
hide(line)
linebreak()
}),
block(fill: rgb(10, 10, 10, 30), width: 100%, inset: 1em, it),
)}