-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.typ
97 lines (83 loc) · 2.67 KB
/
utils.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
#import "./zh-font-config.typ": *
#let write(it) = {
set text(font: ZFC-writing)
set par(first-line-indent: 2em, justify: true)
show math.equation: math.sans
it
}
// 隐藏字形,但仍可被选中与复制;这与 hide 不同
#let hide-glyph(it) = text(fill: color.rgb("#0000"), it)
#let my-remark(it) = align(center, block(
width: 100% - 8em,
inset: 0.5em,
breakable: true,
radius: 0.5em,
fill: rgb("#ffda0080"),
align(left+top, it)
))
#let lorem_zh(n) = for i in range(n) {
[我人有的和主产不为这工要在地一上是中国同经以发了民]
}
#let lorem_all() = [
#lorem(50)
This is some math: $a_b^c = sum_d^e f(g, h)$
#lorem_zh(8) $$
]
#let report-meta(teacher-name, date, grade-preview, grade-total) = text(size: 10.5pt, {
import "./stu-info.typ": *
let _ccell(it) = grid.cell(inset: (bottom: 2.5pt), write(it))
set align(center)
set grid.hline(stroke: 0.85pt)
v(9.1pt)
box(width: 39em, grid(
columns: (auto, 1fr, auto, 1fr, 1em, auto, 1fr, auto, 1fr, 1em, auto, 1fr, auto, 1fr, 1em, auto, 6em),
[*班级*], [], _ccell(stu-class), [], [],
grid.hline(start: 1, end: 4),
[*学号*], [], _ccell(stu-id), [], [],
grid.hline(start: 6, end: 9),
[*姓名*], [], _ccell(stu-name), [], [],
grid.hline(start: 11, end: 14),
[*教师签字*], _ccell(hide-glyph(teacher-name)),
grid.hline(start: 16, end: 17),
))
v(9.1pt)
box(width: 39em, grid(
columns: (auto, 1fr, auto, 1fr, 1em, auto, 4.5em, 1em, auto, 7em),
[*实验日期*], [], _ccell(date), [], [],
grid.hline(start: 1, end: 4),
[*预习成绩*], _ccell(hide-glyph(grade-preview)), [],
grid.hline(start: 6, end: 7),
[*总成绩*], _ccell(hide-glyph(grade-total)),
grid.hline(start: 9, end: 10),
))
v(14.9pt)
set block(spacing: 2.5pt)
line(length: 100%, stroke: 0.7pt)
line(length: 100%, stroke: 0.7pt)
v(16.5pt)
})
#let teacher-signature-box(it) = {
set table.cell(inset: (y: 8pt))
align(right,
table(
columns: (78pt, 77.8pt),
rows: (31.5pt, 31.7pt),
align: center,
text(stroke: 0.5pt, size: 14pt)[教师],
text(stroke: 0.5pt, size: 14pt)[姓名],
text(font: ZFC--kai-zh, stroke: 0.5pt, size: 16pt)[签字],
text(font: ZFC--kai-zh, size: 16pt, hide-glyph(it)),
)
)
}
#let absolute-place(label-name, dx: 0em, dy: 0em, content) = {
[#metadata("absolute-place") #label("absolute-place--" + label-name)]
style(styles => {
let dx = measure(h(dx), styles).width
let dy = measure(v(dy), styles).height
context {
let pos = query(label("absolute-place--" + label-name)).last().location().position()
place(dx: -pos.x + dx, dy: -pos.y + dy, content)
}
})
}