-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.typ
More file actions
210 lines (178 loc) · 4.09 KB
/
lib.typ
File metadata and controls
210 lines (178 loc) · 4.09 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
#import "@preview/codly:1.0.0": *
#import "@preview/gentle-clues:0.9.0": *
#import "@preview/cuti:0.2.1": show-cn-fakebold
#import "@preview/showybox:2.0.1": showybox
#import "@preview/cetz:0.2.2"
#import "@preview/mitex:0.2.4":*
#import "@preview/lovelace:0.3.0": *
#import "@preview/finite:0.3.2":automaton
#import "@preview/commute:0.2.0":*
#import "../Draft/src/exports.typ":*
#let (
BLUE,
GREEN,
YELLOW,
RED,
)=(
rgb("#4285f4"),
rgb("#34a853"),
rgb("#fbbc05"),
rgb("#ea4335"),
)
#let BlueText(_text)={
set text(fill: BLUE)
[#_text]
}
#let GreenText(_text)={
set text(fill: GREEN)
[#_text]
}
#let YellowText(_text)={
set text(fill: YELLOW)
[#_text]
}
#let RedText(_text)={
set text(fill: RED)
[#_text]
}
#import "@preview/suiji:0.3.0": *
#let Colorful(_text)={
let colors = (
rgb("#4285F4"),
rgb("#34A853"),
rgb("#FBBC05"),
rgb("#EA4335"),
)
let i=7;
let rng = gen-rng(_text.text.len() * i);
let index_pre = integers(rng, low: 0, high: 4, size: none, endpoint: false).at(1);
for c in _text.text{
let rng = gen-rng(i - 1);
let index_cur = integers(rng, low: 0, high: 4, size: none, endpoint: false).at(1);
let cnt=100;
while index_cur == index_pre and cnt>0{
let rng = gen-rng(cnt + i);
index_cur = integers(rng, low: 0, high: 4, size: none, endpoint: false).at(1);
cnt -= 1;
}
let color = colors.at(index_cur);
set text(fill: color)
[#c]
index_pre = index_cur;
i += 2;
}
}
// #let Link(_link)=box(link(_link,image("assets/link.svg")), height: 1em)
#let Title(
title:[],
reflink:"",
level:1,
)={
let pic = (
"",
"assets/easy.svg",
"assets/medium.svg",
"assets/hard.svg",
)
box(
image(pic.at(level), height: 1em),
)
[#title]
box(
link(reflink,image("assets/link.svg", height: 1em))
)
}
#let note(
difficuty:[],
title:[标题],
description:[描述],
examples:(),
tips:[提示],
solutions:(),
code:[代码],
gain:none,
)={
block({
question(
title:title,
)[#description]
let i=1;
for _example in examples {
example(
title:"示例" + str(i),
)[#_example]
i+=1;
}
tip(
title:[提示],
)[#tips]
let j=1;
// pagebreak()
for solution in solutions {
idea(
title:"方法" + str(j)+": "+solution.name,
)[#solution.text
#solution.code
]
j+=1;
}
if(gain != none){
conclusion(
title:[笔记],
)[#gain]
}
})
}
#let xquotation(first:[],second:[])=if first != [
]{ quotation(
title:[书内链接],
)[
#columns(2)[
#set par(justify: true)
#first
#colbreak()
#second
]
]
}
//
// #llltable(
// titles:table.header(
// [*Random walk*],[*Markov chain*]
// ),
// columns:2,
// caption: [随机游走与马尔可夫链],
// [图 Graph], [随机过程 Stochastic process],[顶点 Vertex], [状态 State],[强连通 Strongly connected], [持续 Persistent],[非周期的 Aperiodic], [非周期的 Aperiodic],[强连通且非周期的 Strongly connected and aperiodic], [遍历的 Ergodic],[无向图 Undirected graph], [时间可逆的 Time reversible]
// )
yes! it works!
#let llltable(titles:[],columns:1,caption:[],align:left,kind:"table",supplement:[表],..items)={
let items=items.pos()//在函数定义中,..bodies 表示接收任意数量的参数,这些参数被收集到一个特殊的 参数对象(arguments object) 中.bodies.pos() 方法从参数对象中提取所有的 位置参数,并返回一个 序列(sequence),即一个有序的参数列表。
figure(
kind:kind,
supplement:supplement,
caption: caption,
table(
stroke: none,
columns: columns,
align: align,
table.hline(),
// table.header(
// for title in titles {
// strong(title)
// }
// ),
titles,
table.hline(),
..items,
table.hline(),
),
)
}
#let algo(caption:[],content:[])={
figure(
kind: "algorithm",
caption: caption,
supplement: [算法],
content
)
}