repo
stringlengths 26
115
| file
stringlengths 54
212
| language
stringclasses 2
values | license
stringclasses 16
values | content
stringlengths 19
1.07M
|
---|---|---|---|---|
https://github.com/c-allergic/2024-Summer-UGRP | https://raw.githubusercontent.com/c-allergic/2024-Summer-UGRP/main/UGRP.typ | typst | MIT License | #import "@preview/unequivocal-ams:0.1.1": ams-article, theorem, proof
#import "@preview/cetz:0.2.2": canvas,draw,tree,decorations
#import "@preview/codly:1.0.0": *
#set text(
font:"Times New Roman",
size: 12pt,
)
#set par(
justify: false,
leading: 2em,
)
#show: ams-article.with(
bibliography: bibliography("refs.bib"),
title: "Solving the Factoring Problem with an Ising Machine",
paper-size: "a4",
)
#show raw.where(block: true): set text(size: 0.8em)
#set math.equation(numbering: "(1)")
#show: codly-init.with()
#codly(
languages: (
julia: (
name: "Julia",
color: rgb("#CE412B"),
),
)
)
#let jinguo(txt) = {
text(blue)[[JG: #txt]]
}
//basic shapes
#let blackbox((x,y),r,name) = draw.rect(
(x,y),
(rel:(r,r)),
fill: black,
name:name,
)
#let horizontal-line(x1,x2,y,size) = draw.line((x1 - size*0.5,y + size*.7),(x2 + size*1.5,y + size*.7),stroke:3pt)
#let horizontal-carry-line(x1,x2,y,size,name) = draw.line((x1 - size*0.5,y + size*.3),(x2 + size*1.5,y + size*.3),name:name,stroke:1pt)
#let vertical-line(y1,y2,x,size) = draw.line((x + size*0.5,y1 - size*0.5),(x + size*0.5,y2 + size*1.5),stroke:3pt)
#let diaonal-sum-line(x1,y1,x2,y2,size,name) = draw.line((x1 - size*0.5,y1 + size*1.5),(x2 + size*1.5,y2 - size*0.5),name:name,stroke:1pt)
#let carry-bezier(x,y1,y2,size) = draw.bezier-through((x - size*0.5,y1 + size*.3),(x - size *1,y1),(x - size*0.5,y2 + size*1.5),stroke:1pt)
#let p-input(x,y,text,size) = draw.content((x + size*0.5,y + size*1.7),text,anchor:"south")
#let q-input(x,y,text,size) = draw.content((x + size*1.6,y + size*.8),text,anchor:"west")
#let diagonal-io(x,y,text,size,type)= if type == "i" {
draw.content((x - size*0.5,y + size*1.5),text,anchor:"south-east")
} else if type == "o"{
draw.content((x + size*1.5,y - size*0.5),text,anchor:"north-west")
}
#let horizontal-io(x,y,text,size,type)= if type == "i" {
draw.content(((x + size*1.6,y + size*.3)),text,anchor:"west")
} else if type == "o"{
draw.content((x - size*0.6,y + size*.3),text,anchor:"east")
}
#let andgate(x,y,size,name) = {draw.rect(
(x,y),//the start of output line
(rel:(size,size)),
radius: (south:100%),
name:name,
stroke: 1pt
)
draw.line((name:name,anchor:120deg),(x+ 0.2*size,y + 1.5*size),stroke:1pt)//input 1
draw.line((name:name,anchor:60deg),(x+ 0.8*size,y + 1.5*size),stroke:1pt)//input 2
draw.line((name:name,anchor:"south"),(x + 0.5*size,y - 0.5 * size),stroke:1pt) //output
}
#let circontent(x,y,text,size,name) = {
draw.circle((x,y),radius:size,name:name)
draw.content((x,y),text)
}
#let recontent(x,y,text,size,name) = {
draw.rect((x,y),(rel:(size,size)),name:name)
draw.content((x + 0.5* size,y + 0.5* size),text)
}
#let pin(name, direction) = {
if direction == "rt" {
return (name: name, anchor: 20deg)
} else if direction == "lt" {
return (name: name, anchor: 160deg)
} else if direction == "rb" {
return (name: name, anchor: 340deg)
} else if direction == "lb" {
return (name: name, anchor: 200deg)
} else if direction == "t" {
return (name: name, anchor: 90deg)
} else if direction == "tl" {
return (name: name, anchor: 135deg)
} else if direction == "b" {
return (name: name, anchor: 270deg)
} else if direction == "br" {
return (name: name, anchor: 315deg)
}
}
#let dashed-grid-spin(x1,y1,size,name) = {
draw.on-xz({
draw.rect((x1,y1),(rel:(size,size)),stroke:(dash: "dashed"),name:name)
draw.grid((x1,y1),(rel:(size,size)),stroke:(dash: "dashed"),step:.75)
})
draw.line((x1,y1 + .2 * size),(x1,y1 - 0.2*size),mark:(end:"straight"))
draw.line((x1 + .50 * size,y1 + .2 * size ),(x1 + 0.5*size,y1 - .2 * size),mark:(start:"straight"))
draw.line((x1 + size,y1 + .2 * size),(x1 + size,y1 - .2 * size),mark:(end:"straight"))
draw.line((x1 + .25 * size,y1 + 0.5 *size),(x1 + 0.25*size,y1 + 0.1 *size ),mark:(end:"straight"))
draw.line((x1 + .75 * size,y1 + 0.5 *size),(x1 + 0.75*size,y1 + 0.1 *size ),mark:(end:"straight"))
draw.line((x1 + 1.25 * size,y1 + 0.5 *size),(x1 + 1.25*size,y1 + 0.1 *size),mark:(start:"straight"))
draw.line((x1 + .5 * size,y1 + .75 *size),(x1 + .5*size,y1 + 0.35 *size),mark:(start:"straight"))
draw.line((x1 + size,y1 + .75 *size),(x1 + 1*size,y1 + 0.35 *size),mark:(start:"straight"))
draw.line((x1 + 1.5 * size,y1 + .75 *size),(x1 + 1.5*size,y1 + 0.35 *size),mark:(end:"straight"))
}
#let curve-box(x,y,size,name) = {
draw.rect((x,y),(rel:(size,size)),radius: 30%,name:name)
}
#show link: set text(blue)
#align(center)[
*Abstract*
]
This project investigates the use of Ising machines to tackle the prime factorization problem, essential for the security of RSA encryption systems. We develop the `ProblemReductions.jl` package to reduce complex problems into Ising models, enabling efficient solutions through Ising machines. We demonstrate the process of solving the factoring problem using an Ising machine with the assistance of `ProblemReductions.jl`. This work provides a practical way to leverage the power of Ising machines for factoring problems and builds a reduction framework for NP problems.
= Introduction: Ising machine and the factoring problem
Ising machines are powerful hardware solvers that are used to find out the optimal solutions for Spin Glass problems. People have employed multiple kinds of algorithm, like Simulated Annealing and Tensor Networks, to realize Ising machine @mohseni2022ising. For example, @Ising (a) shows a Boltzmann machine and @Ising (b) shows a commercial quantum annealing Ising machine from D-Wave Systems Inc. With an Ising machine, people could solve Spin Glass problems much faster than traditional computers with von-Neuman architecture.
#figure(
image("Ising.png"),
caption:[(a) A Boltzmann machine@kiraly2021atomic. (b)Quantum Annealing Ising machine from D-Wave Systems Inc@D-waveIsingmachine.]
)<Ising>
The ability of Ising machines to solve Spin Glass problems is not that powerful in the context that many algorithms could only solve a single type of problem and when nuanced differences are introduced, the algorithm does not work well. However, in the context of computational complexity, people only care about complexity class of problems such as P, NP, and NP-complete problems class shown in @fig-problem-reductions. The P problems are the problems that could be solved in polynomial time, the NP problems are the problems that could be verified in polynomial time, and the NP-complete problems, where Spin Glass problem belongs to, are the hardest problems in NP. The basic principle of problem reduction is that if a problem A could be reduced to problem B, then problem B is at least as hard as problem A so that problems of same complexity class can be reduced to one another in the time polynomial to the problem size @moore2011nature. Therefore, since many optimization problemms are in NP-complete, it is possible to formulate any NP problem into a Spin Glass problem @lucas2014ising and that is where the Ising machine comes in handy.
#figure(scale(canvas(length: 1cm, {
import draw: *
circle((),radius:3,name:"NP",)
content("NP.north-west","NP",anchor:"south-east")
rect((-1.5,0.5),(rel:(1,1)),name:"P",radius: 30%)
content((-1,1),"P")
rect((-1,-2),(rel:(2.5,1)),name:"NP-complete",radius: 30%)
content((0.3,-1.5),"NP-complete")
rect((0.5,0.3),(rel:(1.6,0.6)),name:"Factoring",radius: 30%)
content((1.35,0.65),"Factoring")
line((name:"Factoring",anchor:"south"),(1,-1),mark:(end:"straight"))
line((name:"P",anchor:"south"),(0,-1),mark:(end:"straight"))
set-style(
line: (stroke: (dash: "dashed")),
rect: (fill: none,stroke:(dash: "dashed")),
)
rect((5,0),(rel:(4,3)),name:"ProblemReductions.jl")
line((name: "NP-complete", anchor: 45deg),(name: "ProblemReductions.jl", anchor: 135deg))
line((name: "NP-complete", anchor: 320deg),(name: "ProblemReductions.jl", anchor: 225deg))
content((7,2.5),"Circuit SAT")
content((7,1.5),"QUBO")
content((7,0.5),"Spin Glass")
content((-3.4,0),"(a)")
content((7,-0.2),"(b)",anchor: "north")
}), x: 70%, y:70%, reflow: true),
caption: [
(a) A possibe diagram of P, NP, and NP-complete problems @garey1979computers and their reduction relations. The circles represent the classes of problems. The arrow represents the reduction from one kind of problem to another.
(b) Several Problems in the package `ProblemReductions.jl`.
] ) <fig-problem-reductions>
Among these problems, the factoring problem is one of the most important problems in number theory and cryptography such as RSA system @rivest1978method@aggarwal2009breaking. It is in NP-intermediate as shown in @fig-problem-reductions, which means it is neither in P nor in NP-complete. Solving the factoring problem could lead to breakthroughs in analyzing the vulnerabilities of the RSA system. And up to now, people have developed many ways to solve the factoring problem, for example, reducing it to the closest lattice vector problem then use _Shortest Vector Problem_(SVP) algorithm to solve it @schnorr2021fast, and using a primitive method --- encoding it into an array multiplier @nguyen2023quantum, both of which could be reduced to the Ising model.
Unfortunately, although there are already many well-established reductions for NP problems @lucas2014ising, we don't have a clear and usable way to reduce factoring to Ising model. This motivates the development of our package, `ProblemReductions.jl`, which not only provides a practical way to bridge this gap, enabling us to leverage the power of Ising machines for factoring problems, but also build up the reduction framework of NP problem. In this article, we aim to demonstrate the process of solving a factoring problem using an Ising machine with the assistance of ProblemReductions.jl, as depicted in @mainfigure. Since we do not have access to actual hardware, we employ the `GenericTensorNetworks` package instead, which provides a software-based Ising machine solver.
#figure(scale(canvas(length: 1.1cm, {
import draw: *
curve-box(0,5,3,"factoring")
curve-box(0,0,3,"spinglass")
curve-box(6,0,3,"Ising-machine")
curve-box(6,5,3,"solution")
content((1.5,8.3),"(a) Factoring")
content((1.5,-.3),"(b) Spin Glass")
content((7.5,-.3),"(c) Ising Machine")
content((7.5,8.3),"(d) Solution")
content((1.5,6.5),$m = p times q$)
set-origin((-.1,1))
dashed-grid-spin(.5,0,1.5,"grid")
set-origin((.1,-1))
content((7.5,1.5), [#image("Ising.png", width:3cm,height:1.2cm)])
content((7.5,7),"configuration")
content((7.5,6.2),$ sigma = {-1,1,dots,1}$)
line("factoring","spinglass",mark:(end:"straight"),name:"1",stroke:2pt)
line("spinglass","Ising-machine",mark:(end:"straight"),name:"2",stroke:2pt)
line("Ising-machine","solution",mark:(end:"straight"),name:"3",stroke:2pt)
line("solution","factoring",mark:(end:"straight"),name:"4",stroke:2pt)
// line((4.5,4.5),(4.5,6.4),stroke:2pt,mark:(end:"straight"))
// line((2.8,4),(1.6,4),stroke:2pt,mark:(end:"straight"))
}), x: 70%, y:70%, reflow: true),
caption: [
Process of solving a factoring problem by Ising machine using `ProblemReductions.jl`.
(a) Factoring problem needed to solve. (b) Through `ProblemReductions.jl`, we reduce the factoring problem to a corresponding Spin Glass problem. (c) The Ising machine is used to solve the Spin Glass problem. (d) Extract the solution to the factoring problem through `ProblemReductions.jl`.
]
)<mainfigure>
= From factoring to Ising machine
== Factoring problem
_Factoring_, a problem of decomposing an $n$-bit composite integer $m$ into its prime factors $p$ and $q$, is denoted as $m = p times q$. To specify it, we use the binary representation for the integer $m= sum_(i=0)^(n-1) 2^i m_i $, with $m_i ∈ {0, 1}$, $p=sum_(i=0)^(k-1)2^i p_i$ for the $k$-bit integer, and $q=sum_(i=0)^(n-k-1)2^i q_i$ for the $(n-k)$-bit integer. The factoring problem thus amounts to finding the unknown bits $p_i$ and $q_i$ such that $ sum_(i=0)^(n-1)2^i m_i = sum_(i=0)^(k-1) sum_(j=0)^(n-k-1)2^(i+j)p_i q_j. $ Note that k is a priori unknown since we just want to consider this specific problem. However, one could consider this problem for any $k=1,2,...,n/2$ @nguyen2023quantum.
== Factoring $arrow$ Circuit Satisfaction
The factoring problem can be reduced to the _Circuit Satisfaction_(Circuit SAT) problem.
Circuit SAT is a problem of determining whether a given boolean circuit has a satisfying assignment. Hence, factoring is the problem of finding the satisfying assignment of the integer multiplication circuit.
In computer science, the multiplication of two integers is often implemented using an _array multiplier_ as shown in @fig:multiplier.
The basic idea of the array multiplier is to multiply each bit of the multiplicand with every bit of the multiplier and then add the partial products to obtain the final product @asha2016performance.
The building block of the array multiplier is composed of an AND gate and a full adder as shown in @fig:multiplier.
To clarify it, we consider a simple multiplication of 3-bits binary numbers
$ 5 times 7 = 35 arrow 111 times 101 = 100011, $
the graphical representation of its vertical calculation and array multiplier is shown in @fig:multiplier.
#align([#figure(scale(canvas(length: 1cm, {
import draw: *
import decorations: *
/// vertical calculation
content((0,1.5),[$1$])
content((0.5,1.5),[$1$])
content((1,1.5),[$1$])
content((0.5,1),[$0$])
content((1,1),[$1$])
content((0,1),[$1$])
content((-0.5,1),[$times$])
line((-.8,0.7),(1.2,.7))
content((0,0.5),[$1$])
content((0.5,0.5),[$1$])
content((1,0.5),[$1$])
content((0.5,0),[$0$])
content((0,0),[$0$])
content((-0.5,0),[$0$])
content((0,-0.5),[$1$])
content((-0.5,-0.5),[$1$])
content((-1,-0.5),[$1$])
line((-1.7,-0.7),(1.2,-0.7))
content((0,-1),[$0$])
content((0.5,-1),[$1$])
content((1,-1),[$1$])
content((-0.5,-1),[$0$])
content((-1,-1),[$0$])
content((-1.5,-1),[$1$])
//caption
content((0,-1.5),"(a)vertical calculation")
///array multiplier
set-origin((5.5,-6))
blackbox((0,0),1,"a")
blackbox((3,0),1,"b")
blackbox((6,0),1,"c")
blackbox((0,3),1,"d")
blackbox((3,3),1,"e")
blackbox((6,3),1,"f")
blackbox((0,6),1,"g")
blackbox((3,6),1,"h")
blackbox((6,6),1,"i")
// p and sum input
horizontal-line(0,6,6,1)
horizontal-line(0,6,3,1)
horizontal-line(0,6,0,1)
horizontal-line(0,6,0,1)
horizontal-carry-line(0,6,6,1,"1C")
horizontal-carry-line(0,6,3,1,"2C")
horizontal-carry-line(0,6,0,1,"3C")
// q input
vertical-line(0,6,0,1)
vertical-line(0,6,3,1)
vertical-line(0,6,6,1)
//carry input
diaonal-sum-line(0,6,6,0,1,"1S")
diaonal-sum-line(3,6,6,3,1,"2S")
diaonal-sum-line(0,3,3,0,1,"3S")
diaonal-sum-line(0,0,0,0,1,"4S")
diaonal-sum-line(6,6,6,6,1,"5S")
carry-bezier(0,6,3,1)
carry-bezier(0,3,0,1)
//content
p-input(6,6,$p_0$,1)
p-input(3,6,$p_1$,1)
p-input(0,6,$p_2$,1)
q-input(6,6,$q_0$,1)
q-input(6,3,$q_1$,1)
q-input(6,0,$q_2$,1)
diagonal-io(0,6,$0$,1,"i")
diagonal-io(3,6,$0$,1,"i")
diagonal-io(6,6,$0$,1,"i")
diagonal-io(6,6,$m_0$,1,"o")
diagonal-io(6,3,$m_1$,1,"o")
diagonal-io(6,0,$m_2$,1,"o")
diagonal-io(3,0,$m_3$,1,"o")
diagonal-io(0,0,$m_4$,1,"o")
horizontal-io(6,6,$0$,1,"i")
horizontal-io(6,3,$0$,1,"i")
horizontal-io(6,0,$0$,1,"i")
horizontal-io(0,0,$m_5$,1,"o")
content("1C.0%",$c_(2,0)$,anchor:"north")
content("1C.30%",$c_(1,0)$,anchor:"north")
content("1C.70%",$c_(0,0)$,anchor:"north")
content("2C.1%",$c_(2,1)$,anchor:"north-east")
content("2C.30%",$c_(1,1)$,anchor:"north")
content("2C.70%",$c_(0,1)$,anchor:"north")
content("3C.30%",$c_(1,2)$,anchor:"north")
content("3C.70%",$c_(0,2)$,anchor:"north")
content("1S.30%",$s_(2,0)$,anchor:"east")
content("2S.50%",$s_(1,0)$,anchor:"east")
content("1S.70%",$s_(1,1)$,anchor:"east")
content("3S.50%",$s_(2,1)$,anchor:"east")
content("3S.0%",$s_(3,0)$,anchor:"east")
content("4S.3%",$s_(3,1)$,anchor:"east")
//caption
content((4,-1),"(b)array multiplier")
///blackbox
set-origin((-8,-2))
set-style(
line: (stroke: (dash: "dashed")),
rect: (fill: none,stroke:(dash: "dashed")),
)
rect((7.7,4.8),(9.3,6.2),name:"blackbox")
rect((-.5,1),(rel:(6,5)),name:"design")
line((name:"blackbox",anchor:135deg),(name:"design",anchor:45deg))
line((name:"blackbox",anchor:227deg),(name:"design",anchor:315deg))
rect((1.3,2.3),(rel:(2.5,2.5)),name:"box",stroke:1pt)
//content
andgate(2.8,3.7,.3,"and")
rect((1.9,2.6),(rel:(1.6,.8)),name:"FA1",stroke: 1pt)
content((2.7,3),text(8pt)[Full Adder])
// io
line((4.4,4.3),(.5,4.3),stroke:1pt,mark:(end:"straight"))
line((name:"box",anchor:90deg),(2.55,5.5),stroke:1pt)
line((),(2.55,3.6),(1.7,3.6),stroke:1pt)
line((),(1.7,2.45),(2.56,2.45),stroke:1pt)
line((name:"box",anchor:270deg),(2.55,2.45),(2.55,1.5),stroke:1pt,mark:(end:"straight"))
line((name:"FA1",anchor:315deg),(4.5,1.7),stroke:1pt,name:"sum-out",mark:(end:"straight"))
line((.7,5.4),(2.1,4),(2.1,3.4),stroke:1pt,name:"sum-in")
line(pin("FA1","rt"),(4.4,3.15),stroke:1pt,name:"cin")
line(pin("FA1","lt"),(.5,3.15),stroke:1pt,name:"cout",mark:(end:"straight"))
line((2.95,3.4),(2.95,3.7),stroke:1pt)
line((3.04,4),(3.04,4.3),stroke:1pt)
circle((3.04,4.3),radius:.06,fill:black)
line((2.55,4.15),(2.87,4.15),stroke:1pt)
circle((2.55,4.15),radius:.06,fill:black)
//bits io
content((.5,5.7),$s_(i+1,j-1)$)
content((4.7,1.6),$s_(i,j)$)
content((4.9,3.2),$c_(i-1,j)$)
content((0.2,3.2),$c_(i,j)$)
content((2.55,5.8),$p_i$)
content((2.55,1.4),$p_i$)
content((4.6,4.4),$q_j$)
content((.2,4.4),$q_j$)
}), x: 70%, y:70%, reflow: true),
caption: [
(a) The multiplication of 3-bits binary numbers. The vertical calculation of 7 times 5 is shown.
(b) The array multiplier @nguyen2023quantum. It multiplies each bit of the multiplicand with the multiplier bits to generate partial products, which are then summed for the final product.
(c) The building block of array multiplier (@blackbox). Each building block is composed of an AND gate and a full adder.
//The four inputs of blackbox are respectively: one bit of mulpicand and one bit of multiplier, the carry-in and sum-in. Outputs are the carry-out and sum-out.
]
) <fig:multiplier>])
#linebreak()
Observing the array multiplier and blackbox in @fig:multiplier, it is obvious that each blackbox contains several constraints to its input. Here, for such a $n times n$ multiplier, we could define the constraint for each blackbox as:
$ s_(i,j) + 2c_(i,j) = p_i q_j + c_(i-1,j) + s_(i+1,j-1) \
c_(-1,j) = s_(i,-1) = 0 $ <blackbox>
for $i,j in {0,1,dots,n}$, let $c_(i j)$ and $s_(i j)$ represent the carry-out and sum-out, $p_i$ and $q_j$ denote the $i$th bit of the multiplicand and the $j$th bit of the multiplier, and $c_(i-1,j)$ and $s_(i,j-1)$ refer to carry-in and sum-in, where $i-1$ and $j-1$ simply indicates that each blackbox receives carry-out from the last blackbox in the same row, and sum-out from the upper-left blackbox(which, in vertical calculation corresponds to the previous column) @nguyen2023quantum.
A boolean circuit is a directed graph with input nodes and one or more output node. The internal nodes, known as "gate", produce logical function of inputs. One could devide a circuit into a series of layers of gates and the gates from each layer receive inputs from the layer above them @moore2011nature. Based on this "layer" design, we could reduce factoring to Circuit SAT simply by pushing all the constraints in the blackbox to certain layers in the circuit.
== Circuit Satisfaction $arrow$ QUBO
Firstly, we give a formal definition of the _Quadratic Unconstrained Binary Optimization_ (QUBO) model. Definition: The QUBO model is expressed by the optimization problem:
$ "QUBO: minimize/maximize" y=x^t Q x $ where $x$ is a vector of binary decision variables and $Q$ is a square matrix of constants. It is worth noticing that the there are distinct differences between QUBO and Circuit SAT since, firstly, the former is a optimization problem and the latter is a decision problem and secondly, QUBO is unconstrained and Circuit SAT is constrained. However, by constructing $Q$ properly, one could implicitly introduce the constraints into the QUBO model.
For constrained optimization problems, quadratic penalties are introduced to simulate the constraints so that the constraints problems could be re-formulated into QUBO problems effectively @glover2022quantum. As an example, we consider the logical operations that are common in Circuit SAT and their corresponding QUBO penalties in Table 1.
#align(center)[
#figure(table(
columns: 2,
table.header(
[*Logical Operation*],[*QUBO Penalty*]
),
[$z = not x$],[$2x z-x-z+1$],
[$z = x_1 or x_2$],[$x_1 x_2 + (x_1 + x_2)(1-2z)+ z$],
[$z = x_1 and x_2$],[$x_1x_2-2(x_1+x_2)z+3z$],
[$z = x_1 xor x_2$],[$2x_1x_2-2(x_1+x_2)z-4(x_1+x_2)a+4a z+x_1+x_2+z+4a$]
),
caption: [QUBO Penalties for Logical Operations @noauthor_reformulating_nodate]
) <tbl:qubo>
]
In @tbl:qubo, all the variables are intended to be binary value and note that in that case, we have $ x_i^2 = x_i $ and thereby we could transform the linear part into quadratic one @glover2022quantum. For example, for the NOT operation, we could obtain its QUBO expression as follows:
$ z = not x arrow y = 2x z -x^2 - z^2+1 arrow y = mat(x,z;delim:"[") mat(-1,1;
1,-1;delim: "[") mat(x;
z;delim: "[") $
For each truth assignment of the variables, the penalty would be 0 if the logical operation is satisfied and be larger than 0 otherwise. By checking whether the penalty is 0, we could determine whether the logical operation is satisfied. Given this penalties gadgets, we process by considering a simple conjunction of two gedgets. Given a Circuit SAT example
#align(center)[
#canvas(length: 0.8cm,{
import draw: *
circontent(-.6,0,$x_1$,0.5,"x1")
circontent(1.4,0,$x_2$,0.5,"x2")
recontent(-1,-2,text(6pt)[AND],0.8,"and1")
recontent(1,-2, text(6pt)[OR],0.8,"or1")
recontent(0,-3.5,text(6pt)[AND],0.8,"and2")
circontent(0.4,-4.4,$z$,0.5,"z")
line("x1","and1",mark:(end:"straight"))
line("x2","and1",mark:(end:"straight"))
line("x1","or1",mark:(end:"straight"))
line("x2","or1",mark:(end:"straight"))
line("and1","and2",mark:(end:"straight"),name:"y1")
line("or1","and2",mark:(end:"straight"),name:"y2")
line("and2","z",mark:(end:"straight"))
content("y2.mid",$y_2$,anchor:"north-west")
content("y1.mid",$y_1$,anchor:"north-east")
content((3,-2.5),"(a)")
})
]
In (a), there is a simple conjuction of an AND gate and an OR gate. The output of them, $y_1$ and $y_2$, is then connected to the AND gate in the next layer as inputs. The conjuction of the two gates in the first layer is given by:
$ z = y_1y_2 -2(y_1+y_2)z+3z $ <conjunction>
So by simply change the literals in the QUBO penalty, we could simulate the conjuction of two gadgets and therby the Circuit SAT problem. The whole reduction of (a), from Circuit SAT to QUBO, is given by:
$ y_1 = x_1x_2-2(x_1+x_2)y_1+3y_1 $ $ y_2 = x_1 x_2 + (x_1 + x_2)(1-2y_2)+ y_2 $ #align(center)[and @conjunction]
== QUBO $arrow$ Spin Glass and Ising machine
=== Reduction from QUBO to Spin Glass
_Spin Glass_ problem is of great interest both in solid state physics and in statistical physics. Simply speaking, in a Spin Glass system, there are many spins that interact with each other and the onsite energy, such as magnetic field. In spin glss, there is an energy interaction between spins:
$H_12 = J_12 sigma_1 sigma_2$,
where $sigma_1$ and $sigma_2$ are the spins and $J_12$ is the interaction @barahona1982computational. For a configuration $sigma ={sigma_1,sigma_2,...,sigma_n}, $ where $sigma_i = {+1,-1}$, the energy of the configuration is given by the Hamiltonian
$ H = sum_(i,j) J_(i j) sigma_i sigma_j + sum_(i) h_i sigma_i. $ <spinglass-energy>
The parameters $J$ and $h$ correspond to the energies associated with spins' interactions with other spins and the external field, respectively. Note that in @spinglass-energy we set the sign to be positive to keep consistent with QUBO's penalty rules. For a ferromagnet, $J$ is positive and a configuration with most interacting spins having parallel moments ($sigma_i = sigma_j$) has lower energy and vice versa. Here we notice that the Hamiltonian is composed of quadratic sum term and linear sum term, which is close to a QUBO form except that spin's value is not binary. A simple way to convert it is by setting $x_i = (1-2sigma_i)/2$ and substitute it into the QUBO penalty, after which we could obtain the Hamiltonian.
Consider a simple example of QUBO:
$min y = mat(x_1,x_2;delim:"[") mat(-1,1;
1,-1;delim: "[") mat(x_1;
x_2;delim: "[")$, which is the QUBO penalty of $x_2 = not x_1$. We substitute $x_i = (1-2sigma_i)/2$ into the penalty and we have: $ y = mat((1-sigma_1)/2,(1-sigma_2)/2;delim:"[") mat(-1,1;
1,-1;delim: "[") mat((1-sigma_1)/2;
(1-sigma_2)/2;delim: "[") arrow y = -1/4 sigma_1^2 -1/4 sigma_2^2 + 1/2sigma_1sigma_2. $ Note that $sigma_i in {-1,1}$, so the square terms are actually constants. Therefore, we could simplify it and obtain the Hamiltonian of the target Spin Glass problem as:
$ H = 1/2 sigma_1 sigma_2. $ We could verify its correctness by comparing the solution of both problems. For QUBO, the solution is $x_1 = 1, x_2 = 0$ and for the Spin Glass, the solution is $sigma_1 = -1, sigma_2 = 1$. Through the conversion, we could see that the two solutions are consistent.
=== Ising machine
Ising model is actually a simplified version of Spin Glass model. The spins in Ising model would assumes one of the two values, +1 or -1, to settle themselves in the lowest energy state with numerous alternatives in the process.The Ising machine is designed to mimic this process and find the optimal solutions for the model. Many algorithms are used to realize the Ising machine, such as simulated annealing, quantum annealing, and tensor network.
In a nutshell, Ising machine is a powerful tool for Ising model. After the whole reduction process, Ising machine could help us obtain a solution of target problem and through extracting the solution, we could get the solution for factoring.
= Code Implementation
== Julia programming language
Julia is a modern, open-source, high performance programming language for technical computing. It was born in 2012 in MIT. Though Julia is new, it has a large number of packages and a strong and fresh community(JuliaHub Inc).
Julia is fast. Its feature of Just-In-Time compilation and its types system keep it from typical compilation and execution uncertainties @bezanson2017julia. At the same time, multiple dispatch feature allows the package based on Julia to be more flexible and extensible, which is not only important for the open-source community but also fit for requirements of the field of optimization problems.
For more information, refer to following links:
- Official website: #link("https://julialang.org/")[JuliaLang]
- Julia Introduction: #link("https://benlauwens.github.io/ThinkJulia.jl/latest/book.html")[ThinkJulia.jl], #link("https://book.jinguo-group.science/stable/")[Scientific Computing for Physicists]
== ProblemReductions.jl
In this section, we will introduce how to use `ProblemReductions.jl`. The main function of the package is problem reduction. It defines a set of computational hard problem(`models`) and provides feasible interface(`reduction_graph` and `reduceto`) to reduce one to another. Here is an example of reduce a factoring problem to a Spin Glass problem through the package.
Consider factoring problem: $6 = p times q$, note that in the package, the parameters for factoring problem is `m`, `n` and `input` where `m` and `n` is the number of bits for the factors and `input` is the number to be factored. Open a Julia REPL and run the following code:
```julia
julia> using ProblemReductions #import the package
julia> factoring = Factoring(2, 2, 6) # 3 bits factors and 6 as input
Factoring(2, 2, 6)
```
#scale(canvas(length: 1.4cm, {
import draw: *
curve-box(-5.6,0,2.,"factoring1")
content((-4.6,1),text(14pt)[$6 = p times q$])
line((-3.5,1),(.5,1),mark:(end:"straight"),stroke:2pt)
content((2,.9),text(14pt)[`Factoring(2,2,6)`],anchor:"south")
}), x: 60%, y:60%, reflow: true)
When we initialize an instance, not only `Factoring`, we need to offer some information about the problem. For `Factoring`, we need to provide the number of bits for the factors and the number to be factored. And the outcome would be a `Factoring` instance with these information.
The next thing is to find out how to reduce the factoring to Spin Glass.
```julia
julia> g = reduction_graph(); # get the reduction graph
julia> path = reduction_paths(Factoring, SpinGlass)
1-element Vector{Vector{Type}}:
[Factoring, CircuitSAT, SpinGlass]
julia> reduction_result = implement_reduction_path(path[1], factoring);
julia> target = target_problem(reduction_result)
SpinGlass{HyperGraph, Vector{Int64}}(HyperGraph(90, [[1, 2], [1, 3], [2, 3], [1], [2], [3], [4], [3, 4], [3, 5], [3, 6] … [84, 88], [82, 88], [88], [83, 89], [63, 89], [89], [88, 89], [88, 90], [89, 90], [90]]), [1, -2, -2, 3, 3, 0, 0, 1, -1, -2 … -2, -2, -3, -2, -2, -3, 1, -2, -2, 1])
```
#scale(canvas(length: 1.1cm, {
import draw: *
curve-box(-5.6,0,2.6,"factoring")
content((-4.2,2),`Factoring`)
content((-4.2,0.4),`SpinGlass`)
line((-4.2,1.8),(-4.2,0.6),mark:(end:"straight"),stroke:1pt,name:"reduce")
content((-4.1,1.4),"?", anchor:"west")
line((-2.8,1.3),(1,1.3),mark:(end:"straight"),stroke:2pt,name:"Findpath")
content((2,.9),``,anchor:"south")
curve-box(1.2,0,2.6,"SpinGlass",)
content((2.5,2),`Factoring`)
content((2.5,1.2),`Circuit SAT`)
content((2.5,0.4),`SpinGlass`)
line((2.5,1.8),(2.5,1.3),mark:(end:"straight"),stroke:1pt,name:"reduce1")
line((2.5,1),(2.5,0.5),mark:(end:"straight"),stroke:1pt,name:"reduce2")
content((-1,1.6),text(10pt)[Find Reduction path])
}), x: 60%, y:60%, reflow: true)
The `reduction_graph` function returns a graph, where each vertex represent a `model` and each edge represent a reduction from one model to another. The `reduction_paths` function returns a list of paths from the source model to the target model. Here we get a vector of problems: `[Factoring, CircuitSAT, SpinGlass]`. That means we need to reduce the factoring problem to a circuit satisfaction problem and then to a Spin Glass problem. The `implement_reduction_path` function is used for problem reductions and it would return the result of the reduction. It's worth noticing that the reduction result is an instance of `AbstractReductionResult` class, which contains the information of the reduction process, not just single problem instance. The `target_problem` function is used to get the target problem from the reduction result. In this case, the target problem is a `SpinGlass` instance.
So the basic programs to implement the problem reduction using `ProblemReductions.jl` are as follows:
- Initialize the source problem and offer the priori known information.
- Initialize the reduction graph using `reduction_graph()`.
- Get the reduction paths using `reduction_paths(source, target)`, note that the source and target should be the type of the source and target problem.
- Implement the reduction path using `implement_reduction_path(path, source)`.
- Get the target problem using `target_problem(reduction_result)`.
```julia
julia> import GenericTensorNetworks # solver
julia> gtn_problem = GenericTensorNetworks.SpinGlass(
target.graph.n,
target.graph.edges,
target.weights
)
julia> result = GenericTensorNetworks.solve(
GenericTensorNetwork(gtn_problem),
SingleConfigMin()
)[]
(-92.0, ConfigSampler{44, 1, 1}(10000000000000110101000001010010000011010000))ₜ
julia> extract_solution(reduction_result, 1 .- 2 .* Int.(read_config(result)))
4-element Vector{Int64}:
1
1
0
1
```
#scale(canvas(length: 1cm, {
import draw: *
curve-box(.1,-.8,3,"SpinGlass")
content((1.6,1.7),text(13pt)[SpinGlass])
dashed-grid-spin(.5,0,1.5,"grid")
line((3.2,.7),(7,.7),mark:(end:"straight"),stroke:2pt)
content((5,1.2),text(14pt)[Ising Machine])
content((5,.4),`GenericTensorNetworks`)
curve-box(7.1,-.8,3,"Solution")
content((8.6,1.5),text(14pt)[Solution])
content((8.55,.5),text(12pt)[$space sigma = {1,-1,dots}$])
line((10.3,.7),(14.1,.7),mark:(end:"straight"),stroke:2pt)
curve-box(14.3,-.8,3,"result")
content((15.8,1.5),text(14pt)[Result])
content((15.8,.5),text(12pt)[$110 = 11 times 10$])
content((12,1.1),`extract_solution`)
}), x: 60%, y:60%, reflow: true)
The result is $p = 3$ and $q = 2$ which is the correct factors of 6. The code above shows how to reduce a factoring problem to a Spin Glass problem and solve it using the `GenericTensorNetworks` package. The `GenericTensorNetworks` package is a solver for the Ising machine and it provides a set of solvers for the Ising machine. The `SingleConfigMin` is a solver that finds the minimum energy configuration of the Ising machine. The `extract_solution` function is used to extract the solution from the result of the solver. The solution is then used to find the factors of the input number.
= CONCLUSIONS AND OUTLOOK
In this work, we have presented an efficient reduction framework to solve the factoring problem using Ising machines, with ProblemReductions.jl serving as the core tool for problem transformation. The process leverages the power of tensor networks and other optimization techniques to tackle Spin Glass problems, which can be embedded into hardware solutions. Although the reductions demonstrated are practical and adaptable, there are still limitations. For instance, the scalability of the reduction graph, leave room for improvement.
Looking forward, several directions could be explored. Firstly, for the package, the `reduction graph` could be extended to increase the robustness of the reduction system.In terms of the reduction complexity, the reduction paths and rules could be optimized to reduce the size of intermediate elements. What's more, better Ising machine solver could be employed to improve the efficiency of the solution.
= Acknowledgements
Thank the authors of the package `ProblemReductions.jl`: <NAME>, <NAME>, and <NAME> for their contributions to the package. Thank <NAME> for advices on the report writing. We acknowledge the funding support provided by Research Department of HKUST(GZ) through UGRP program.
= Appendix
#set par(
first-line-indent: 0em
)
== My Contributions to the `ProblemReductions.jl`
=== GitHub repository
#link("https://github.com/GiggleLiu/ProblemReductions.jl")[ProblemReductions.jl]
=== Activities
My contribution the the package as #link("https://github.com/c-allergic")[_c-allergic_] during the summer vacation:
- #link("https://github.com/GiggleLiu/ProblemReductions.jl/graphs/contributors")[Code Contributions]
#align(center)[#scale(figure(
image("commits.png",width:100%,),
caption: "Commits of the package ProblemReductions.jl: totally added 1694 lines of code and deleted 250 lines of code."
),x:80%,y:80%,reflow:true)]
=== Pull Requests
13 merged pull requests in total.
- #link("https://github.com/GiggleLiu/ProblemReductions.jl/pull/83")[New: PaintShop model]
- #link("https://github.com/GiggleLiu/ProblemReductions.jl/pull/81")[fix: parameters and set_parameters in Matching.jl and add tests]
- #link("https://github.com/GiggleLiu/ProblemReductions.jl/pull/79")[New: matching model]
- #link("https://github.com/GiggleLiu/ProblemReductions.jl/pull/78")[New: Maximal Independent Set]
- #link("https://github.com/GiggleLiu/ProblemReductions.jl/pull/70")[Fix: xor symbol and others bugs]
- #link("https://github.com/GiggleLiu/ProblemReductions.jl/pull/61")[Add: Reduction from SpinGlass{HyperGraph} -> MaxCut]
- #link("https://github.com/GiggleLiu/ProblemReductions.jl/pull/57")[Clean up: unnecessary type deduction]
- #link("https://github.com/GiggleLiu/ProblemReductions.jl/pull/56")[New: reduction from Sat to Coloring]
- #link("https://github.com/GiggleLiu/ProblemReductions.jl/pull/53")[New: Reduction from vertex covering to set covering]
- #link("https://github.com/GiggleLiu/ProblemReductions.jl/pull/49")[New: Vertex Covering model]
- #link("https://github.com/GiggleLiu/ProblemReductions.jl/pull/44")[New: Reduction between simple kinds of SpinGlass and MaxCut problems]
- #link("https://github.com/GiggleLiu/ProblemReductions.jl/pull/42")[New: MaxCut model]
- #link("https://github.com/GiggleLiu/ProblemReductions.jl/pull/39")[Set covering]
#pagebreak() |
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/meta/figure_02.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
// Testing show rules with figures with a simple theorem display
#show figure.where(kind: "theorem"): it => {
let name = none
if not it.caption == none {
name = [ #emph(it.caption.body)]
} else {
name = []
}
let title = none
if not it.numbering == none {
title = it.supplement
if not it.numbering == none {
title += " " + it.counter.display(it.numbering)
}
}
title = strong(title)
pad(
top: 0em, bottom: 0em,
block(
fill: green.lighten(90%),
stroke: 1pt + green,
inset: 10pt,
width: 100%,
radius: 5pt,
breakable: false,
[#title#name#h(0.1em):#h(0.2em)#it.body#v(0.5em)]
)
)
}
#set page(width: 150pt)
#figure(
$a^2 + b^2 = c^2$,
supplement: "Theorem",
kind: "theorem",
caption: "Pythagoras' theorem.",
numbering: "1",
) <fig-formula>
#figure(
$a^2 + b^2 = c^2$,
supplement: "Theorem",
kind: "theorem",
caption: "Another Pythagoras' theorem.",
numbering: none,
) <fig-formula>
#figure(
```rust
fn main() {
println!("Hello!");
}
```,
caption: [Hello world in _rust_],
)
|
https://github.com/mariunaise/HDA-Thesis | https://raw.githubusercontent.com/mariunaise/HDA-Thesis/master/charts/PUF.typ | typst | #import "@preview/fletcher:0.5.1" as fletcher: diagram, node, edge
#import fletcher.shapes: diamond
#diagram(
node-stroke: 1pt,
edge-stroke: 1pt,
//node-inset: 2pt,
node((0,0), [PUF], corner-radius: 2pt, name: <PUF>),
edge(<PUF>, <init_quant>, "->", $nu$),
node((1,0), [Initial quantization], name: <init_quant>, width: 10em),
edge(<init_quant>, <encod>, "->", $k$),
node((2,0), [Encoding], name: <encod>, width: 8em),
node((1,1), [Helper data\ generation], name: <quant_hd>, width: 10em),
edge(<init_quant>, <quant_hd>, "->"),
node((2.25, -0.5), [Enrollment], name: <enrollment_node>, stroke: none),
node(enclose: (<init_quant>, <encod>, <enrollment_node>), stroke: (dash: "dashed"), inset: 10pt),
node((0, 2), [PUF], corner-radius: 2pt, name: <PUF2>),
node((1, 2), [Repeated quantization], name: <quant2>),
node((2, 2), [Error correction], name: <ecc>),
node((3, 1), [$kappa = kappa^*$?],name: <result>),
node((2, 1), [Error correction helper data], name: <ecc_hd>, width: 8em),
node((2.25, 2.5), [Reconstruction], stroke: none, name: <reconstruction_node>),
node(enclose: (<quant2>, <ecc>, <reconstruction_node>), stroke: (dash: "dashed"), inset: 10pt),
edge(<quant_hd>, <quant2>, "->", $h$),
edge(<PUF2>, <quant2>, "->", $nu^*$),
edge(<quant2>, <ecc>, "->", $k^*$),
edge(<ecc_hd>, <ecc>, "->"),
edge(<encod>, "r,d", "->", $kappa$, label-pos: 0.3),
edge(<ecc>, "r,u", "->", $kappa^*$, label-pos: 0.4),
edge(<encod>, <ecc_hd>, "->")
)
|
|
https://github.com/hitszosa/universal-hit-thesis | https://raw.githubusercontent.com/hitszosa/universal-hit-thesis/main/harbin/bachelor/lib.typ | typst | MIT License | #import "conf.typ": doc, preface, main, ending
#import "pages/cover.typ": cover
#import "pages/abstract.typ": abstract-cn, abstract-en
#import "pages/outline.typ": outline-page
#import "pages/conclusion.typ": conclusion
#import "pages/bibliography.typ": bibliography-page
#import "pages/acknowledgement.typ": acknowledgement
#import "pages/achievement.typ": achievement
#import "config/constants.typ": special-chapter-titles
#import "pages/declaration-of-originality.typ": declaration-of-originality
#import "../../common/components/typography.typ": indent
#import "../../common/components/figure.typ": code-figure, algorithm-figure
#import "../../common/theme/type.typ": 字号, 字体 |
https://github.com/CCNU-CSIT883-Group2/Documents | https://raw.githubusercontent.com/CCNU-CSIT883-Group2/Documents/master/Templates/template.typ | typst | #import "@preview/bubble:0.2.1": *
#let group_work(tilte, body) = {
show: bubble.with(
title: "CSIT883\nSystem Analysis and Project Management",
subtitle: tilte,
author: "Group 2",
affiliation: "Wollongong Joint Institute",
date: datetime.today().display(),
class: "<NAME>, <NAME>, <NAME>, <NAME>\n<NAME>, <NAME>, <NAME>, <NAME>",
main-color: "398297",
)
set heading(numbering: (..nums) => {
let level = nums.pos().len()
let pattern = if level == 1 {
"1."
} else if level == 2 {
"1.1."
} else if level == 3 {
"1.1.1."
}
if pattern != none {
numbering(pattern, ..nums)
}
})
set text(size: 12.5pt, lang: "en")
set page(numbering: none)
show outline.entry.where(
level: 1
): it => {
v(1.5em, weak: true)
strong(it)
}
outline(indent: auto, depth: 3, fill: repeat([·]))
set page(numbering: "1 / 1")
pagebreak()
counter(page).update(1)
show figure.where(
kind: table
): set figure.caption(position: bottom)
set figure.caption(separator: auto)
show figure.caption: set text(size: 11pt)
body
}
#let individual_work(title, author, body) = {
show: bubble.with(
title: "CSIT883\nSystem Analysis and Project Management",
subtitle: title,
author: author,
affiliation: "Wollongong Joint Institute",
date: datetime.today().display(),
main-color: "398297",
)
set heading(numbering: (..nums) => {
let level = nums.pos().len()
let pattern = if level == 1 {
"1."
} else if level == 2 {
"1.1."
} else if level == 3 {
"1.1.1."
}
if pattern != none {
numbering(pattern, ..nums)
}
})
set text(size: 12.5pt, lang: "en")
set page(numbering: none)
show outline.entry.where(
level: 1
): it => {
v(1.5em, weak: true)
strong(it)
}
outline(indent: auto, depth: 3, fill: repeat([·]))
set page(numbering: "1 / 1")
pagebreak()
counter(page).update(1)
show figure.where(
kind: table
): set figure.caption(position: bottom)
show figure.where(
kind: image
): set figure.caption(position: bottom)
set figure.caption(separator: auto)
show figure.caption: set text(size: 11pt)
body
} |
|
https://github.com/taiga4112/jasnaoe_template_typst | https://raw.githubusercontent.com/taiga4112/jasnaoe_template_typst/main/main.typ | typst | #import "libs/jasnaoe-conf/jasnaoe-conf_lib.typ": jasnaoe-conf
#show: jasnaoe-conf.with()
#import "libs/jasnaoe-conf/direct_bib_lib.typ": bibliography-list, bib-item, use-bib-item-ref
#show: use-bib-item-ref.with(numbering: "1)") // 番号の書式を指定
//----------------------------------------
//以下,申込に必要な最低限の情報です.
//本文には反映されませんが,共著者間でのレビュー時に必要かと思います.
/*
論文タイトル(日本語): Typstで講演論文書こうぜ -テンプレートを勝手に作って何が悪い!!-
論文タイトル(英語): Let's write a conference paper with Typst -What's wrong with creating a template on our own!!-
著者1(名前(日本語),名前(英語), 所属(日本語), 会員種別): 造森船一, <NAME>, 造船大学校, 正会員
著者2(名前(日本語),名前(英語), 所属(日本語), 会員種別): 海尾学, <NAME>, 海洋大学, 学生会員
著者3(名前(日本語),名前(英語), 所属(日本語), 会員種別): 造田船次郎, <NAME>, 造船研究所, 学生会員
著者4(名前(日本語),名前(英語), 所属(日本語), 会員種別): 学会一, <NAME>, 日本船舶海洋工学会, 学生会員
要旨:
このテンプレートは,2024年秋季講演会以降の日本船舶海洋工学会の講演会論文作成を想定して,Typstで作成しています.
もちろん♡非公式♡のテンプレートですので,ご使用の際は自己責任でお願いします.
*/
//----------------------------------------
// ここから論文の内容を記述してください.
= 緒 言
このテンプレートは,2024年秋季講演会以降の日本船舶海洋工学会の講演会論文作成を想定して,#link("https://typst.app")[Typst]で作成しています.
もちろん♡非公式♡のテンプレートですので,ご使用の際は自己責任でお願いします.
= 執筆のための環境設定
手元のPCでTypst環境を構築する必要があります.基本的には,#link("https://typst.app")[Typst]のマニュアルを参考に構築してください.
不安な方は,README.md に記載されている手順に従ってください.
= 執筆方法
== 基本的な執筆の流れ
2024年秋季講演会から#link("https://www.jasnaoe.or.jp/lecture/2024aut/thesis.html?id=yoryo")[講演論文のテンプレートが大幅に変更]されました.
具体的には,論文タイトル,著者情報,キーワード,要旨は講演論文投稿システムで別に作成し,本文のみを記載したファイルを講演論文投稿システムに投稿することで,システム側でマージして完成するようになりました.
そのため,このテンプレートは,本文情報のみを記載することを想定しており,論文タイトル,著者情報,キーワード,要旨は記載していません.
原稿執筆の際には,このテンプレートファイルに直接打ち込んでいって下さい.
読点は「,」句点は「.」を使って下さい.
章は `=`,節は `==`,小節は `===` で始めます.
改段落は LaTeX と同じく改行を 2 つ以上挟みます.
数字つき箇条書きは `+` で,数字なしの箇条書きは `-` を文頭につけて書くことができます.
例えば,数字付きの箇条書きは
+ 1番目
+ 2番目
+ 3番目
のような感じです.
例えば,数字なしの箇条書きは
- 1番目
- 2番目
- 3番目
のような感じです.
文字組等の投稿規定を満たすように作られていますので,フォントの種類の設定や行送り,文字サイズの設定を省略することができます.
ちなみに,本文の文字サイズは9pt,行間隔は1.00emと設定してします.
その他,文法は#link("https://typst.app/docs")[Typst Documentation]をご参照ください.
いまだ,調整中のところも多いので,是非改善点などをGitHubのIssueで教えてください.
== 図
図の入れ方は#link("https://typst.app")[Typst]のドキュメントや,このテンプレートファイルを参考にしてください.
図のタイトルは @fig:fig_example のように図の下部につけてください.
図の表題(caption)は英語で書きます.
また,表題の最後にはピリオドを付けて下さい.
また,図は原則として英語表記としてください.
日本語もしくはその他の言語の表記が必要な場合は,英語との併記としてください.
文字・記号等は十分に判読できる大きさとしてください.
ここで placement 属性は,自動 (`auto`) だけでなく,紙面の上 (`top`) に寄せるか下 (`bottom`) に寄せるかを決められます.言及している文章に近い方に調整してください.また,どうしても対象の文章と図が離れてしまうのが嫌な場合,固定 (`none`) を指定してください.
#figure(
placement: auto, // top, bottom, auto, none
image("figs/example.svg", width: 100%),
caption: [Example of a figure.],
) <fig:fig_example>
== 表
表の入れ方は#link("https://typst.app")[Typst]のドキュメントや,このテンプレートファイルを参考にしてください.
表は,@tab:table_example のように表形式で記述します.
表題(caption)は表の上に書きます.
表の表題(caption)は英語で書きます.
また,表題の最後にはピリオドを付けて下さい.
また,表も原則として英語表記としてください.
ここで placement 属性は,自動 (`auto`) だけでなく,紙面の上 (`top`) に寄せるか下 (`bottom`) に寄せるかを決められます.また,どうしても対象の文章と表が離れてしまうのが嫌な場合,固定 (`none`) を指定してください.
必要に応じて,言及している文章に近い方に調整してください.
#figure(
placement: none, // top, bottom, auto, none
caption: [Example of a table.],
table(
columns: 4,
stroke: (x: none),
table.header(
[*Margins*],
[...],
[*Left Column*],
[*Right Column*],
),
row-gutter: (2.2pt, auto),
[Top], [...], [27 mm], [27 mm],
[Left], [...], [16 mm], [107.5 mm],
[Right], [...], [100 mm], [191.5 mm],
[Bottom], [...], [275 mm], [275 mm],
)
) <tab:table_example>
== 数式
数式番号をつけるような中央揃えの数式は,最初の`$` と閉じの`$`の中に記載してください.
数式の書き方はTypstのドキュメントを参照してください.
例えば,@eq:mmg_example のように記述してください.
$
m(dot(u)-v r) &=-m_x dot(u)+m_y v r+X_H+X_P+X_R \
m(dot(v)+u r) &=-m_y dot(v)+m_x u r+Y_H+Y_R \
I_(z G) dot(r) &=-J_Z dot(r)+N_H+N_R
$ <eq:mmg_example>
また,文中に書く数式は,例えば,$n_i = sum_(i=1)^(N)(f(r_(i j)))$のように記述してください.
== 特殊な章
謝辞と参考文献は他の章とは異なり,章番号が自動でつかないように設定しています.
== 参考文献
参考文献は このファイルの`#bibliography-list` に直接記載してください.
参考文献の書き方は,このテンプレートファイルを参考にしてください.
参考文献は英語表記としてください.
英語等(フランス語,ドイツ語その他アルファベットで表される言語) 以外の文献の場合,文献に英語等のタイトルがある場合はそれを記載し,無い場合は英訳と原語の併記としてください.
併記の場合は,改行コードである 「`\`」 を使ってください.
著者名:論文タイトル,掲載論文名,巻・号番号,ページ番号,発行年を書き,最後にピリオドを付けます.
引用の方法については後述します.
引用されていない論文を参考文献に記載するのは,推奨されていません.
提出前に引用されているかを必ず確認してください.
== 引用
参考文献に記載したものを引用する際には この #super[@ichinose_method_2022] ように表示されます.
参考文献は連続して引用すると #super[@ichinose_method_2022 @ichinose_sustainable_2022 @okuboStudyPracticalApplication2023] となります.
引用の際には,`@` の後に参考文献のキーを記載してください.
現時点では、#link("https://typst.app/docs/reference/model/bibliography/")[TypstのBibliograpy機能]を使って、 MendelelyやZoteroなどの文献管理ソフトから.bibファイルをエクスポートして、そのファイルを利用して参考文献リストを作る方法をスタンダートとして定義しています.
ただし,日本語英語併記には対応していません.日本語英語併記に対応する場合は,参考文献を直接定義する方法を採用してください.
このファイルの末尾に直接定義する方法の例を記載しています.
= おわりに
論文の最後には結論を書きます.
箇条書きスタイルを使うなどして,分かり易く,コンパクトに書いて下さい.
結論を先に読むという読者も居ますので,分かり易く,何が研究されて,新しく何が分かったのかなどを書きます.
= 謝 辞
謝辞が必要なときは,結論の次に書きます.章番号は付けませんが,「謝辞」の表題はセンタリングをして下さい.
// --------------------------------------------------
// 参考文献
// --------------------------------------------------
// 他の.bibファイルを読み込む場合はこの行を使ってください
// ただし,現時点では公式フォーマットで定められている英語日本語の併記には対応できていません
#bibliography("references.bib",
title: "参 考 文 献",
style: "libs/jasnaoe-conf/jasnaoe-reference.csl",
)
// --------------------------------------------------
// // 直接定義する場合はこのコードを編集してください
// #bibliography-list(
// title: "参 考 文 献", // 参考文献の章のタイトル
// )[
// #bib-item(<format-en-journal>)[
// Family names and initials of all authors: Title of the paper, _abbreviated title of the journal (or conference proceedings),_ number of the volume, number of the issue, numbers of the first and last pages, and year of publication.
// ]
// #bib-item(<MakiStochastic2023>)[
// <NAME>., <NAME>., <NAME> al.: Stochastic stabilization and destabilization of ship maneuvering motion by multiplicative noise, _Journal of Marine Science and Technology_, 28, 704–718, 2023.
// ]
// #bib-item(<OkuboProduction2023>)[
// <NAME>., <NAME>.: Study of the practical application of production planning method using shipbuilding process simulation, _Journal of the Japan Society of Naval Architects and Ocean Engineers_, 37, 115-123, 2023 (in Japanese). \
// 大久保友結,満行泰河:船舶建造工程シミュレーションを用いた生産計画立案手法の現場適用に関する研究, _日本船舶海洋工学会論文集_, 37, 115-123, 2023.
// ]
// #bib-item(<YamamotoStructure1986>)[
// <NAME>., <NAME>., <NAME>., and <NAME>.: Ship Structural Mechanics, Seizando-Shoten Publishing Co., Ltd., 1986 (in Japanese). \
// 山本善之,大坪英臣, 角洋一,藤野正隆:船体構造力学,_成山堂書店_,1986.
// ]
// ]
// -------------------------------------------------- |
|
https://github.com/MilanR312/ugent_typst_template | https://raw.githubusercontent.com/MilanR312/ugent_typst_template/main/template/methods/introduction.typ | typst | MIT License | #let introduction(body) = {
set par(leading: 0.5em)
align(
block(
align(
left,
[_#(body)_]
),
width: 70%
),
center
)
}
|
https://github.com/Vaskozlov/Lectures | https://raw.githubusercontent.com/Vaskozlov/Lectures/main/Теория графов.typ | typst | #set text(lang: "ru")
= Теория графов
== Определения
$E_(G)(X, Y)$ множество, состоящее из таких ребер $e in E(G)$,
что $e = x y, x in X, y in Y$
$N_(G)(v)$ – окрестность вершины $v$ (множество всех вершин смежных с $v$)
$N'_(G)(U)$ – множество всех вершин графа смежных со всеми вершинами множества U
$N_(G)(U) = N'_(G)(U) \\ U $
$d_(G)(x)$ – количество ребер графа инцидентных вершине x
$delta(G)$ – минимальная степень вершины в графе G
$Delta(G)$ – максимальная степень вершины в графе G
Граф G называют регулярным, если степени всех его вершин одинаковы
=== Подграф
Подграф H графа G называется остовным, если $V(H) = V(G)$
$U subset V(G)$ через $G(U)$ мы обозначим индуцированные подграф на множестве вершин $U$. Это означает, что $V(G(U)) = U$, а $E(G(U))$ состоит из всех ребер множества E(G), обо конца которых лежат в $U$.
Индуцированные подграф - это другой граф, который образуется из подмножества вершин исходного графа и всех ребер, соединяющих пары вершин в этом множестве.
=== Маршрут и путь
Маршрут – последовательность вершин и ребер графа G, где $e_i = a_i a_(i + 1)$
Путь - это маршрут, не проходящий ни по какому ребру дважды. Более того, путь - подграф графа G, состоящий из вершин и ребер, по которым этот путь проходит
Путь называется простым, если все его вершины различны.
Внутренность $"Int"(P)$ - это множество всех его вершин, отличных от начала и конца этого пути.
Расстояние между вершинами x и y графа G называется наименьшая длина xy-пути. Обозначение $"dist"_(G)(x, y)$.
=== Цикл
Цикл - это последовательность вершин и различных ребер графа G, где $e_i = a_i a_(i + 1)$ для всех $i in [1..n]$ (мы считаем, что $a_(n + i) = a_i$).
Цикл называется простым, если все его вершины различны.
Длина цикл - количество его ребер.
Пусть C - простой цикл, а x, y - две его несоседние вершины.
- Вершины x и y делят цикл C на два пути с концами x и y, которые мы будем называть дугами.
- Если $"xy" in E(G)$, назовем ребро xy хордой или (что, то же самое) диагональю цикла C.
Индуцированный цикл графа G - это простой цикл, не имеющий диагоналей.
=== Компоненты связанности
Вершины a и b графа G называют связанными, если в графе существует путь между ними.
Граф называется связным, если любые две его вершины связанны.
Компоненты связанности графа G - максимальные (по включению) связанные множества вершин. Через $c(G)$ обозначим их количество.
Будем называть компонентами графа G подграфы, индуцированные на его компонентах связанности.
#align(center)[
#figure(
image("images/Пример графа с компонентами связнности.png", width: 20%),
caption: [Граф G, $c(G) = 3$]
)
]
=== Дерево и лес
Дерево - это связанный граф без циклов.
Лес - это граф без циклов. Все компоненты леса - деревья.
Вершина x графа G, имеющая степень 1, называется висячей вершиной или листом.
#pagebreak()
== Теоремы и леммы
=== Общие
$ sum_(v in V(G))d_(G)(v) = 2e(G) $
=== Циклы
Для любого циклы $Z$ существует такой простой цикл $Z'$, что $V(Z') subset V(Z)$ и $E(Z') subset E(Z)$
Если в графе есть нечетный цикл, то есть и простой нечетный цикл.
Из xy-пути можно выделить простой xy-путь.
=== Дерево
В дереве с n вершинами n - 1 ребро.
У любого связанного графа существует основное дерево.
Граф G является деревом, если и только если для любых двух вершин существует единственный простой путь, соединяющий их. |
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/visualize/gradient-math_08.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
// Test conic gradient
#show math.equation: set text(fill: gradient.conic(red, blue, angle: 45deg))
#show math.equation: box
$ A = mat(
1, 2, 3;
4, 5, 6;
7, 8, 9
) $
|
https://github.com/songoffireandice03/simple-template | https://raw.githubusercontent.com/songoffireandice03/simple-template/main/templates/abbreviations.typ | typst | #let spnset = "spaninng set"
#let ref = "row-echelon form"
#let wrt = "with resepct to"
#let box2 = box
#let speca = "specific heat capcity"
#let heca = "heat capcity"
#let ene = "energy"
#let diff = "difference"
#let diffs = "differences"
#let tempe = "temperature"
#let tempes = "temperatures"
#let deri = "derivative"
#let deris = "derivatives"
#let vars = "variables"
#let var = "variable"
#let cord = "coordinate"
#let cords = "coordinates"
#let contra = "contradiction"
#let contras = "contradiction"
#let eival = "eigenvalue"
#let eivt = "eigenvector"
#let eivals = "eigenvalues"
#let eivts = "eigenvectors"
#let supp = "suppose"
#let Supp = "Suppose"
#let hypo = "hypothesis"
#let magflux = "magentic flux"
#let cw = "clockwise"
#let ccw = "counterclockwise"
#let moi = "moment of inertia"
#let com = "center of mass"
#let cog = "center of gravity"
#let elpoten = "elastic potential energy"
#let poten = "potential energy"
#let grapoten = "gravitational potential energy"
#let gren = "gravitational energy"
#let magfield = "magnetic field"
#let magfields = "magnetic fields"
#let inj = "injective"
#let surj = "surjective"
#let bij = "bijective"
#let cayham = "Cayley-Hamilton theorem"
#let charpol = "characteristic polynomial"
#let pol = "polynomial"
#let pols = "polynomials"
#let pst = "Problem Solving Tactics"
#let putnam = "<NAME>"
#let ela = "Essential Linear Algebra"
#let upmp = "University Physics with Modern Physics"
#let tao1 = "Analysis I"
#let tao2 = "Analysis II"
#let hrk4 = "Physics, 4th Edition"
#let hrk5 = "Physics, 5th Edition"
#let egmo = "Euclidean Geometry in Mathematical Olymipads"
#let pss = "Problem Solving Strategies"
#let liog = "Lemmas in Olympiad Geometry"
#let irodov1 = "Problems in General Physics"
#let irodov2 = "Fundamental Laws of Mechanics"
#let irodov3 = "Basic Laws of Magnetism"
#let cacc = "Calculus: A Complete Course"
#let napkin = "An Infinite Napkin"
#let morin1 = "Introduction to Classical Mechanics with Problems and Solutions"
#let purcell = "Electricity and Magnetism"
#let psim = "Problems and Solutions in Introductory Mechanics"
#let probmorin = "Probability for the Enthusiastic Beginner"
#let hrk4 = "Physics, 4th Edition"
#let hrk5 = "Physics, 5th Edition"
#let hrw10 = "Fundamentals of Physics, 10th Edition"
#let ladr = "Linear Algebra Done Right"
#let stewart = "Calculus: Early Transcendentals"
#let ineq = "inequality"
#let Ineq = "Inequality"
#let eq = "equality"
#let eqs = "equalities"
#let Eq = "Equality"
#let Eqs = "Equalities"
#let ineqs = "inequalities"
#let ineqs = "Inequalities"
#let cauchy = "Cauchy-Schwarz inequality"
#let rein = "rearragnement inequality"
#let jensen = "Jensen's inequality"
#let sati = "satisfying"
#let amgm = "AM-GM inequality"
#let dia = "diagonal"
#let adia = "antidiagonal"
#let mt = "matrix"
#let mts = "matrices"
#let difable = "differerentiable"
#let inble = "invertible"
#let sol = "solution"
#let unsol = "unique solution"
#let trivsol = "trivial solution"
#let sols = "solutions"
#let unsols = "unique solutions"
#let linsys = "linear system"
#let trivsols = "trivial solutions"
#let poly = "polynomial"
#let polys = "polynomials"
#let kronpro = "Kronecker product"
#let orth = "orthogonal"
#let sym = "symmetric"
#let sksym = "skew-symmetric"
#let ansym = "antisymmetric"
#let perm = "permutation"
#let perms = "permutations"
#let permt = "permutation matrix"
#let permts = "permutation matrices"
#let uptri = "upper-triangular"
#let lowtri = "lower-triangular"
#let iff = "if and only if"
#let WLOG = "Without loss of generality"
#let wlog = "without loss of generality"
#let rhs = "right hand side"
#let lhs = "left hand side"
#let vt = "vector"
#let vts = "vectors"
#let vsp = "vector space"
#let vsps = "vector spaces"
#let sbsp = "subspace"
#let disum = "direct sum"
#let disums = "direct sums"
#let Lincom = "Linear combination"
#let Lincoms = "Linear combinations"
#let fn = "function"
#let fns = "functions"
#let comu = "commutative"
#let asso = "associative"
#let comut = "commutativity"
#let assot = "associativity"
#let lincom = "linear combination"
#let lincoms = "linear combinations"
#let indep = "linearly independent"
#let dep = "linearly dependent"
#let Indep = "Linearly independent"
#let ba = "basis"
#let Dep = "Linearly dependent"
#let defi = "definition"
#let ax = "axiom"
#let the = "theorem"
#let lem = "lemma"
#let Fn = "Function"
#let Fns = "Functions"
#let pro = "proposition"
#let proj = "projection"
#let Pro = "Proposition"
#let Defi = "Definition"
#let Ax = "Axiom"
#let The = "Theorem"
#let Lem = "Lemma"
#let sset = "subset"
#let ssets = "subsets"
#let un = "union"
#let scamu = "scalar multiplication"
#let scam = "scalar multiple"
#let scams = "scalar multiples"
#let sbsps = "subspaces"
#let Sbsps = "Subspaces"
#let Sbsp = "Subspace"
#let adid = "additive identity"
#let posi = "positive"
#let nega = "negative"
#let adi = "addition"
#let muli = "multiplication"
#let lid = "linear dependence lemma"
#let dime = "dimension"
#let Dime = "Dimension"
#let findem = "finite-dimensional"
#let indem = "infinite-dimensional"
#let int = "integer"
#let Fibo = "Fibonacci"
#let isect = "intersect"
#let istion = "intersection"
#let isects = "intersects"
#let istions = "intersections"
#let tri = "triangle"
#let tris = "triangles"
#let Tri = "Triangle"
#let Tris = "Triangles"
#let st = "such that"
#let mp = "midpoint"
#let radax = "radical axis"
#let circir = "circumcircle"
#let cirrad = "circumradius"
#let quadi = "quadilateral"
#let quadis = "quadilaterals"
#let cyc4 = "cyclic quadilateral"
#let cyc4s = "cyclic quadilaterals"
#let Cyc4 = "Cyclic quadilateral"
#let Cyc4s = "Cyclic quadilaterals"
#let dne = "does not exist"
#let dnes = "do not exist"
#let cont = "continuous"
#let discont = "discontinuous"
#let conty = "continuity"
#let disconty = "discontinuity"
#let Cont = "Continuous"
#let Discont = "discontinuous"
#let Conty = "Continuity"
#let Disconty = "Discontinuity"
#let orcen = "orthocenter"
#let Orcen = "Orthocenter"
#let incen = "incenter"
#let Incen = "Incenter"
#let excen = "excenter"
#let Excen = "Excenter"
#let colin = "colinear"
#let limp = "linear map"
#let limps = "linear maps"
#let lintran = "linear transformation"
#let lin = "linear"
#let lintrans = "linear transformations"
#let diran = "directed angle"
#let dirans = "directed angles"
#let resp = "respectively"
#let drn = "direction"
#let drns = "directions"
#let eqns = "equations"
#let eqn = "equation"
#let pos = "position"
#let Pos = "Position"
#let poss = "positions"
#let Poss = "Positions"
#let coeff = "coefficient"
#let coeffs = "coefficients"
#let cosf = "coefficient of static friction"
#let acel = "acceleration"
#let acels = "accelerations"
#let wet = "work-energy theorem"
#let ppn = "perpendicular"
#let ppns = "perpendiculars"
#let dimal = "dimensional"
#let EMWs = "electromagnetic waves"
#let EMW = "electromagnetic wave"
#let emg = "electromagnetic"
// Other commands |
|
https://github.com/swablab/documents | https://raw.githubusercontent.com/swablab/documents/main/templates/tmpl_letter.typ | typst | Creative Commons Zero v1.0 Universal | #import "tmpl_page.typ": tmpl_page
#import "common.typ": colors
#let tmpl_letter(
title: none,
address: none,
info: none,
footer: none,
doc,
) = {
show: doc => tmpl_page(
title: title,
version: "",
change_date: "",
doc,
)
// DIN 5008 Sichtfenster: 45mm
place(
top+left,
dx: 7mm,
dy: 25mm,
)[
#text(size: 0.75em)[
#underline[swablab e.V. - Katharinenstr. 1 - 72250 Freudenstadt]
]
#address
]
// DIN 5008 Faltmarke 1: 87mm
place(
top+left,
dy: 67mm,
dx: -1cm,
line(
length: -1em,
stroke: 0.5pt + colors.subtext
)
)
// DIN 5008 Faltmarke 2: 192mm
place(
top+left,
dy: 172mm,
dx: -1cm,
line(
length: -1em,
stroke: 0.5pt + colors.subtext
)
)
// DIN 5008 Informationsblock: 50mm
place(
top+right,
dy: 30mm,
)[
#v(1em)
#info
]
// DIN 5008 nach Faltmarke 1
place(
top+left,
dy: 67mm,
doc
)
// Footer
place(bottom+left)[
#footer
#text(size: 0.7em, fill: colors.subtext)[
#table(
stroke: none,
align: top+left,
columns: (1fr,1fr,auto,1fr,1fr),
[*Telefon*],[*E-Mail / Web*],[*Bankverbindung*],[*Vereinsregister*],[*Vorstand*],
[
+49 15679232971
],
[
<EMAIL> \
https://swablab.de
],
[
VR-Bank Dornstetten-Horb \
DE12 6426 2408 0125 6340 05
],
[
VR 724909 \
Amtsgericht Stuttgart
],
[
<NAME> \
<NAME>
],
)
]
]
} |
https://github.com/jomaway/typst-teacher-templates | https://raw.githubusercontent.com/jomaway/typst-teacher-templates/main/ttt-utils/lib/assignments.typ | typst | MIT License | #import "components.typ": point-tag, checkbox, caro, lines as _lines
#import "helpers.typ": if-auto-then
#import "random.typ": shuffle
// States
#let _solution = state("ttt-solution", false);
#let _answer_field = state("ttt-auto-field", _lines(2))
/// wrapper for updating the `_answer_field` state
///
/// - field (content): Content to be shown if @answer field parameter is `auto`
/// -> content (state-update)
#let set-default-answer-field(field) = _answer_field.update(field)
// Counters
#let _question_counter = counter("ttt-question-counter");
/// Wrapper to reset the `_question_counter` back to zero
#let reset-question-counter() = { _question_counter.update(0) }
// Labels
#let _question_label = label("ttt-question-label")
/// Add the current assignment number
///
/// - style (string): style of the number gets passed to typst `numbering` function. default: "1."
/// -> content
#let a-nr(style: "1.") = context numbering(style, _question_counter.get().first())
/// Add the current question number
///
/// - style (string): style of the number gets passed to typst `numbering` function. default: "a)"
/// -> content
#let q-nr(style: "a)") = context numbering(style, _question_counter.get().last())
/// the assignment environment state
/// should contain `none` or an `integer` with the current assignment number
#let _assignment_env = state("ttt-assignment-state", none)
/// Starts a new assignment environment.
/// All following questions will be grouped into this assignment until a `end-assignment` statement occurs.
#let new-assignment = {
_question_counter.step(level: 1)
context _assignment_env.update(_question_counter.get().first())
}
/// Ends the assignment environment.
/// All following questions will be treated as stand alone questions.
#let end-assignment = _assignment_env.update(none)
/// Wrapper to check if the assignment environment is active.
#let is-assignment() = {
_assignment_env.get() != none
}
/// Add an assignment environment.
/// By default this adds the current assignment number up front.
///
/// Example:
///
/// ```typ
/// #assignment [
/// Answer the questions
///
/// #question[This will be question a)]
/// #question[This will be question b)]
/// ]
/// ```
/// - body (content): the content to be displayed for this assignment
/// - number (string, none): if none no number will be displayed otherwise the string gets passed to typst `numbering` function.
/// -> content
#let assignment(body, number: "1.") = {
new-assignment
if (number != none and number != "hide") { a-nr(style: number) }
body
end-assignment
}
/// Add a question and some metadata to your document.
///
/// This function will just render the given body and store the points as metadata inside the document.
/// You mostly want to use the higher level `question` function.
///
/// - body (content): the content to be displayed for this assignment
/// - points (int): the given points for a correct answer of this question. Will be stored as metadata.
/// -> content
#let _question(body, points: none) = {
if points != none {
assert.eq(type(points), int, message: "expected points argument to be an integer, found " + type(points))
}
context {
let level = if is-assignment() { 2 } else { 1 }
_question_counter.step(level: level)
// note: metadata must be a new context to fetch the updated _question_counter value correct
context [#metadata((type: "ttt-question", num: _question_counter.get() ,points: points, level: level)) #_question_label]
}
body
}
/// Add a question with number and point-tag to your document.
///
/// This function adds the current question number up front and a `point-tag` on the right side.
/// If you just want the plain question to render use the low level `_question` function.
///
/// Example:
///
/// ```typ
/// #question(points: 2)[What is the result of $1 + 1$ ?]
/// ```
/// - body (content): the content to be displayed for this assignment
/// - points (int): the given points for a correct answer of this question. Will be stored as metadata.
/// - number (string, none): if none no number will be displayed otherwise the string gets passed to typst `numbering` function.
/// -> content
#let question(body, points: none, number: auto) = {
grid(
columns: (1fr, auto),
column-gutter: 0.5em,
_question(points: points)[
#context q-nr(style: if-auto-then(number, { if is-assignment() { "a)" } else { "1." } }))
#body
],
if points != none {
place(end, dx: 1cm,point-tag(points))
}
)
}
/// A stack with multiple options and a checkbox upfront.
///
/// - distractors (array): all wrong choices
/// - answer (array, string, integer): one or multiple correct choices.
/// - dir (direction): direction of the options. Get's passed to typst `stack` function.
/// -> content
#let _multiple-choice(distractors: (), answer: (), dir: ttb) = {
let answers = if (type(answer) == array ) { answer } else { (answer,) }
let choices = (..distractors, ..answers)
choices = shuffle(choices).map(choice => {
box(inset:(x:0.5em))[
#context {
let is-solution = _solution.get() and choice in answers
checkbox(fill: if is-solution { red }, tick: is-solution )
}
]; choice
})
stack(dir:dir, spacing: 1em, ..choices)
}
/// A multiple or single choice question.
///
/// The checkbox of an answer will be filled red and ticked if solution-mode is set to true.
///
/// - ..args (arguments): only looking for prompt, distractors, answer and hint.
/// -> content
#let multiple-choice(..args, dir: ttb) = {
// assertions
let data = args.named()
assert(type(data) == dictionary, message: "expected data to be a dictionary, found " + type(data))
let keys = data.keys()
assert("prompt" in keys, message: "could not find prompt in keys");
assert("distractors" in keys, message: "could not find distractors in keys");
assert("answer" in keys, message: "could not find answer in keys");
// create output
block(breakable: false,
question(points: if (type(data.answer) == array) { data.answer.len() } else { 1 })[
#data.prompt
#_multiple-choice(
distractors: data.distractors,
answer: data.answer,
dir: dir //if data.at("dir", default: none) != none { data.at("dir") } else { ttb }
)
// show hint if available.
#if ("hint" in data.keys()) {
strong(delta: -100)[Hint: #data.at("hint", default: none)]
}
]
)
}
// -----------------
// Solution methods
// -----------------
/// Wrapper to set solution-mode to true
#let show-solutions = { _solution.update(true) }
/// Wrapper to set solution-mode to false
#let hide-solutions = { _solution.update(false) }
/// Wrapper to get the current value of the _solution state
/// ! needs context
/// -> bool
#let is-solution-mode() = {
_solution.get()
}
/// Sets the solution to a defined state.
///
/// - value (bool): the solution state
/// -> content
#let set-solution-mode(value) = {
assert.eq(type(value), bool, message: "expected bool, found " + type(value))
_solution.update(value)
}
/// Sets whether solutions are shown for a particular part of the document.
///
/// - solution (bool): the solution state to apply for the body
/// - body (content): the content to show
/// -> content
#let with-solution(solution, body) = context {
assert.eq(type(value), bool, message: "expected bool, found " + type(value))
let orig-solution = _solution.get()
_solution.update(solution)
body
_solution.update(orig-solution)
}
/// An answer field which is only shown if solution-mode is false.
///
/// - body (content): the content to show
/// -> content
#let answer-field(body) = {
context {
if not is-solution-mode() { body }
}
}
/// An answer to a question which is only shown if solution-mode is true.
///
/// - body (content): the content to show
/// - color (color): text color of the answer. default: red
/// - field (auto, content): some content which is shown if solution-mode is off. default: `_answer_field` state value
/// -> content
#let answer(body, color: red, field: auto) = {
answer-field(context if-auto-then(field, _answer_field.get()))
context {
if is-solution-mode() {
set text(fill: color)
body
}
}
}
// ---------
// Queries
// ---------
/// Fetch the metadata of the last defined question
///
/// -> dictionary
#let current-question() = { query(selector(_question_label).before(here())).last().value }
/// Fetch the metadata of all questions in the document.
///
/// - filter (function): a filter which is applied before returning
/// -> dictionary
#let get-questions(filter: none) = {
let all-questions = query(_question_label).map(m => m.value)
if filter != none {
all-questions.filter(filter)
} else {
all-questions
}
}
|
https://github.com/frosty884/vex-typst-notebook | https://raw.githubusercontent.com/frosty884/vex-typst-notebook/main/README.md | markdown | # vex-typst-notebook
This repository contains an open source VEX Robotics notebook template for use with the [Typst](https://typst.app/) note-taking app.
## Getting Started
To use this template, you'll need to have Typst installed on your device. You can use Typst from their [website](https://typst.app/) or install the [Typst LSP extension](https://marketplace.visualstudio.com/items?itemName=typst.typst-lsp) for Visual Studio Code.
Once you have Typst installed, follow these steps to use the VEX Robotics notebook template:
1. Clone or download this repository to your device.
2. Open folder in Visual Studio Code.
3. Use two side by side windows, one with main.typ or template.typ, and one with main.pdf
4. Save main.typ, and main.pdf will automatically compile with any updates made.
That's it! You can now start using the VEX Robotics notebook template in Typst.
## Contributing
We welcome contributions to this template! If you have suggestions or improvements, please feel free to submit a pull request or open an issue on our [GitHub repository](https://github.com/frosty884/vex-typst-notebook). You can also check out the [Typst GitHub repository](https://github.com/typst/typst) for more information and resources.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
https://github.com/mitex-rs/mitex | https://raw.githubusercontent.com/mitex-rs/mitex/main/docs/spec.typ | typst | Apache License 2.0 |
#import "pageless.typ": *
// Take a look at the file `template.typ` in the file panel
// to customize this template and discover how it works.
#show: project.with(
title: "MiTeX Draft",
authors: (
"OrangeX4",
"<NAME>",
),
)
// #let pmat = math.mat.with(delim: "(")
// #let tt(..args) = repr(args)
// $tt(1, 2; 3, 4)$
#let mitex = [*MiTeX*]
= APIs of #mitex
== Compile Specification
```typst
#let command-fn(num, dir: "right", has-optional: false) = (
assosication-dir: dir,
shape: (
"fixed-len",
num,
),
)
#let symbol(alias: none) = (
alias: alias,
)
#let compile-spec(spec: none, inherit: true) = (..);
#let spec = mitex.compile-spec((
// regular command
hat: command-fn(1),
// left associated
limits: command-fn(1, dir: "left"),
// symbol
prod: symbol("product"),
// environment
pmatrix: env(0,
ctx: (mitex.matrix-like-ctx, ),
handle: math.mat.with(delim: "("),
)
));
spec: #repr(spec)
```
It produces:
#align(center)[
spec: (opaque: bytes(4712), extra-scope: (pmatrix: #repr(() => ())))
]
== Convert LaTeX equation to Typst equation
=== Into String
```typst
#let mitex-convert(input, spec: none) = (..);
#repr(mitex-convert("\alpha x"))
```
It produces:
#align(center)[
#repr("alpha x ")
]
=== Into Content
```typst
#let mitex(input, spec: none) = (..);
#mitex("\alpha x")
```
It produces:
#align(center)[
$ alpha x $
]
= Specification of LaTeX Commands (for developers)
// todo: translate Rust code descriptions to natural language
Define how a user specifies commands in Typst for #mitex. Mitex is aware of a special case of command, environment, which is in shape of `\begin{e}...\end{e}`.
The specification is structured as following in Rust:
```rs
/// An item of command specification. It is either a normal _command_ or an
/// _environment_.
/// See [Command Syntax] for concept of _command_.
/// See [Environment Syntax] for concept of _environment_.
///
/// [Command Syntax]: https://latexref.xyz/LaTeX-command-syntax.html
/// [Environment Syntax]: https://latexref.xyz/Environment-syntax.html
pub enum CommandSpecItem {
Cmd(CmdShape),
Env(EnvShape),
}
/// Command specification that contains a set of commands and environments.
pub struct CommandSpecRepr {
/// A map from command name to command specification
pub commands: fxhash::FxHashMap<String, CommandSpecItem>,
}
```
The specification will be passed to #mitex for converting LaTeX code correctly. For example, #mitex Parser uses it to produce an AST that respect the shape of commands.
Note: since we need to process environments statically, users cannot override the `\begin` and `\end` commands.
```rust
pub struct CmdShape {
/// Describes how we could match the arguments of a command item.
pub args: ArgShape,
/// Makes the command alias to some Typst handler.
/// For exmaple, alias `\prod` to Typst's `product`
pub alias: Option<String>,
}
pub struct EnvShape {
/// Describes how we could match the arguments of an environment item.
pub args: ArgPattern,
/// Specifies how we could process items before passing them
/// to the Typst handler
pub ctx_feature: ContextFeature,
/// Makes the command alias to some Typst handler.
/// For exmaple, alias `\pmatrix` to a Typst function `pmat` in scope.
pub alias: Option<String>,
}
/// An efficient pattern used for argument matching.
///
/// There are four kinds of pattern. The most powerful one is
/// [`ArgPattern::Glob`], which matches an sequence of input as arguments. Among
/// these four kinds, [`ArgPattern::Glob`] can already match all possible inputs
/// in our use cases. But one should specify a fixed length pattern
/// ([`ArgPattern::FixedLenTerm`]), a range length pattern
/// ([`ArgPattern::RangeLenTerm`]), or a greedy pattern
/// ([`ArgPattern::Greedy`]) to achieve better performance.
///
/// Let us look at usage of a glob pattern by \sqrt, which is `{,b}t`.
///
/// - Example 1. For `\sqrt{2}{3}`, parser requires the pattern to match with an
/// encoded string `tt`. Here, `{,b}t` matches and yields the string `t`
/// (which corresponds to `{2}`).
///
/// - Example 2. For `\sqrt[1]{2}{2}`, parser requires the pattern to match with
/// an encoded string `btt`. Here, `{,b}t` matches and yields the string `bt`
/// (which corresponds to `[1]{2}`).
///
/// Kinds of item to match:
/// - Bracket/b: []
/// - Parenthesis/p: ()
/// - Term/t: any remaining terms, typically {} or a single char
///
/// Note: any prefix of the argument pattern are matched during the parse stage,
/// so you need to check whether it is complete in later stages.
pub enum ArgPattern {
/// No arguments are passed, i.e. this is processed as a variable in Typst.
///
/// E.g. `\alpha` => `$alpha$`, where `\alpha` has an argument pattern of
/// `None`
None,
/// Fixed length pattern, equivalent to repeat `{,t}` for `x` times
///
/// E.g. `\hat x y` => `$hat(x) y$`, where `\hat` has an argument pattern of
/// `FixedLenTerm(1)`
///
/// E.g. `1 \sum\limits` => `$1 limits(sum)$`, where `\limits` has an
/// argument pattern of `FixedLenTerm(1)`
FixedLenTerm(u8),
/// Range length pattern (matches as much as possible), equivalent to
/// repeat `t` for `x` times, then repeat `{,t}` for `y` times.
///
/// No example
RangeLenTerm(u8, u8),
/// Receives any items as much as possible, equivalent to `*`.
///
/// E.g. \over, \displaystyle
Greedy,
/// The most powerful pattern, but slightly slow.
/// Note that the glob must accept the whole prefix of the input.
///
/// E.g. \sqrt has a glob argument pattern of `{,b}t`
///
/// Description of the glob pattern:
/// - {,b}: first, it matches a bracket option, e.g. `\sqrt[3]`
/// - t: it then matches a single term, e.g. `\sqrt[3]{a}` or `\sqrt{a}`
Glob(Arc<str>),
}
/// Shape of arguments
/// With direction to match since
/// Note: We currently only support
/// - `Direction::Right` with any `ArgPattern`
/// - `Direction::Left` with `ArgPattern::FixedLenTerm(1)`
/// - `Direction::Infix` with `ArgPattern::Greedy`
pub enum ArgShape {
/// A command that associates with the right side of items.
///
/// E.g. `\hat`
Right(ArgPattern),
/// A command that associates with the left side of items, and with
/// `ArgPattern::FixedLenTerm(1)`.
///
/// E.g. `\limits`
Left1,
/// A command that associates with both side of items, and with
/// `ArgPattern::Greedy`, also known as infix operators.
///
/// E.g. `\over`
InfixGreedy,
}
pub enum ContextFeature {
/// No special feature
None,
/// Parse content like mat arguments
IsMatrix,
/// Parse content like cases
IsCases,
}
```
Sample ASTs:
#let cc0 = counter("sample")
#let sample-counter() = {
cc0.step()
cc0.display()
}
Sample #sample-counter():
```tex
\frac{ a }{ b }␠
```
```coffee
Command(
CommandName("frac"),
Argument(Curly(Space(" "), Word("a"), Space(" "))),
Argument(Curly(Space(" "), Word("b"), Space(" "))),
),
```
Sample #sample-counter():
Special direction of association are processed:
```tex
\sum\limits _x f(x)␠
```
```coffee
AttachItem(
Item(Command(
CommandName("limits"),
Argument(Command(CommandName("sum")))
)),
Bottom(Word("x"))
),
Word("f"),
# used for paren escaping (a special case in typst)
Paren(Word("x")),
```
Sample #sample-counter():
Spaces are not omitted. This is useful for processing `\text`.
```tex
\frac 1 2 ␠
```
```coffee
Command(
CommandName("frac"),
Argument(Word("1")),
Argument(Word("2")),
),
Space(" "),
```
Sample #sample-counter():
Attached items are identified.
```tex
x_1''^2␠
```
```coffee
AttachItem(
Item(Word("x")),
Superscript(Word("'"), Word("'"), Word("2")),
Subscript(1),
),
```
Sample #sample-counter():
Attached items are identified (case 2).
```tex
x''_1␠
```
```coffee
AttachItem(
Item(Word("x")),
Superscript(Word("'"), Word("'")),
Subscript(1),
),
```
Sample #sample-counter():
Apostrophes without an attached target will become regular text.
```tex
''␠
```
```coffee
Word("'")
Word("'")
```
Sample #sample-counter():
Apostrophes that in the position of a command argument will become regular text.
```tex
\frac''␠
```
```coffee
Command(
CommandName("frac"),
Argument(Word("'")),
Argument(Word("'")),
),
```
|
https://github.com/An-314/typst-templates | https://raw.githubusercontent.com/An-314/typst-templates/main/template.typ | typst | /* This is a template for writing articles in Chinese. */
#import "@preview/tablex:0.0.6": tablex, hlinex
#import "@preview/tablem:0.1.0": tablem
#let three-line-table = tablem.with(
render: (columns: auto, ..args) => {
tablex(
columns: columns,
auto-lines: false,
align: center + horizon,
hlinex(y: 0),
hlinex(y: 1),
..args,
hlinex(),
)
}
)
#let newpara() = {
par()[#text(size: 0.0em)[#h(0.0em)]]
v(-12pt)
}
#let project(
template: "article",
title: "",
info:"",
authors: (),
time: "",
abstract: none,
keywords: (),
preface: none,
contents: false,
content_depth: 2,
font_size: 11pt,
body
) = {
/****** 设置字体 ******/
let song = ("CMU Serif", "Linux Libertine", "SimSun")
let hei = ("CMU Serif", "Linux Libertine", "SIMHEI")
let kai = ("CMU Serif","Linux Libertine", "KaiTi",)
let xbsong = "FZXiaoBiaoSong-B05"
let code = "Consolas"
let title-font = hei
let author-font = kai
let body-font = song
let heading-font = hei
let caption-font = kai
let header-font = kai
let strong-font = hei
let emph-font = kai
let quote-font = kai
let raw-font = code
/************************* 初始化文档 *************************/
set document(author: authors, title: title)
set heading(numbering: "1.1")
set text(font: body-font, lang: "zh", region: "cn")
set bibliography(style: "gb-7714-2015-numeric")
/************************* 设置样式字体 *************************/
set par(first-line-indent: 2em,leading: 1.1em)
set enum(indent: 2em)
set figure(gap: 0.5cm)
set text(font: body-font, size: font_size)
show strong: set text(font: strong-font)
show emph: set text(font: emph-font)
show ref: set text(red)
show raw.where(block: true): block.with(
width: 100%,
fill: luma(240),
inset: 10pt,
)
show raw.where(block: true): set par(leading: 0.7em)
show raw: set text(font: (raw-font, "simsun"), size: 10pt)
show link: underline
show link: set text(blue)
/************************* 调整样式 *************************/
show heading: it => box(width: 100%)[
#set text(font: heading-font)
#v(-0.8em)
#if it.numbering != none { counter(heading).display() }
#h(0.2em)
#it.body
#v(0.5em)
]
show heading.where(level: 1): it => box(width: 100%)[
#v(0.3em)
#set heading(numbering: "一")
#it
]
/** 把每一板块封装成函数 */
let mktitle(title) ={
align(center)[
#if(template == "report") {
v(10em)
block(text(font: title-font, weight: 700, 2.2em, title))
v(5em)
} else if(template == "book") {
v(20em)
block(text(font: title-font, weight: 700, 2.3em, title))
v(5em)
} else [
#block(text(font: title-font, weight: 700, 2.3em, title))
]
]}
let mkinfo(info) = {
if(info != ""){
align(center)[
#if (template in ("report")) {
align(center)[
#v(0em)
#block(text(font: title-font, weight: 700, 2.5em, info))
#v(15em)
]}else if(template in ("book")) {
block(text(font: title-font, weight: 700, 1.5em, info))
v(10em)
}else{
v(0.5em)
block(text(font: author-font, 1.5em, info))
}
]
}
}
let mkauthor(author) = {
let author-size = if(template == "report"){ 1.3em }else{ 1.1em }
pad(
top: 0.5em,
bottom: 0.5em,
x: 2em,
grid(
columns: (1fr,) * calc.min(3, authors.len()),
gutter: 1em,
..authors.map(author => align(center, text(font: author-font,size: author-size, author))),
),
)
}
let mktime(time) = {
if (time != "") {align(center)[
#if(template in ("report", "book")) {
v(10em)
set text(1.3em)
time
} else{
v(-0.3em)
set text(1em)
time
}]}}
let mkabstruct(abstract, keywords) = {
if (abstract != none) {
set par(first-line-indent: 0em,leading: 1.1em)
v(2pt)
[*摘要:*#abstract]
v(1pt)
if keywords!= () [
*关键字:*
#text(font: kai, keywords.join(";"))
]
v(10pt)
}
}
let mkpreface(preface) = {
if (preface != none) {
[
#v(2em)
#set align(center)
#set text(2.5em)
*前言*
#v(1em)
]
set par(first-line-indent: 2em,leading: 1.1em)
v(2pt)
preface
v(10pt)
}
}
let mkcontent(contents) = {
if(contents) {
set par(first-line-indent: 2em,leading: 1em)
show outline.entry.where(level: 1): it => {
v(0.3em)
h(-2.0em)
set text(15pt)
strong(it)
}
outline(indent: auto, depth: content_depth, fill: repeat( " ·"))
v(20pt)
}
}
// 调整图片
show figure: it => [
#v(2pt)
#set text(font: caption-font)
#it
#v(-2em)
#par()[#text(size: 0.0em)[#h(0.0em)]]
#v(13pt)
]
show image: it => [
#it
#v(-1.1em)
#par()[#text(size: 0.0em)[#h(1.0em)]]
]
// 调整表格
show table: it => [
#set text(font: body-font)
#it
]
// 调整列表
show enum: it => [
#it
#par()[#text(size: 0.0em)[#h(0.0em)]]
#v(-12pt)
]
show list: it => [
#it
#par()[#text(size: 0.0em)[#h(0.0em)]]
#v(-12pt)
]
// 调整引用
show quote: it => [
#set text(font: quote-font)
#align(center)[#it]
]
// 数学公式
set math.equation(numbering: it => {
locate(loc => {
let count = counter(heading.where(level:1)).at(loc).last()
numbering("(1.1)", count, it)
})
})
// 调整页眉页脚
let pageheading = [
#set text(font: header-font)
#let header = if(template in ("article")) {
if(selector(heading.where(level:1)) == true) {
locate(loc => [#locate(loc => [#counter(heading.where(level:1)).display() #query(selector(heading.where(level:1)).before(loc), loc).last().body.text])])
}else{
""
}
}else{
none
}
#if(header != "" and header != none) {
locate(loc => if(loc.page() != 1) [#title #h(1fr) #info #h(1fr) #header])}else{
locate(loc => if(loc.page() != 1) [#title #h(1fr) #info])
}
]
// 正文
if(template in ("article")){
set page(numbering: "1", number-align: center, header: pageheading,)
mktitle(title)
mkinfo(info)
mkauthor(authors)
mktime(time)
mkabstruct(abstract, keywords)
mkcontent(contents)
body
}else if(template in ("report")){
mktitle(title)
mkinfo(info)
mkauthor(authors)
mktime(time)
if (contents){
set page(numbering: "I", number-align: center,header: pageheading,)
counter(page).update(1)
mkabstruct(abstract, keywords)
v(2em)
mkcontent(contents)
}
let pageheading = [
#set text(font: header-font)
#let header = locate(loc => [#locate(loc => [#counter(heading.where(level:1)).display() #query(selector(heading.where(level:1)).before(loc), loc).last().body.text])])
#if(header != "" and header != none) {
locate(loc => if(loc.page() != 1) [#title #h(1fr) #info #h(1fr) #header])}else{
locate(loc => if(loc.page() != 1) [#title #h(1fr) #info])
}
]
set page(numbering: "1", number-align: center,header: pageheading,)
counter(page).update(1)
if (contents != true){
mkabstruct(abstract, keywords)
}
show heading.where(level:1): it => {
counter(math.equation).update(0)
it
}
body
}else if(template in ("book")){
mktitle(title)
mkinfo(info)
mkauthor(authors)
mktime(time)
show heading: it => box(width: 100%)[
#set text(font: heading-font)
#v(0.5em)
#if it.numbering != none { counter(heading).display() }
#h(0.2em)
#set text(1.2em)
#it.body
#v(0.5em)
]
show heading.where(level: 1): it => box(width: 100%)[
#v(2em)
#set align(center)
#set heading(numbering: "一")
#set text(1.5em)
#it
#v(1em)
]
if (preface!=none){
set page(numbering: "A", number-align: center, header: pageheading,)
counter(page).update(1)
mkpreface(preface)
}
if (contents){
set page(numbering: "I", number-align: center, header: pageheading,)
counter(page).update(1)
mkcontent(contents)
}
let pageheading = [
#set text(font: header-font)
#let header = locate(loc => [#locate(loc => [#counter(heading.where(level:1)).display() #query(selector(heading.where(level:1)).before(loc), loc).last().body.text])])
#if(header != "" and header != none) {
locate(loc => if(loc.page() != 1) [#title #h(1fr) #info #h(1fr) #header])}else{
locate(loc => if(loc.page() != 1) [#title #h(1fr) #info])
}
]
set page(numbering: "1", number-align: center, header: pageheading,)
counter(page).update(1)
show heading.where(level:1): it => {
counter(math.equation).update(0)
it
}
body
}
}
/************************* 定义常用块 *************************/
#let problem-counter = counter("problem")
#problem-counter.step()
#let problem(body) = {
problem-counter.step()
set enum(numbering: "(1)")
block(
fill: rgb(241, 241, 255),
inset: 8pt,
radius: 2pt,
width: 100%,
)[*题目 #problem-counter.display().* #h(0.75em) #body]
}
#let solution(body) = {
set enum(numbering: "(1)")
block(
inset: 8pt,
width: 100%
)[*解答.* #h(0.75em) #body]
}
#let theorem-counter = counter("theorem")
#show heading.where(level:1): it => {
counter("theorem").update(0)
it
}
#let theorem(body, name:none) = {
theorem-counter.step()
block(
fill: rgb(241, 241, 255),
inset: 8pt,
radius: 2pt,
width: 100%,
)[*Theorem [#counter(heading.where(level:1)).display().#theorem-counter.display()]* #if(name!=none){text(style: "italic",weight: "bold", name)} #h(0.75em) #body]
}
#let proof(body) = {
set enum(numbering: "(1)")
block(
inset: 8pt,
width: 100%
)[_Proof._ #h(0.75em) #body
#align(right)[$qed$]
]
}
|
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/layout/list-attach_01.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
// Test that attached list isn't affected by block spacing.
#show list: set block(above: 100pt)
Hello
- A
World
- B
|
https://github.com/huyufeifei/grad | https://raw.githubusercontent.com/huyufeifei/grad/master/docs/paper/src/ch3.typ | typst | #import "template/template.typ" : empty_par
= 驱动实现
== VirtIO驱动
VirtIO设备 @virtio 是一种专门为虚拟环境设计的虚拟设备。Alien现阶段在qemu模拟器中运行,因此适配了一些qemu提供的VirtIO设备。包括网卡、输入设备(鼠标、键盘、触摸板等)、块设备(硬盘等)、显示设备、控制台设备。
=== 块设备
块设备是一种用于持久储存数据的IO设备,包括硬盘、SD卡、U盘等。这种设备提供的最小读写单位是块,因此被称为块设备。对块设备可以进行的操作共有8种。每种操作都需要在描述符所指向的地址处放置一个Request结构。其中描述了操作的类型、目标块标号和数据存放缓冲区。注意这个结构可以被分开放置于多个描述符指向的地址中。在实际使用中,需要操作的元数据(操作类型、块标号)被放在首个描述符指向的区域中,并把读写操作所需的缓冲区放置在第二个描述符指向的区域中。设备在完成操作后会向驱动返回一个状态值,它将被存放在缓冲区之后的第三个(非读写操作则是第二个)描述符指向的区域中。
块设备支持的特性位展示在下表中:
#figure(
table(
columns: 2,
inset: (x: 1em),
[位],[名称],
[0],[VIRTIO_BLK_F_BARRIER],
[1],[VIRTIO_BLK_F_SIZE_MAX],
[2],[VIRTIO_BLK_F_SEG_MAX],
[4],[VIRTIO_BLK_F_GEOMETRY],
[5],[VIRTIO_BLK_F_RO],
[6],[VIRTIO_BLK_F_BLK_SIZE],
[7],[VIRTIO_BLK_F_SCSI],
[9],[VIRTIO_BLK_F_FLUSH],
[10],[VIRTIO_BLK_F_TOPOLOGY],
[11],[VIRTIO_BLK_F_CONFIG_WCE],
[13],[VIRTIO_BLK_F_DISCARD],
[14],[VIRTIO_BLK_F_WRITE_ZEROES],
),
caption: [块设备特性位],
)
它有一个称为`requestq`的虚拟队列,用于执行所有操作。块设备的大小固定以512字节为一个块。初始化时,需要按如下步骤对块设备进行操作:
1. 从设备处阅读总容量。
2. 如果`VIRTIO_BLK_F_BLK_SIZE`特性被协商启用,驱动可以读取到`blk_size`,用以作为最优的设备块大小。这并不影响协议中的单位大小,它总是512位。只是一个影响性能的因素。
3. 检测是否启用了`VIRTIO_BLK_F_RO`特性。如果启用,则对设备的所有写操作将会被拒绝。
4. 检测是否启用了`VIRTIO_BLK_F_TOPOLOGY`特性。如果启用了,则`topology`结构中的字段可以被读取,以决定最优的读写操作物理块长度。这也只影响性能而不影响协议。
5. 如果`VIRTIO_BLK_F_CONFIG_WCE`特性被启用,则可以通过`writeback`字段读取或设置缓存模式。设为`0`表示通写(Writethrough)模式,设为`1`表示写回(Writeback)模式。在设备重置之后,缓存模式可能是以上两种中任一种。在特性协商之后,可以读取该字段来判断到底时哪一种。
6. 如果`VIRTIO_BLK_F_DISCARD`特性被启用,`max_discard_sectors`和`max_discard_seg`字段可以被读取,用于决定块设备用的最大折扣区和最大折扣段编号。当操作系统基于对齐进行操作时,可以使用`discard_sector_alignment`字段。
7. 如果`VIRTIO_BLK_F_WRITE_ZEROES`特性被启用,`max_write_zeroes_sectors`和`max_write_zeroes_seg`字段可以被读取,用于决定块设备驱动使用的最大写入0区和最大写入0段的编号。
当驱动不会发出flush请求时,它不应该协商`VIRTIO_BLK_F_FLUSH`特性。
块设备的特点是对它的操作是由系统发出、设备接受的。这与VirtIO所设计的操作通信模式一致,因此较容易实现。
驱动提供了阻塞式和非阻塞式的接口,使用者可以任选一种使用。非阻塞式是基础的操作方式,也是VirtIO设备运行的模式。驱动在发出操作请求之后,可以不时进行查询操作是否完成。如果完成,则接受操作的结果。此外,如果中断特性被协商开启,那么设备在完成操作之后也会发出一个中断来通知系统。
=== 输入设备
输入设备是用于接受用户外部输入的设备,包括鼠标、键盘、触摸板等。输入设备的操作类型非常简单,只有一种,就是驱动从设备处接受一个输入事件。这个事件将会含有一些属性,如输入类型(触发了哪个按键),鼠标移动的距离,等。通信方式是驱动向设备发出一个请求,而当输入设备接受到一个新的用户输入时,就把输入写入到请求中的储存区域,然后返回给驱动。
输入设备无任何支持的特性。
输入设备与之后的网卡,这两个设备与块设备之间有一点不同,就是它们需要处理的事件会包含从设备处发出而系统接受的类型。这种类型与VirtIO设备的操作通信模式相异,因此需要一些额外的处理。被选中的解决方案是,从驱动初始化的时候开始,就保持可用环(即驱动向设备发出的请求)始终为满。因此,每当设备接受到一个输入时,总是有可用的请求用于存放输入并返回给驱动(可用请求总数为队列大小)。而系统会定期轮询驱动查询有无新的输入。此时驱动会把一个设备已经完成并返回的操作接受,取出其中的输入传给系统,并继续向可用环中插入新的请求。
=== 网卡
网卡是用于通过网络通信(即发送与接受数据包)的设备。驱动在这个过程中要做的事情主要有两件,即收和发数据包。在发送数据包时,驱动从系统处获取想要发送的一个数据包,在其前方加入VirtIO网络包的header,并将其传递给设备处理。在接受数据包时,驱动从设备处获取一个收到的数据包,剥离其开头的VirtIO网络包header,并把内部的内容返回给系统。
网卡设备可以有$2n+1 ( n in NN_+)$个虚拟队列。编号依次为$0, 1, ..., 2n$。其中前$n$个偶数编号的队列为接受队列,前$n$个奇数编号的队列为发送队列。第$2n$个队列为控制队列。如果`VIRTIO_NET_F_MQ`特性未被协商,则$n=1$。否则$n$由`max_virtqueue_pairs`设定。只有当特性`VIRTIO_NET_F_CTRL_VQ`启用时才存在控制队列。
网课设备的特性位如下表所示:
#figure(
table(
columns: 2,
inset: (x: 1em),
[位],[名称],
[0],[VIRTIO_NET_F_CSUM ],
[1],[VIRTIO_NET_F_GUEST_CSUM ],
[2],[VIRTIO_NET_F_CTRL_GUEST_OFFLOADS],
[3],[VIRTIO_NET_F_MTU],
[5],[VIRTIO_NET_F_MAC ],
[6],[VIRTIO_NET_F_GSO ],
[7],[VIRTIO_NET_F_GUEST_TSO4 ],
[8],[VIRTIO_NET_F_GUEST_TSO6 ],
[9],[VIRTIO_NET_F_GUEST_ECN ],
[10],[VIRTIO_NET_F_GUEST_UFO ],
[11],[VIRTIO_NET_F_HOST_TSO4 ],
[12],[VIRTIO_NET_F_HOST_TSO6 ],
[13],[VIRTIO_NET_F_HOST_ECN ],
[14],[VIRTIO_NET_F_HOST_UFO ],
[15],[VIRTIO_NET_F_MRG_RXBUF ],
[16],[VIRTIO_NET_F_STATUS ],
[17],[VIRTIO_NET_F_CTRL_VQ ],
[18],[VIRTIO_NET_F_CTRL_RX ],
[19],[VIRTIO_NET_F_CTRL_VLAN ],
[21],[VIRTIO_NET_F_GUEST_ANNOUNCE],
[22],[VIRTIO_NET_F_MQ],
[23],[VIRTIO_NET_F_CTRL_MAC_ADDR],
[41],[VIRTIO_NET_F_GUEST_RSC4 ],
[42],[VIRTIO_NET_F_GUEST_RSC6 ],
[61],[VIRTIO_NET_F_RSC_EXT],
[62],[VIRTIO_NET_F_STANDBY],
),
caption: [网卡设备特性位],
)
#empty_par
当数据包被复制到接收队列中的缓冲区后,最佳的处理方法是禁用接受队列发来的中断通知,并处理数据包,直到处理完所有的包为止,然后在重新启用中断。
数据包中的`num_buffers`字段表示该数据包分布在多少个描述符上(包括本描述符):如果未启用`VIRTIO_NET_F_MRG_RXBUF`,则该值始终为 $1$。这样就可以接收大数据包,而无需分配大缓冲区:一个缓冲区放不下的数据包数据可以继续放置在下一个缓冲区中,以此类推。在这种情况下,虚拟队列中至少会有2个使用过的 `num_buffers` 缓冲区,设备会将它们串联起来形成一个数据包,其方式类似于将数据包存储在分布于多个描述符的单个缓冲区中。其他缓冲区不会以 `virtio_net_hdr` 结构开头。
如果 `num_buffers` 为 $1$,则整个数据包都放置在此缓冲区中,紧接在 `virtio_net_hdr` 结构之后。
如果启用了 `VIRTIO_NET_F_GUEST_CSUM` 特性,则可以设置标志中的 `VIRTIO_NET_HDR_F_DATA_VALID` 位:如果设置了该位,则表示设备已验证了数据包校验和。如果有多个封装协议,则已验证了一级校验和。
网卡与输入设备虽然都有与VirtIO操作通信模式相异的事件,但它们之间还有不同之处,这是因为输入设备需要接受的是可以直接进行逐字节拷贝(即实现了`Copy` `trait`)的基本类型数据,其大小极小(仅64位)使得拷贝过程不会影响性能。但是网卡所接受的内容是一整个数据包,其大小可能达到上千字节。如果逐字节拷贝这个数据,那么对性能的影响将会是不可接受的。因此可行的方案是直接保持数据在内存中的存放位置不懂,仅传递指针。在一些情况下,使用者可能想要自行决定网络收发的数据包需要放在什么地方(如Alien中数据包需要跨域进行传递,因此需要被放置在共享堆上)。另外的情况下使用者可能想要开箱即用而不关心数据包实际上存放在了哪里。因此向使用者提供了两种不同的驱动:`VirtIONet`和`VirtIONetRaw`。从名称上可以看出,后者允许使用者自行为数据包收发分配内存空间,并只需向驱动提供数据包的地址即可;前者则在基础驱动之上进行了更多的封装,提供了直接传入数据包进行发送,接受数据包的功能。当然这会带来一定的性能损失,对性能有追求的使用者应该使用基础的驱动。
== Uart16550驱动
这是一个物理存在的串口设备。与VirtIO系列的设备不同。因此它的驱动也和VirtIO设备的驱动分开成了两份代码。串口设备用于在多个设备间进行字节粒度的数据传输。它的通信模式也更加简单:往其某个寄存器中写入数据即是发送,而从某个寄存器中读取数据即是接受。
与VirtIO设备相同,对寄存器的操作也被归纳成了一个`trait`,提供按字节对一段内存进行读写的能力。该段内存被映射到设备寄存器上。
|
|
https://github.com/zurgl/typst-resume | https://raw.githubusercontent.com/zurgl/typst-resume/main/letter.typ | typst | #import "templates/main.typ": letterHeader, layout, letterSignature, letterFooter
#show: layout
#set text(size: 12pt) //set global font size
#letterHeader(
myAddress: [1 Rue Gonnet \ 75003 Paris, France], recipientName: [ABC Company], recipientAddress: [15 Boulevard Roi \ 75011 Paris, France], date: [03/07/2024], subject: "Subject: Job Application for Tech Leader",
)
Dear Hiring Manager,
....
Thank you for considering my application. I look forward to the opportunity to
discuss my qualifications further.
Sincerely,
#letterSignature("/assets/signature.png")
#letterFooter()
|
|
https://github.com/leesum1/brilliant-cv | https://raw.githubusercontent.com/leesum1/brilliant-cv/master/modules_en/skills.typ | typst | // Imports
#import "@preview/brilliant-cv:2.0.2": cvSection, cvSkill, hBar
#let metadata = toml("../metadata.toml")
#let cvSection = cvSection.with(metadata: metadata)
#cvSection("Skills")
#cvSkill(type: [Programming Languages], info: [Proficient in C/C++, Rust, Verilog/SystemVerilog, and Scala/Chisel, with the ability to develop across the entire stack from low-level hardware to high-level system software.])
#cvSkill(type: [Embedded Development], info: [In-depth understanding of embedded systems development processes, with experience in BSP development; possess the capability for collaborative development from hardware to software.])
#cvSkill(type: [Chip Design], info: [Skilled in RTL design and verification, proficient in using Verilog and Chisel for processor core design and AXI bus integration.])
#cvSkill(type: [Areas of Interest], info: [Passionate about processor design, hardware acceleration technologies, and embedded systems application development.])
|
|
https://github.com/OrangeX4/typst-tablem | https://raw.githubusercontent.com/OrangeX4/typst-tablem/main/README.md | markdown | MIT License | # Tablem
Write markdown-like tables easily.
## Example
Have a look at the source [here](./examples/example.typ).

## Usage
You can simply copy the markdown table and paste it in `tablem` function.
```typ
#import "@preview/tablem:0.1.0": tablem
#tablem[
| *Name* | *Location* | *Height* | *Score* |
| ------ | ---------- | -------- | ------- |
| John | Second St. | 180 cm | 5 |
| Wally | Third Av. | 160 cm | 10 |
]
```
And you can use custom render function.
```typ
#import "@preview/tablem:0.1.0": tablem
#let three-line-table = tablem.with(
render: (columns: auto, ..args) => {
table(
columns: columns,
stroke: none,
align: center + horizon,
table.hline(y: 0),
table.hline(y: 1, stroke: .5pt),
..args,
table.hline(),
)
}
)
#three-line-table[
| *Name* | *Location* | *Height* | *Score* |
| ------ | ---------- | -------- | ------- |
| John | Second St. | 180 cm | 5 |
| Wally | Third Av. | 160 cm | 10 |
]
```

## `tablem` function
```typ
#let tablem(
render: table,
ignore-second-row: true,
..args,
body
) = { .. }
```
**Arguments:**
- `render`: [`(columns: int, ..args) => { .. }`] — Custom render function, default to be `table`, receiving a integer-type columns, which is the count of first row. `..args` is the combination of `args` of `tablem` function and children genenerated from `body`.
- `ignore-second-row`: [`boolean`] — Whether to ignore the second row (something like `|---|`).
- `args`: [`any`] — Some arguments you want to pass to `render` function.
- `body`: [`content`] — The markdown-like table. There should be no extra line breaks in it.
## Limitations
Cell merging has not yet been implemented.
## License
This project is licensed under the MIT License.
|
https://github.com/crd2333/template-report | https://raw.githubusercontent.com/crd2333/template-report/master/README.md | markdown | MIT License | # my-typst-template
- A typst template for course report, desighed as a student in Chinese Zhejiang University, and is easy to modify.
- 这个 typst 模板是用于课程实验报告的、基于浙江大学(ZJU)学子身份设计的模板,集成了几个相对实用的包,对中英文混排做一定优化。
- 建议在本地 VSCode 中使用 [tinymist](https://github.com/Myriad-Dreamin/tinymist.git) 和 typst-preview 插件,以获得最佳体验。
- 在直接开始使用前,你可能需要下载字体等,可以根据报错定位缺少哪些部分(不过字体可能不会报错而是 fallback 到你已有的字体)。
## 声明
- 本模板是在 [浙江工业大学实验报告模板](https://github.com/zjutjh/zjut-report-typst) 和 [南京大学学位论文模板](https://github.com/nju-lug/nju-thesis-typst) 的基础上修改而来的。
- 使用了自己编写的基于 showybox 的 [admonitions](https://github.com/crd2333/typst-admonition)、[theorems boxes](https://github.com/crd2333/typst-theorem-box)。
## 特点(feature)
- 根据个人使用习惯,对封面页设置了"report"和"normal"类型,并支持匿名实验报告,支持无封面的简单作业;
- 拥有一键添加封面与目录、优化页眉与页脚、语言切换、图表分章节自动计数等功能;
- 优化了中西文混排、图文混排;
- 整合了一些方便实用的第三方包在内,便于使用。
- 优化(添加)功能包括:图、表、代码、伪代码、公式、admonitions、theorems、todo、emoji、树形图、流程图、LaTeX公式支持等。
- 通过更改校徽和校名并调整大小,你也可以很方便地将其改为你的学校。
- 具体使用方法,可以参考 `template/main.typ`。

## Change logs
1. 2024.2.1:Initial commit
2. 2024.2.1:Add README and first publish
3. 2024.2.27:根据不同课程报告添加不同report类型并略微调整代码
4. 2024.3.1:修改几个bug
5. 2024.3.1:删除没用的文件
6. 2024.3.3:加入几个新的第三方包,修改代码部分组织方式,修改margin
7. 2024.3.3:修bug
8. 2024.3.8:解决中西文空格问题,添加中文斜体解决方案,添加thms包
9. 2024.3.8:优化部分编排
10. 2024.3.9:再次添加几个包,重构部分代码,重新上传整个仓库
11. 2024.3.10:typst 0.11.0 发布,根据新版的 template 要求重新组织结构
12. 2024.4.1:调整表格为 0.11.0 的 built-in 表格及一些细节修改
13. 2024.4.5:修改 theorem boxes,使用 showybox 实现
14. 2024.4.14:细节调整与添加 cheq 包
15. 2024.5.13:删除 xarrow 包,添加 fletcher 包,同时修改一些细节,添加页眉与页脚的种类
16. 2024.7.2:添加 indenta, pinit, mitex. 重构部分代码,重构 thms 包
17. 2024.10.19:更新到 typst 0.12.0,更新相关第三方包
18. 2024.10.22:删除 i-figured(自己做更简洁的实现),添加 timeliney 包 |
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/cetz-plot/0.1.0/README.md | markdown | Apache License 2.0 | # CeTZ-Plot
CeTZ-Plot is a library that adds plots and charts to [CeTZ](https://github.com/cetz-package/cetz), a library for drawing with [Typst](https://typst.app).
CeTZ-Plot requires CeTZ version ≥ 0.3.1!
## Examples
<!-- img width is set so the table gets evenly spaced by GitHubs css -->
<table>
<tr>
<td>
<a href="gallery/line.typ">
<img src="gallery/line.png" width="250px">
</a>
</td>
<td>
<a href="gallery/piechart.typ">
<img src="gallery/piechart.png" width="250px">
</a>
</td>
<td>
<a href="gallery/barchart.typ">
<img src="gallery/barchart.png" width="250px">
</a>
</td>
</tr><tr>
<td>Plot</td>
<td>Pie Chart</td>
<td>Clustered Barchart</td>
</tr>
</table>
*Click on the example image to jump to the code.*
## Usage
For information, see the [manual (stable)](https://github.com/cetz-package/cetz-plot/blob/stable/manual.pdf?raw=true).
To use this package, simply add the following code to your document:
```
#import "@preview/cetz:0.3.1"
#import "@preview/cetz-plot:0.1.0": plot, chart
#cetz.canvas({
// Your plot/chart code goes here
})
```
## Installing
To install the CeTZ-Plot package under [your local typst package dir](https://github.com/typst/packages?tab=readme-ov-file#local-packages) you can use the `install` script from the repository.
### Just
This project uses [just](https://github.com/casey/just), a handy command runner.
You can run all commands without having `just` installed, just have a look into the `justfile`.
To install `just` on your system, use your systems package manager. On Windows, [Cargo](https://doc.rust-lang.org/cargo/) (`cargo install just`), [Chocolatey](https://chocolatey.org/) (`choco install just`) and [some other sources](https://just.systems/man/en/chapter_4.html) can be used. You need to run it from a `sh` compatible shell on Windows (e.g git-bash).
## Testing
This package comes with some unit tests under the `tests` directory.
To run all tests you can run the `just test` target. You need to have
[`typst-test`](https://github.com/tingerrr/typst-test/) in your `PATH`: `cargo install typst-test --git https://github.com/tingerrr/typst-test`.
|
https://github.com/QianZeHao123/Mutilevel-Modeling | https://raw.githubusercontent.com/QianZeHao123/Mutilevel-Modeling/main/notes-summative/main.typ | typst | #import "template.typ": *
// Take a look at the file `template.typ` in the file panel
// to customize this template and discover how it works.
#let today = datetime.today()
#show: project.with(
title: "Multilevel Modeling Notes",
authors: ((name: "<NAME>", email: "<EMAIL>"),),
// Insert your abstract after the colon, wrapped in brackets.
// Example: `abstract: [This is my abstract...]`
date: today.display("[month repr:long] [day], [year]"),
// date: "2021-10-14"
)
// We generated the example code below so you can see how
// your document will look. Go ahead and replace it with
// your own content!
// ------------------------------------------------
// outline part
#show link: underline
#show outline.entry.where(level: 1): it => {
v(12pt, weak: true)
strong(it)
}
#outline(indent: auto)
// ------------------------------------------------
= Three-level Modele
== Empty Model
$y_"tij"=gamma_0+u_"ij"+v_j+epsilon_"tij"$, where $u_"ij" tilde N (0, sigma_n^2)$, $v_j tilde N(0,sigma_h^2)$, $epsilon_"tij" tilde N(0.sigma^2)$
== Building
$y_"tij"= a_"ij"+b T_"tij" + epsilon_"tij"$
$a_"ij" = a_j+alpha^"(1)"e_"ij"+alpha^"(2)" z_"ij" + alpha^"(3)" t_"ij"$
$a_j = a + gamma s_j + u_j$, where $u_j tilde N(0, sigma_u^2)$, Random Intercept
Model
== Covariates
=== Level 1
$T_"tij" = t$, $t=1,2,3$
=== Level 2
$e_"ij"$ (exper), $z_"ij"$ (gender), $t_"ij"$ (intervention)
=== Level 3
$s_j arrow$ size of hospital |
|
https://github.com/SkiFire13/master-thesis | https://raw.githubusercontent.com/SkiFire13/master-thesis/master/preface/summary.typ | typst | #let summary() = page[
#v(1cm)
= Summary
#v(1cm)
Fixpoint equations and, more generally, systems of fixpoint equations are ubiquitous in a number of formal verification tasks. This includes the model checking of specification logics, like the $mu$-calculus, and the check of behavioral equivalence, like bisimilarity. Consequently, a recurring problem consists in conceiving and implementing algorithms aimed at determining the solution of these systems. It has been shown in the literature that a game-theoretic characterization of the solution of equational systems can be given in terms of a parity game (a two-player, zero-sum game), which is referred to as fixpoint game or powerset game. The game view opens the way for the development of local algorithms for characterizing the solution of such equation systems. Two classes of algorithms can be identified: global algorithms, aimed at computing the full solution, by deciding the game for all positions, and local algorithms, which instead aim at determining only some "component" of the solution. For instance, in the case of the $mu$-calculus, of could be interested in checking whether a specific state enjoys or not a property, rather than determining all states satisfying the property. Similarly, for bisimilarity checking one might be interested in establishing whether two states are bisimilar, rather than computing the full equivalence.
A local algorithm for solving a system fo fixpoint equations has been already proposed, based on the local algorithm for parity games due to Stevens and Stirling. In this thesis we explore the possibility of exploiting a different local algorithm for parity games, due to Vöge and Jurdziński, based on local strategy iteration. The idea is to start from arbitrary strategies for game players and progressively provide a local solution for systems of fixpoint equations. We show how this algorithm can be adapted to provide a local solution for systems of fixpoint equations. This is non-trivial as it requires, in particular, to deal with a symbolic representation of the moves of the game, and with a lazy generation of such symbolic moves. An implementation in the language Rust is also provided, and a comparison is conducted with other existing tools.
]
|
|
https://github.com/7sDream/fonts-and-layout-zhCN | https://raw.githubusercontent.com/7sDream/fonts-and-layout-zhCN/master/chapters/03-unicode/global-scripts.typ | typst | Other | #import "/template/template.typ": web-page-template
#import "/template/components.typ": note
#import "/template/font.typ": sil-pua
#import "/lib/glossary.typ": tr
#show: web-page-template
// ## Global Scripts in Unicode
== Unicode 中的#tr[global scripts]
// At the time of writing, the Unicode Standard is up to version 9.0, and new scripts and characters are being encoded all the time. The Unicode character set is divided into 17 planes, each covering 65536 code points, for a total of 1,114,112 possible code points. Currently, only 128,327 of those code points have been assigned characters; 137,468 code points (including the whole of the last two planes) are reserved for private use.
在写作时,Unicode 标准的最新版是9.0,不断有新的#tr[scripts]和#tr[character]被#tr[encoding]进去。Unicode#tr[character set]被分为17个平面,每个平面有65536个#tr[codepoint],共有 1114112 个可用#tr[codepoint]。目前,只有其中128327个被分配了#tr[character],还有(包括最后两个平面的)137468个#tr[codepoint]为自定义的私人用途而保留。
#note[
// > Private use means that *within an organisation, community or system* you may use these code points to encode any characters you see fit. However, private use characters should not "escape" into the outside world. Some organisations maintain registries of characters they have assigned to private use code points; for example, the SIL linguistic community have encoded 248 characters for their own use. One of these is , LATIN LETTER SMALL CAPITAL L WITH BELT, which they have encoded at position U+F268. But there's nothing to stop another organisation assigning a *different* character to U+F268 within their systems. If allocations start clashing, you lose the whole point of using a common universal character set. So use private use characters... privately.
私人使用意味着,在*一个组织、社群或系统中*,你可以按照符合你需求的方式随意使用这些#tr[codepoint]。但是,私用#tr[character]不能“逃逸”到外部世界中。一些组织会维护一个他们使用的私人#tr[codepoint]的目录以供查询:比如SIL语言学社区#tr[encoding]了他们自用的248个#tr[character]。其中一个是#sil-pua[/*\u{0F268}*/\u{1DF04}]#footnote[译注:大多数SIL PUA#tr[character]已经被Unicode正式编入,编入后这些PUA区的#tr[character]就会标注为已弃用。目前支持SIL PUA区的字体都使用了某种样式来提示U+F268已被弃用,为了显示这个#tr[character]的实际样子,此处使用的其实是其正式Unicode#tr[codepoint]U+1DF04。], LATIN LETTER SMALL CAPITAL L WITH BELT,他们将其#tr[encoding]在U+F268的位置。但这并不能阻止其他组织在其系统中把U+F268分配给*别的*#tr[character]。一旦分配发生冲突,使用公共的通用#tr[character set]就失去了意义。所以私用#tr[character]只能在内部使用。
]
// Most characters live in the first plane, Plane 0, otherwise known as the Basic Multilingual Plane. The BMP is pretty full now - there are only 128 code points left unallocated - but it covers almost all languages in current use. Plane 1 is called the Supplementary Multilingual Plane, and mainly contains historic scripts, symbols and emoji. Lots and lots of emoji. Plane 2 contains extended CJK (Chinese, Japanese and Korean) ideographs with mainly rare and historic characters, while planes 3 through 13 are currently completely unallocated. So Unicode still has a lot of room to grow.
大多数#tr[character]都在第一个平面上,也就是第0平面。它的另一个著名的名字是#tr[BMP](Basic Multilingual Plane,BMP)。BMP现在基本满了,它只剩下最后 128 个#tr[codepoint]还没被分配。这一个平面已经足以满足当前绝大数语言的需求。第1平面被称为#tr[SMP],主要包含古代#tr[scripts]、符号和emoji。很多很多的emoji。第2平面包含中日韩表意文字扩展区,基本上是不常见的或者古代#tr[character]。第3到13平面完全没有使用,Unicode里的可用空间还有很多。
// Within each plane, Unicode allocates each writing system a range of codepoints called a *block*. Blocks are not of fixed size, and are not exhaustive - once codepoints are allocated, they can't be moved around, so if new characters from a writing system get added and their block fills up, a separate block somewhere else in the character set will be created. For instance, groups of Latin-like characters have been added on multiple occasions. This means that there are now 17 blocks allocated for different Latin characters; one of them, Latin Extended-B, consists of 208 code points, and contains Latin characters such as Ƕ (Latin Capital Letter Hwair), letters used in the transcription of Pinyin, and African clicks like U+013C, ǃ - which may look a lot like an exclamation mark but is actually the ǃKung letter Latin Letter Retroflex Click.
在每一个平面内,Unicode 会给某个#tr[writing system]分配一系列连续的#tr[codepoint],这称为*#tr[block]*。#tr[block]不是固定大小的,也不保证全面。也就是它不一定含有这个#tr[writing system]的所有#tr[character],因为在#tr[codepoint]分配给了#tr[character]了后,它们就不能移动了。所以如果这个#tr[block]的所有空位都用完了,而#tr[writing system]又需要增加别的#tr[character]的话,我们就会为它在#tr[character set]的其他位置再开一个#tr[block]。比如,拉丁系#tr[character]就新多次新增过#tr[block],至今已有17个。其中一个#tr[block]叫做拉丁扩展B区,其中包含Ƕ(拉丁大写字母 Hwair),在转写汉语拼音时使用的字母,U+013C \u{01C3} 之类表示非洲搭嘴音的符号等。最后这个符号看上去像一个感叹号,但它其实是 \u{01C3}Kung 语言中的一个发卷舌搭嘴音的字母,我们在文本转写中用`Latin Letter Retroflex Click`这个符号来表示它。
// > The distinction between ǃ (Retroflex Click) and ! (exclamation mark) illustrates a fundamental principle of Unicode: encode what you *mean*, not what you *see*. If we were to use the exclamation mark character for both uses just because they were visually identical, we would sow semantic confusion. Keeping the code points separate keeps your data unambiguous.
#note[
\u{01C3}(卷舌搭嘴音) 和 !(感叹号)之间的区别揭示了Unicode中的一个原则:按*语义*而不是*外形*来决定是否#tr[encoding]。如果我们仅仅因为它俩看上去相似,就在这两个地方都用感叹号,这样会产生让人迷惑的语义。从#tr[codepoint]上将它们分离可以让数据不产生歧义。
]
// Here is the complete list of scripts already encoded in Unicode as of version 9.0: Adlam, Ahom, Anatolian Hieroglyphs, Arabic, Armenian, Avestan, Balinese, Bamum, Bassa Vah, Batak, Bengali, Bhaiksuki, Bopomofo, Brahmi, Braille, Buginese, Buhid, Canadian Aboriginal, Carian, Caucasian Albanian, Chakma, Cham, Cherokee, Common (that is, characters used in multiple scripts), Coptic, Cuneiform, Cypriot, Cyrillic, Deseret, Devanagari, Duployan, Egyptian Hieroglyphs, Elbasan, Ethiopic, Georgian, Glagolitic, Gothic, Grantha, Greek, Gujarati, Gurmukhi, Han (that is, Chinese, Japanese and Korean ideographs), Hangul, Hanunoo, Hatran, Hebrew, Hiragana, Imperial Aramaic, Inscriptional Pahlavi, Inscriptional Parthian, Javanese, Kaithi, Kannada, Katakana, Kayah Li, Kharoshthi, Khmer, Khojki, Khudawadi, Lao, Latin, Lepcha, Limbu, Linear A, Linear B, Lisu, Lycian, Lydian, Mahajani, Malayalam, Mandaic, Manichaean, Marchen, Meetei Mayek, Mende Kikakui, Meroitic Cursive, Meroitic Hieroglyphs, Miao, Modi, Mongolian, Mro, Multani, Myanmar, Nabataean, New Tai Lue, Newa, Nko, Ogham, Ol Chiki, Old Hungarian, Old Italic, Old North Arabian, Old Permic, Old Persian, Old South Arabian, Old Turkic, Oriya, Osage, Osmanya, Pahawh Hmong, Palmyrene, Pau Cin Hau, Phags Pa, Phoenician, Psalter Pahlavi, Rejang, Runic, Samaritan, Saurashtra, Sharada, Shavian, Siddham, SignWriting, Sinhala, Sora Sompeng, Sundanese, Syloti Nagri, Syriac, Tagalog, Tagbanwa, Tai Le, Tai Tham, Tai Viet, Takri, Tamil, Tangut, Telugu, Thaana, Thai, Tibetan, Tifinagh, Tirhuta, Ugaritic, Vai, Warang Citi, Yi.
以下是 Unicode 9.0 中#tr[encoding]了的所有#tr[scripts]:Adlam, Ahom, Anatolian Hieroglyphs, Arabic, Armenian, Avestan, Balinese, Bamum, Bassa Vah, Batak, Bengali, Bhaiksuki, Bopomofo, Brahmi, Braille, Buginese, Buhid, Canadian Aboriginal, Carian, Caucasian Albanian, Chakma, Cham, Cherokee, Common (that is, characters used in multiple scripts), Coptic, Cuneiform, Cypriot, Cyrillic, Deseret, Devanagari, Duployan, Egyptian Hieroglyphs, Elbasan, Ethiopic, Georgian, Glagolitic, Gothic, Grantha, Greek, Gujarati, Gurmukhi, Han, Hangul, Hanunoo, Hatran, Hebrew, Hiragana, Imperial Aramaic, Inscriptional Pahlavi, Inscriptional Parthian, Javanese, Kaithi, Kannada, Katakana, Kayah Li, Kharoshthi, Khmer, Khojki, Khudawadi, Lao, Latin, Lepcha, Limbu, Linear A, Linear B, Lisu, Lycian, Lydian, Mahajani, Malayalam, Mandaic, Manichaean, Marchen, Meetei Mayek, Mende Kikakui, Meroitic Cursive, Meroitic Hieroglyphs, Miao, Modi, Mongolian, Mro, Multani, Myanmar, Nabataean, New Tai Lue, Newa, Nko, Ogham, Ol Chiki, Old Hungarian, Old Italic, Old North Arabian, Old Permic, Old Persian, Old South Arabian, Old Turkic, Oriya, Osage, Osmanya, Pahawh Hmong, Palmyrene, Pau C<NAME>, <NAME>, Phoenician, <NAME>, Rejang, Runic, Samaritan, Saurashtra, Sharada, Shavian, Siddham, SignWriting, Sinhala, Sora Sompeng, Sundanese, Syloti Nagri, Syriac, Tagalog, Tagbanwa, Tai Le, Tai Tham, Tai Viet, Takri, Tamil, Tangut, Telugu, Thaana, Thai, Tibetan, Tifinagh, Tirhuta, Ugaritic, Vai, Warang Citi, Yi。#footnote[译注:翻译本段意义不大,其中的 Han 即为汉字。希望了解其他#tr[scripts]的读者可自行查询ISO 15924代码列表@Unicode.ISO15924。]
#note[
// > When you're developing fonts, you will very often need to know how a particular character is encoded and whereabouts it lives in the Unicode standard - that is, its *codepoint*. For example, the Sinhala letter ayanna is at codepoint 3461 (we usually write these in hexadecimal, as 0D85). How did I know that? I could look it up in the [code charts](https://www.unicode.org/charts/), but actually I have a handy application on my computer called [UnicodeChecker](https://earthlingsoft.net/UnicodeChecker/) which not only helps me find characters and their codepoints, but tells me what the Unicode Standard says about those characters, and also what fonts on my system support them. If you're on a Mac, I recommend that; if not, I recommend finding something similar.
当你开发字体时,你经常需要知道一个特定#tr[character]是如何#tr[encoding]的,也就是它处于Unicode标准的什么位置,这种位置就是#tr[codepoint]。比如,僧伽罗语字母ayanna在#tr[codepoint]3461(我们一般写成十六进制,0D85)处。从哪能获取这种信息呢?你可以查看Unicode#tr[character]代码表@Unicode.UnicodeCharacter,但我一般会在电脑上安装一个叫做UnicodeChecker的应用程序@Earthlingsoft.UnicodeChecker.2022。它不仅能很方便地告诉我Unicode中每个#tr[character]的各种信息,还能列出我电脑中支持这个#tr[character]的所有字体。如果你也在使用Mac系统的话,我非常推荐它。如果不是,我也推荐你找找对应平台上的类似应用#footnote[译注:UnicodeChecker只支持macOS,如果你在其他系统上有查询支持某字符的所有字体的需求,译者为此编写过跨平台的命令行工具fontfor @7sDream.Fontfor,可供一试。]。
]
// What should you do if you are developing resources for a script which is not encoded in Unicode? Well, first you should check whether or not it has already been proposed for inclusion by looking at the [Proposed New Scripts](http://www.unicode.org/pending/pending.html) web site; if not, then you should contact the Unicode mailing list to see if anyone is working on a proposal; then you should contact the [Script Encoding Initiative](http://linguistics.berkeley.edu/sei/), who will help to guide you through the process of preparing a proposal to the Unicode Technical Committee. This is not a quick process; some scripts have been in the "preliminary stage" for the past ten years, while waiting to gather expert opinions on their encoding.
如果你想为一个还没#tr[encoding]进Unicode中的#tr[scripts]开发字体的话,首先应该检查已提案#tr[scripts]#[@Unicode.ProposedNew]页面中是否已经有关于此#tr[scripts]的提案。如果没有,那么你应该通过Unicode邮件列表联系他们,看看是否有人正在编写这个提案。要是也没有人正在编写提案,你可以尝试联系一下Script Encoding Initiative#[@ScriptEncodingInitiative.ScriptEncoding]组织。在从前期准备到向Unicode技术委员会提出提案的整个流程中,他们都可以为你提供帮助。这个流程不会很快,有些#tr[scripts]在等待收集专家对其#tr[encoding]意见的“前期阶段”停留了十多年。
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/salsa-dip/0.1.0/examples/z80.typ | typst | Apache License 2.0 | #import "@preview/salsa-dip:0.1.0": dip-chip-label
#set text(font: ("JetBrains Mono", "Fira Code", "DejaVu Sans Mono"), weight: "extrabold")
#set page(width: auto, height: auto, margin: .125cm)
/// Settings Values:
/// chip-label-size: Font size for the chip label
/// pin-number-margin: Margin to give next to pin numbers
/// pin-number-size: Font size for pin numbers
/// pin-label-size: Font size for pin labels
/// include-numbers: Boolean enabling pin numbers
/// pin-spacing: Spacing of pins
/// vertical-margin: Total margin to put into spacing above and below pin labels
#let z80-labels = ("A11", "A12", "A13", "A14", "A15", "CLK", "D4", "D3", "D5", "D6", "VCC", "D2", "D7", "D0", "D1", overline("INT"), overline("NMI"), overline("HALT"), overline("MREQ"), overline("IOREQ"), overline("RD"), overline("WR"), overline("BUSACK"), overline("WAIT"), overline("BUSREQ"), overline("RESET"), overline("M1"), overline("REFRESH"), "GND", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10")
#dip-chip-label(40, 0.54in, z80-labels, "Z80", settings: (pin-number-margin: 1pt, pin-number-size: 2.5pt, chip-label-size: 5pt))
|
https://github.com/imatpot/typst-ascii-ipa | https://raw.githubusercontent.com/imatpot/typst-ascii-ipa/main/README.md | markdown | MIT License | # `ascii-ipa`
🔄 ASCII / IPA conversion for Typst
This package allows you to easily convert different ASCII representations of the International Phonetic Alphabet (IPA) to and from the IPA.
It also offers some minor utilities to make phonetic transcriptions easier to use overall.
The package is being maintained [here][repo].
Note: This is an extended port of the [`ipa-translate`][ipa-translate] Rust crate by [tirimid][tirimid]'s conversion features into native Typst.
Most conversions are implemented according to [this Wikipedia article][ipa-wikipedia] which in turn relies of the official specifications of the respective ASCII representations.
## Conversion
The package supports multiple ASCII representations for the IPA with one function each:
| Notation | Function name |
|----------|-----------------|
| Branner | `#branner(...)` |
| Praat | `#praat(...)` |
| SIL | `#sil(...)` |
| X-SAMPA | `#xsampa(...)` |
They all return the converted value as a [`string`][typst-str] and accept the set of same parameters:
| Parameter | Type | Positional / Named | Default | Description |
|-----------|-----------------------|--------------------|---------|------------------------------------------------------------------------------------------------------------|
| `value` | [`string`][typst-str] | positional | | Main input to the function. Usually the transcription in the corresponsing ASCII-based notation. |
| `reverse` | [`bool`][typst-bool] | named | `false` | Reverses the conversion. Pass Unicode IPA into `value` to get the corresponsing ASCII-based notation back. |
### Examples
All examples use the Swiss German word [⟨Chuchichäschtli⟩ [ˈχʊχːiˌχæʃːtlɪ]][chuchichäschtli] for the conversion.
```typst
#import "@preview/ascii-ipa:2.0.0": *
// returns "ˈχʊχːiˌχæʃːtlɪ"
#branner("'XUX:i,Xae)S:tlI")
// returns "'XUX:i,Xae)S:tlI"
#branner("ˈχʊχːiˌχæʃːtlɪ", reverse: true)
// returns "ˈχʊχːiˌχæʃːtlɪ"
#praat("\\'1\\cf\\hs\\cf\\:f\\'2\\ae\\sh\\:ftl\\ic")
// returns "\\'1\\cf\\hs\\cf\\:f\\'2\\ae\\sh\\:ftl\\ic"
#praat("ˈχʊχːiˌχæʃːtlɪ", reverse: true)
// returns "ˈχʊχːiˌχæʃːtlɪ"
#sil("}x=u<x=:i}}x=a<s=:tli=")
// returns "}x=u<x=:i}}x=a<s=:tli="
#sil("ˈχʊχːiˌχæʃːtlɪ", reverse: true)
// returns "ˈχʊχːiˌχæʃːtlɪ"
#xsampa("\"XUX:i%X{S:tlI")
// returns "\"XUX:i%X{S:tlI"
#xsampa("ˈχʊχːiˌχæʃːtlɪ", reverse: true)
```
### With `raw`
You can also use [`raw`][typst-raw] for the conversion.
This is useful if the notation uses a lot of backslashes.
```typst
#import "@preview/ascii-ipa:2.0.0": praat
// regular string
#praat("\\'1\\cf\\hs\\cf\\:f\\'2\\ae\\sh\\:ftl\\ic")
// raw
#praat(`\'1\cf\hs\cf\:f\'2\ae\sh\:ftl\ic`)
```
Note: `raw` will not play nicely with notations that use ``` ` ``` a lot.
## Brackets & Braces
You can easily mark your notation text as different types of brackets or braces.
```typst
#import "@preview/ascii-ipa:2.0.0": *
#phonetic("prʲɪˈvʲet") // [prʲɪˈvʲet]
#phnt("prʲɪˈvʲet") // [prʲɪˈvʲet]
#precise("prʲɪˈvʲet") // ⟦prʲɪˈvʲet⟧
#prec("prʲɪˈvʲet") // ⟦prʲɪˈvʲet⟧
#phonemic("prɪvet") // /prɪvet/
#phnm("prɪvet") // /prɪvet/
#morphophonemic("prɪvet") // ⫽prɪvet⫽
#mphnm("prɪvet") // ⫽prɪvet⫽
#indistinguishable("prʲɪˈvʲet") // (prʲɪˈvʲet)
#idst("prʲɪˈvʲet") // (prʲɪˈvʲet)
#obscured("prʲɪˈvʲet") // ⸨prʲɪˈvʲet⸩
#obsc("prʲɪˈvʲet") // ⸨prʲɪˈvʲet⸩
#orthographic("привет") // ⟨привет⟩
#orth("привет") // ⟨привет⟩
#transliterated("privyet") // ⟪privyet⟫
#trlt("privyet") // ⟪privyet⟫
#prosodic("prʲɪˈvʲet") // {prʲɪˈvʲet}
#prsd("prʲɪˈvʲet") // {prʲɪˈvʲet}
```
[repo]: https://github.com/imatpot/typst-ascii-ipa
[ipa-translate]: https://github.com/tirimid/ipa-translate
[tirimid]: https://github.com/tirimid
[ipa-wikipedia]: https://en.wikipedia.org/wiki/Comparison_of_ASCII_encodings_of_the_International_Phonetic_Alphabet
[typst-str]: https://typst.app/docs/reference/foundations/str/
[typst-bool]: https://typst.app/docs/reference/foundations/bool/
[typst-raw]: https://typst.app/docs/reference/text/raw/
[chuchichäschtli]: https://als.wikipedia.org/wiki/Chuchich%C3%A4schtli
|
https://github.com/Tyrn/wei | https://raw.githubusercontent.com/Tyrn/wei/master/robinson-pip.typ | typst | #let to-string(content) = {
if content.has("text") {
content.text
} else if content.has("children") {
content.children.map(to-string).join("")
} else if content.has("child") {
to-string(content.child)
} else if content.has("body") {
to-string(content.body)
} else if content == [ ] {
" "
} else {
content
}
}
#let shouldIgnoreHeading(suppl) = {
let lang = text.lang
let sectionsInLanguages = (
"en": [Section],
"es": [Sección],
"ru": [Раздел],
// Add more languages here as necessary
)
return suppl == sectionsInLanguages.at(lang)
}
#let formatDoc(cnt) = [
#show outline.entry: it => {
if it.element.bookmarked == false {
return
}
if shouldIgnoreHeading(it.element.supplement) {
return
}
let body = it.body
let elem = it.element
// let cpy = body.fields()
let title = to-string(body)
let description = text(style: "normal", size: 10pt)[
#to-string(body)
]
if elem.level == 1 {
return link(elem.location())[
#v(30pt)
#set align(center)
#smallcaps[#text(
size: 18pt
)[#elem.supplement]]
//#set align(left)
#description
]
}
//else
return link(elem.location())[
#let sizes = (12pt, 10pt, 6pt)
#set align(center)
#smallcaps[#text(
size: sizes.at(elem.level - 2)
)[#elem.supplement]]
#set align(left)
#set par(
hanging-indent: 1em,
first-line-indent: 0em,
justify: true,
)
#description #box(width: 1fr, repeat[.]) #it.page
]
}
#show heading: it => {
if shouldIgnoreHeading(it.supplement) {
return
}
return [
#set align(center)
#it.supplement
#it.body
]
}
#cnt
]
#let makeHeading(title, content, level) = [
#v(10pt)
#heading(
level: level,
)[#title]
#heading(
level: level,
supplement: title
)[
#set align(center)
#text(size: 11pt, weight: "semibold", style: "normal")[
#box(width: 80%)[#content]
]
]
#v(10pt)
]
#let part(title, content) = {
makeHeading(title, content, 1)
}
#let chapter(title, content) = {
makeHeading(title, content, 2)
}
|
|
https://github.com/ssotoen/gridlock | https://raw.githubusercontent.com/ssotoen/gridlock/main/CHANGELOG.md | markdown | The Unlicense | # Changelog
<!-- ## Added
## Removed
## Changed
## Migration Guide from v0.1.X -->
## v0.2.0 (2024-10-19)
- Added support Typst 0.12’s new `par.spacing` property
- Replaced a deprecated `location` call with the new `context`
## v0.1.0 (2024-08-06)
Initial Release
|
https://github.com/Wh4rp/Presentacion-Typst | https://raw.githubusercontent.com/Wh4rp/Presentacion-Typst/master/ejemplos/13_show-rest.typ | typst | #show: rest => columns(2, rest)
= Introduction
#lorem(15)
= Related Work
#lorem(2)
= Related Work
#lorem(2) |
|
https://github.com/Tiggax/zakljucna_naloga | https://raw.githubusercontent.com/Tiggax/zakljucna_naloga/main/src/sec/3metode.typ | typst | #set heading(offset: 1)
#import "/src/additional.typ": todo
#import "@preview/sourcerer:0.2.1": code
#import "@preview/oxifmt:0.2.1": strfmt
In order to model the bioreactor a system of @ODE was created.
An application (discussed further in @app-sec) was built for calculations of the system of @ODE used to model the bioreactor.
= Data of a bioreactor process
Data for bioreactor model fitting was randomly generated from data points in approximate industrial bioreactor processes.
The Dataset can be seen in @data_figure.
#figure(
caption: [data, consisting of different values, and points of no known data.],
table(
columns: 6,
fill: (x,y) => if y == 0 {color.mix(teal, white)
},
table.header(
[days], [@VCD], [glutamine], [glucose],[$"DO"_50$], [product]
),
..csv("/podatki/data.csv").slice(1).flatten().map(x => [#strfmt("{:.7}",x)])
)
)<data_figure>
= The System of ordinary differential equations
#let d(n) = $d(#n)/(d t)$
The system was implemented as a `system` function for `ode_solvers` library to use.
For it to work it needed to implement the "`ode_solvers::System<Time, State>`" seen in @trait.
The value `Time` was expressed in a 64 bit float, and the `State` was an `SVector` of length 7 for each of the variables expressed as 64 bit float values.
#let snippet = raw(read("/data/model.rs"), lang: "Rust")
#figure(
caption: [Trait implementation for the system],
kind: image,
code(snippet, lines: (238,238), )
)<trait>
== Viable Cell density<vcd-sec>
Viable cell density or @VCD, expresses the number of viable cells in the reactor.
It is expressed as $10^6 "Cell/mL"$ ($"MVC"/(m L)$) where the only living cells are counted.
The model assumes that viability is 100%, this meaning that 100% of cells in the bioreactor are alive at every increment.
In the model the value is calculated with
$
#d("VCD") = mu dot n_"VCD" dot "VCD"
$
$n_"VCD"$ is a production phase growth constant.
This constant changes on the day that the Temperature shift occurs.
$mu$ is calculated with
$
mu = mu_"max" * (c_"gluc" / ("Ks"_"gluc" + c_"gluc")) * (c_"glut" / ("Ks"_"glut" + c_"glut")) * (c_"O2" / ("Ks"_"O2" + c_"O2"))
$
where $mu_"max"$ is a constant that varies from different strand of @CHO cells.
This constant is then multiplied with each of the dependant variables using Monod kinetics talked about in @monod_sec.
== Glucose and glutamine
#let cgk = $c$
Glucose and glutamine follow simple negative value dependant on
$
#d(cgk) = - k_#cgk * "VCD" * (#cgk / ( "Ks"_#cgk + #cgk))
$
where $#cgk$ is the concentration of the substance, and $k_#cgk$ is the depletion constant, while the $"Ks"_#cgk$ is the half-saturation constant.
== Product
Product is a substitute for a unknown _metabolite_, that is developed during the bioreactor process.
$
#d($c_p$) = k_p * "vcd"
$
where $k_p$ is a product constant that is changed dependant on the producing product.
== Oxygen
=== PID control
For oxygen control a theoretical controller similar to one written about in @pid_sec was used.
For control only the proportional part was used.
The model is one dimensional and describes an ideally mixed fed-batch bioreactor, which means that the response of the regulation is fast and the proportional part of the @PID regulator is sufficient of efficient regulation.
=== Sparger aeration
The model uses a sparger with a mixer that dilutes the oxygen into the system. While @PID control injects pure oxygen, the sparger air rates the system with filtered air (21% oxygen).
The air flow from the sparger and the are combined.
Afterwards $k L a$ (Volumetric Mass Transfer Coefficient) is calculated specific to the system using the power input of the system and the combined flow.
Next the the amount of oxygen released into the system is calculated, by using the Henry's constant.
Afterwards oxygen transfer rate (@OTR) is calculated from which oxygen uptake rate (@OUR) is substracted to get the oxygen change.
== Total balance
Since the bioreactor model is receiving a steady supply of substrate, total balance of the system needs to be calculated.
@VCD and product get diluted, while glucose and glutamine can get concentrated given if the concentration of the feed is bigger than the concentration of the bioreactor.
== parameters of the system
The system was defined with constants seen in @constants. It should be assumed, that any omitted values will be as in @constants.
#import "/src/figures/mod.typ": constants_fig
#figure(
caption: [Default constants of the system],
constants_fig("default")
)<constants>
= the Application<app-sec>
The application was built in the Rust programing language and built using community packages seen in @deps.
@ODE were computed using a modified version of `ode_solvers` package.
The package changed the provided `y` values of each iteration to become mutable, meaning the values of any current step could be modified.
This was made so that the @PID controller values could reflect the current output of each step.
Dependencies `serde`, `serde_json` and `csv` were used for data serialization.
This was used to ease the injection of data, the system values and to be able to save the results of the minimization.
#let deps = toml("/data/Cargo.toml")
#figure(
caption: [Cargo Dependencies used and their versions],
table(
columns: 2,
fill: (x,y) => if y == 0 {color.mix(teal, white)},
table.header(
[Library],[Version],
),
..deps.dependencies.pairs().map(((name, version)) => (
[#name],if type(version) == str {[#version]} else if "version" in version.keys(){[#version.version]} else {[#version.git<#version.branch>]}
)).flatten(),
)
)<deps>
@UI was implemented using the `egui` library, separating the space into two parts as seen in @bion-app.
Left pane was used to control the model, while the right side showed a graph of the individual values over the period of the process.
Each of the values could be individually inspected to see their change of values, and the graph could be zoomed in to see changes in detail.
Left pane contained four sections.
The general settings, where the model could be reset, loaded from a `json`, or loaded to the previous instance.
The simulation parameters, where all of the parameters of the system could be modified to manually tweak the system.
Data control section where data points for fitting could be loaded in using a `csv` file or cleared.
This section also included a button to save the result of the system exported as a `csv` file, with a `json` file with the same name generating alongside with the state of the system.
Finally the minimization section contained two sub-sections.
First section named the minimization target offered a selection of the target value to be minimized, with choices being $mu_"max"$, `n_vcd`, feed rate, PID control oxygen absorption constant (`constants.oxygen`), and constants of product, glutamine and glucose.
Second section contained selection of which data to use as minimization evaluation.
The first option `Mixed` used all point nodes of the data, to try to fit the system optimally, while using only one of the other options minimized the system using only the nodes of that values.
Finally the button "Minimize" ran the minimization process with the system values.
#figure(
caption: [Image of the application interface],
image("/figures/bion-app.png")
)<bion-app> |
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/text/emphasis_00.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
// Basic.
_Emphasized and *strong* words!_
// Inside of a word it's a normal underscore or star.
hello_world Nutzer*innen
// CJK characters will not need spaces.
中文一般使用*粗体*或者_楷体_来表示强调。
日本語では、*太字*や_斜体_を使って強調します。
中文中混有*Strong*和_Empasis_。
// Can contain paragraph in nested content block.
_Still #[
] emphasized._
|
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/compiler/call-08.typ | typst | Other | // Error: 2:1 expected closing bracket
#func[`a]`
|
https://github.com/saYmd-moe/note-for-quantum--mechanics | https://raw.githubusercontent.com/saYmd-moe/note-for-quantum--mechanics/main/README.md | markdown | # Stationary Perturbation Theory
该仓库为使用typst编写的定态微扰理论的笔记,主要参考 _Quantum Mechanics, Vol. 2 - Cohen-Tannoudji_ 。
|
|
https://github.com/soul667/typst | https://raw.githubusercontent.com/soul667/typst/main/PPT/MATLAB/touying/docs/docs/progress/counters.md | markdown | ---
sidebar_position: 1
---
# Touying Counters
The states of Touying are placed under the `states` namespace, including all counters.
## Slide Counter
You can access the slide counter using `states.slide-counter` and display the current slide number with `states.slide-counter.display()`.
## Last-Slide Counter
In some cases, we may need to add an appendix to slides, leading to the requirement to freeze the last-slide counter. Therefore, a second counter is maintained here.
You can use `states.last-slide-number` to display the number of the last slide before the appendix.
## Progress
You can use
```typst
#states.touying-progress(ratio => ..)
```
to show the current progress.
## Appendix
You can use
```typst
// appendix by freezing last-slide-number
#let s = (s.methods.appendix)(self: s)
#let (slide,) = utils.methods(s)
#slide[
appendix
]
```
syntax to enter the appendix.
Additionally, `#let s = (s.methods.appendix-in-outline)(self: s, false)` can be used to hide the appendix section from the outline. |
|
https://github.com/Area-53-Robotics/53E-Notebook-Over-Under-2023-2024 | https://raw.githubusercontent.com/Area-53-Robotics/53E-Notebook-Over-Under-2023-2024/giga-notebook/entries/visualization/identify.typ | typst | Creative Commons Attribution Share Alike 4.0 International | #import "/packages.typ": notebookinator
#import notebookinator: *
#import themes.radial.components: *
#show: create-body-entry.with(
title: "Identify: Data Visualization",
type: "identify",
date: datetime(year: 2023, month: 11, day: 11),
//author: "<NAME>",
//witness: "<NAME>",
)
#metadata(none) <loginator-identify>
Live data visualization is an incredibly powerful tool that could completely
revolutionize how we approach tuning, debugging and testing. It would help us
get a bigger picture of whats going on while debugging, instead of just a slice
in time, and would do so in real time, instead of after program runs.
In the past we've used Matplotlib, a popular Python#footnote("See glossary") <nb-gl> library,
to graph data from a .csv file #footnote(<nb-gl>). This approach is extremely
slow and cumbersome. It requires many different steps to get the information off
the brain and into a format that Matplotlib can read. This usually adds around a
minute of work each time we want to visualize data.
Live graphing would allow us to view data in an understandable way, with zero
time overhead.
#image("./identify.svg", width: 60%)
= Design Goals
- Our solution must visualize data in real time
- Our solution must have minimal extra overhead in effort required to set it up
Overall we want it to be as easy to use as possible, and refrain from inhibiting
our current workflow as little as we can.
= Design Constraints
- Cannot rely on things like network connectivity
- The V5 brain can have a very low bandwidth when it comes to sending wireless
data. This may be an issue when it comes to the amount of data we can send.
|
https://github.com/mumblingdrunkard/mscs-thesis | https://raw.githubusercontent.com/mumblingdrunkard/mscs-thesis/master/src/architecture-and-implementation/index.typ | typst | = Architecture and Implementation <ch:architecture-and-implementation>
In this chapter, we cover the architecture and implementation of the predictor and how it connects to other components in the BOOM core.
We start by summarising the work done previously.
== Previous Work
*Disclaimer:* this section is presenting work that was done before work on this project started, but it is relevant to understanding the rest of the work that has been done, thus we have included it here.
Work in following sections is done afterwards and for this thesis.
In a preparartion for this project, we implemented and started integrating a load-address predictor based on instruction addresses @bib:nodland-paper.
As load instructions commit, they are sent to the predictor to train it.
The predictor detects simple strided patterns.
=== The Predictor
We opted for a simple strided predictor for testing purposes.
A strided predictor detects _strides_ in the address stream generated by load instructions.
I.e. the predictor detects when the same load instruction accesses addresses in consistent increments (or decrements).
The predictor is accessed using instruction address of a load instruction and the storage is organised like a direct-mapped cache.
The storage uses full-width tags (based on instruction addresses) to prevent aliasing as described in @bib:doppelganger.
This simple organisation and implementation was chosen to ensure predictions could be generated quickly on demand.
Each entry of the predictor contains a tag, the previous accessed address, a stride, and the confidence of this prediction.
Predictions are based on physical addresses because that is the information available to the predictor at the commit side.
This has necessitated changing the predictor slightly so that predictions that fall outside of the page of the previous access must be considered invalid so as to not cause exceptional conditions.
Thus, if the new prediction increases the page number in the address, the prediction is marked as invalid.
=== Efficient Predictor Storage
The predictor storage is organised as a specialised cache and is accessed using bits of the instruction address.
As the BOOM is a superscalar microarchitecture, it is possible that multiple predictions need to be read or updated at the same time.
One major discovery from @bib:nodland-paper is that the predictor storage can be implemented efficiently by splitting the storage into multiple banks where each bank requires only one write port and two read ports.
This optimisation relies on the fact that the frontend and backend of the BOOM only dispatch and commit consecutive instructions up to the width of the processor.
The optimisation is trivial when instruction addresses always align to a four-byte boundary.
By using a power-of-two number of banks larger than or equal to the processor width, assigning a bank per instruction is as simple as taking bits $2+n-1:2$ (inclusive range) of the instruction address and using that as an index.
The nature of consecutive instruction addresses guarantees that this scheme yields different banks for each of the incoming instructions.
However, as the BOOM supports the C-extension of RISC-V, instructions can align to two-byte boundaries and may be either four or two bytes wide.
This creates complexity in determining the appropriate banks for consecutive instructions.
In @bib:nodland-paper we showed a simple scheme that provides fairness---similar usage across all banks---and has a low complexity, requiring only an XOR-gate and a concatenation of bits to get the appropriate bank number.
Due to time constraints and the fact that we only ran simulations, the actual implementation uses a single bank with many ports but still uses the algorithm to select the appropriate port.
Synthesis tools are unlikely to detect that the port numbers are guaranteed to be different and is thus unlikely to generate the optimal implementation.
Instead, a proper implementation that exploits this property would need to use something similar to a crossbar switch.
Our original thinking was that this crossbar switch could be implemented physically with tri-state buffers in an integrated circuit.
This supposedly poses some challenges with capacitances in shared wires and such, but the reduced port count should still be advantageous.
RISC-V technically supports more instruction sizes in increments of 16 bits, but none of the ratified extensions thus far use instructions larger than 32 bits.
Adding more instruction sizes while keeping the alignment requirements of 16 bits adds more complexity in bank selection logic.
=== Training the Predictor
Along with the scheme for efficient predictor storage we displayed the predictor's ability to detect strides in the addresses accessed by committed load instructions by showing an increasing confidence value in an entry of the predictor.
The predictor is only trained on cacheable addresses to prevent sending spurious load instructions to locations that may have side-effects.
== Integrating the Predictor
Here we describe the process of integrating the predictor into the system and sending predictions to the LSU and how they are handled from there.
@fig:doppelganger-load-architecture is how we have implemneted it in the BOOM, but it is included in the previous chapter to illustrate concepts around how doppelgangers work.
=== Generating Predictions for Incoming Load Instructions
The core is connected to the predictor and the predictor receives the uOPs that are sent to the decode units, thus the predictor starts quite early in the pipeline.
Because the predictor receives "raw" instructions, bits like `is_load` in the uOP are not yet set.
From here, the predictor generates a prediction by looking up in the storage to see if there is a matching entry.
If there is a matching entry, a prediction is created by adding the stride to the previous address.
If there is a match, the instruction is guaranteed to be a load instruction as the only way the entry would have ended up in the predictor storage in the first place is by receiving a committed load.
It is still reasonable to perform a simple check to see whether the instruction is a load and use clock-gating to conserve the power spent accessing the predictor storage, but this has not been done for the sake of saving time.
=== Sending Predictions to the Load-Store Unit
The predictor only sends a single prediction to the LSU per cycle, no matter the width of the memory interface.
When multiple predictions are generated in the same cycle, the one with the highest confidence is prioritised.
Predictions are not buffered, so if there is available capacity in the LSU the next cycle, but no predictions generated, the LSU stalls.
In the LSU, the predicted addresses are stored next to the real addresses in the LDQ.
In a final implementation, these two slots should be merged, but they are separated for simpler debugging and implementation.
All predictions generated by the predictor are stored in the LDQ, even if they are not used.
This is done purely for tracking statistics.
Predictions are prioritised over various wakeup signals, but can not take priority over the `_incoming` signals.
The `_incoming` signals in the LSU are generated by AGUs and cannot be back-pressured because the AGUs are 0-cycle FUs, meaning they must be handled as they arrive.
`_wakeup` and similar signals are decided by the LSU itself, so we can safely prioritise doppelganger loads over them.
We have made efforts to properly synchronise the predictions that enter the LSU with the uOPs that arrive from dispatch/rename to the LSU.
Because predictions are based on uOPs that have not yet passed through rename, the LDQ index has not yet been generated.
LDQ entries are allocated in the LSU during the decode stage.
Most of the time, the naive approach works by assuming a fixed number of cycles from entering decode until leaving dispatch/rename.
Sometimes there is back-pressure and the predictions fall out of synchronisation with the uOPs from dispatch.
This is slightly difficult to fix without hooking into a lot of stalling logic, which we wanted to avoid for simplicity.
In the LSU, prediction PCs are compared with dispatched uOPs' PCs to verify that they belong to the correct instruction and are otherwise ignored when they are unsynchronised.
=== Passing Predictions to the Data Cache
As predictions arrive and there is available capacity, the LSU will issue a doppelganger load to the data cache.
The request is marked as such and flows almost like a normal load, except that if it misses, it is not passed to the MSHRs but is dropped instead.
The corresponding LDQ entry is marked as executed to prevent mechanisms like wakeup or triggering extra loads when the real address arrives.
Marking entries as executed, or at least triggering the pipeline that eventually marks them as such, also triggers additional mechanisms such as checking for ordering violations and such.
One important difference between doppelganger loads and normal loads is that doppelganger loads do not trigger the speculative load wakeups.
Speculative load wakeup is on a fixed cycle offset from issuing the load to the L1d and care must be taken to ensure doppelgangers suppress this logic.
=== Problems with Missing Mispredicted Doppelgangers
In the case of doppelgangers that miss, the LSU is informed to ensure the corresponding entry is marked as such.
Otherwise, in the case of a correct prediction, the LSU will be waiting for a response that never arrives.
Dropping the missing doppelgangers was done to save time from working around a bothersome issue where:
+ a doppelganger was issued to the data cache,
+ the doppelganger missed and was placed in a MSHR,
+ the doppelganger used an incorrect prediction,
+ the real load hit in the cache and returned its value before the doppelganger could complete,
+ the doppelganger finally returned, extremely late with no clear indication as to whether the LDQ slot had already been re-allocated for a new load, which was predicted correct, then
+ the extremely old doppelganger propagated its value to the wrong instructions.
In a proper implementation of doppelganger loads, doppelgangers should be allowed to miss in the first-level cache.
This requires the MSHRs to be informed when a doppelganger that missed is determined to be mispredicted so that the request can be dropped or tagged so that the request can be properly ignored when returning to the LSU.
=== When the Real Address Arrives
When the real address arrives from an AGU, the LSU raises a signal named `can_fire_load_incoming`.
This signal has the highest priority, so `will_fire_load_incoming` will always be high, barring a lack of capacity for other reasons such as back-pressure from the L1d.
After inspecting the relevant signals from the AGU, the LSU performs a lookup in the LDQ to check whether the address is for a previously predicted (and executed) doppelganger.
If it is, the predicted address is compared to the output from the TLB (unless it missed).
When the address is confirmed, the corresponding entry is marked as correct.
Here, it is important that the `can_fire_load_incoming` and `will_fire_load_incoming` signals are not suppressed if the prediction is determined to be correct.
We were under the assumption that doing this would allow the LSU to prioritise other actions that require the same resources, but these signals are used to select the input to the TLB, whose outputs are used to compare to the predicted address, whose output would be used to suppress the aforementioned signals, which are used to select the inptu to the TLB.
That is a combinational loop.
This handling is unfortunate as the LSU in theory would be able to issue wakeup operations for loads that have had their address translated but could not be issued to the L1d for other reasons.
=== Store Value Forwarding
If an older store aliases with a newer doppelganger load, the doppelganger receives the forwarded value and the request to L1d is squashed.
=== Handling Responses From the Data Cache
Normal responses from the L1d are sent straight to the PRF as they are already based on real addresses and dependent instructions can begin executing.
Doppelganger loads require holding off dependent instructions until the address is confirmed.
Because of time constraints, we have not implemented the logic to hold values in the PRF until they are ready.
Instead, the values are held in the LDQ until the address is confirmed and the writebacks are scheduled.
=== Sending Responses to the Physical Register File
An AGU can generate an address (and thus confirm a prediction) in the same cycle that the LSU receives a response from the L1d for a non-doppelganger load.
As confirmed doppelgangers and real loads have to share the same writeback ports, the doppelgangers are only written back when there is available capacity.
A priority mux detects confirmed, unsent doppelgangers and writes back the values when no other instructions require the ports.
Lower absolute indices in the LDQ are given priority.
A slightly more optimal strategy would be to prioritise from the head of the LDQ which is implemented as a circular buffer, ensuring that the oldest confirmed doppelgangers are sent to the PRF as soon as possible.
As this is not intended to be part of the completed solution, we choose this method of writebacks as an acceptable compromise for the time constraints.
|
|
https://github.com/RiccardoTonioloDev/Bachelor-Thesis | https://raw.githubusercontent.com/RiccardoTonioloDev/Bachelor-Thesis/main/preface/dedication.typ | typst | Other | #pagebreak(to: "odd")
#set page(numbering: none)
#v(3cm)
#v(2cm)
#align(center, [
A mia madre e mio padre, i migliori che potessi avere
])
|
https://github.com/Myriad-Dreamin/tinymist | https://raw.githubusercontent.com/Myriad-Dreamin/tinymist/main/crates/tinymist-query/src/fixtures/post_type_check/user_external.typ | typst | Apache License 2.0 | // path: base.typ
#let tmpl(content, font: none) = {
set text(font: font)
content
}
-----
#import "base.typ": *
#tmpl(font: /* position after */ ("Test",))[]
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/unichar/0.1.0/ucd/block-AAE0.typ | typst | Apache License 2.0 | #let data = (
("MEETEI MAYEK LETTER E", "Lo", 0),
("MEETEI MAYEK LETTER O", "Lo", 0),
("MEETEI MAYEK LETTER CHA", "Lo", 0),
("MEETEI MAYEK LETTER NYA", "Lo", 0),
("MEETEI MAYEK LETTER TTA", "Lo", 0),
("MEETEI MAYEK LETTER TTHA", "Lo", 0),
("MEETEI MAYEK LETTER DDA", "Lo", 0),
("MEETEI MAYEK LETTER DDHA", "Lo", 0),
("MEETEI MAYEK LETTER NNA", "Lo", 0),
("MEETEI MAYEK LETTER SHA", "Lo", 0),
("MEETEI MAYEK LETTER SSA", "Lo", 0),
("MEETEI MAYEK VOWEL SIGN II", "Mc", 0),
("MEETEI MAYEK VOWEL SIGN UU", "Mn", 0),
("MEETEI MAYEK VOWEL SIGN AAI", "Mn", 0),
("MEETEI MAYEK VOWEL SIGN AU", "Mc", 0),
("MEETEI MAYEK VOWEL SIGN AAU", "Mc", 0),
("MEETEI MAYEK CHEIKHAN", "Po", 0),
("MEETEI MAYEK A<NAME>", "Po", 0),
("MEETEI MAYEK ANJI", "Lo", 0),
("MEETEI MAYEK SYLLABLE REPETITION MARK", "Lm", 0),
("MEETEI MAYEK WORD REPETITION MARK", "Lm", 0),
("MEETEI MAYEK VOWEL SIGN VISARGA", "Mc", 0),
("MEETEI MAYEK VIRAMA", "Mn", 9),
)
|
https://github.com/polarkac/MTG-Stories | https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/033%20-%20Rivals%20of%20Ixalan/004_Sabotage.typ | typst | #import "@local/mtgstory:0.2.0": conf
#show: doc => conf(
"Sabotage",
set_name: "Rivals of Ixalan",
story_date: datetime(day: 31, month: 01, year: 2018),
author: "<NAME> & <NAME>",
doc
)
= Around 1,300 Years Ago
A soft breeze passed over an open steppe, herds of grass-eating beasts peacefully passed the walls of a great city of glass and stone, and in a ripple of air, a dragon tore through the sky from a faraway world.
His name was Ugin, and his purpose was, and always had been, singular.
Crowds of people gathered as he approached from above and cheered at the sight of the dragon. They guided him toward the center of the city. They smiled to see Ugin, for the Arbiter of Law told them the Spirit Dragon could be trusted. Ugin was led through the city with great fanfare, and eventually found his associate at the top of the stairs leading to what the citizens told him was the Palace of Justice.
The sphinx was a hieromancer who had lived for 10,000 years. His causes were noble even if his reasons were not.
"Ugin, my friend," Azor said with a flourish of his wings and a bow of his head, "welcome to my newest home."
The sphinx flicked his flight feathers, and a small pulse of law magic caused the crowd around them to turn around and leave.
"What brings you to this plane?" Azor asked.
The Spirit Dragon spoke to Azor. "When we last met, we discussed our common foe."
"What of him?" asked Azor. He looked around nervously. "Is this world in danger?"
The destroyer had arrived suddenly on one of Azor's patron worlds, wiped away Azor's work, and built a new empire for his own cryptic purposes.
Ugin met the sphinx less than a decade later and revealed the scourge's name, his methods, and his villainous history.
"Every world is in danger, as long as our enemy is free and whole. That is why I am here. I have devised a plan to rid the Multiverse of his influence, but I cannot do it without you."
The sphinx replied, "I have established law on countless worlds. I have created structure where once there was none. I would be most honored to share the immensity of my gifts with you, dear friend."
Ugin was pleased. "Together we will rid the Multiverse of <NAME>."
The plan they hatched required success on two fronts: they would need a means and opportunity to pull their enemy into their prison, and a lock to contain and neutralize him there. As they conversed, Azor excitedly outlined the hieromancy necessary to create an object that would enhance his own law magic—giving him the ability to summon the golden dragon from any location in the Multiverse. It would require the sacrifice of his own spark, but with Ugin's assistance, that could be reclaimed after <NAME> was destroyed. "There is a plane I have been wanting to bring order to—a world called Ixalan. I will build the Immortal Sun there, on the continent of Torrezon."
Azor would no longer be a Planeswalker, but the Immortal Sun would amplify his hieromancy with all the power of his severed spark, allowing him to work magic a mortal sphinx could never hope to create. Unaided, their foe would be summoned to the cage no matter what plane he was on. The device would also serve as a lock to their prison, ensuring their planeswalking enemy would have no means of escape. Ugin assured Azor that, thanks to centuries of planning, he had secreted away a means to remove <NAME> from existence for good. They needed only capture the golden dragon, and their task would be complete.
"You will have to lure him to a specific location," Azor said. "I will need to know where to aim in order to summon him to the prison."
Ugin, naturally, had thought all of this through, for he was as cunning as he was conniving. "I will lure him to Tarkir."
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
"Tell me more of this #emph[lawbringer] ," drawled <NAME> as he casually tore off the right arm of the minor functionary he held in his talon. An elf, the leader of whatever-this-place-was and the overseer of who-cares.
As <NAME> used the severed appendage to slap the man repeatedly, he reflected that he should not allow himself to be so easily tempted into savagery by the foolishness of mortals, particularly not when even the slightest use of his telepathic ability would suffice to get the information he needed. Nevertheless, the slaps had the desired effect, dispelling the man's shock long enough to produce an answer. There was a certain feeling of joy Bolas achieved only by punishing stupidity.
While all this elf's fellow bureaucrats—and everyone else in the city—had been sensibly running for their lives, this one pathetic fool had remained in the plaza. He had begun hurling insults. At an elder dragon. He had sworn that the lawbringer would soon return, and would once more bring an end to evil. #emph[Such tired invective] , thought Bolas as the elf blubbered, telling all he knew and begging for his life.
#emph[The sphinx. Again, the sphinx.] This was the third plane Bolas had encountered where the people revered a sphinx who had come from a faraway land. He knew now that it was no coincidence. The stories were too similar—always the sphinx came from a distant, unknown place, and always he imposed a system of justice on the populace before disappearing again, leaving laborious legal codes and, in the case of this plane, pretentious statuary in his wake. #emph[A planeswalker] , Bolas thought, #emph[a hieromancer most like, and, it would seem, an enemy] .
The statue, large in its own right, had been installed (rather too ostentatiously in Bolas's view) atop the largest building in the city—an official-looking marble hall that towered over the plaza. The dragon carefully lowered the bleeding bureaucrat onto the head of the statue before releasing him, waiting for a moment to be sure the elf found steady footing. "Fear not, mortal," sneered Bolas as he made to depart. "From all you've told me, I am sure your lawbringer will return to aid you well before you bleed to death."
"Azor," the weakling had said. The sphinx was called Azor. Resolving to learn as much as he could about this Azor, Bolas smiled contemptuously for a moment at the man teetering on the statue. Then he unfurled his giant wings and took to the sky.
Over many years, and across many planes, <NAME> sought clues to the sphinx's agenda. Finally, on a plane wracked by war, Bolas came upon a lawmage staring forlornly down at a broken statue—yet another garish reminder of the fabled lawbringer.
#emph[The Arbiter of Law turned our world against itself] , the lawmage thought, and a flood of images flowed from her mind as <NAME> attuned to her and began to unravel the threads of her existence. #emph[To think that I worshipped him as a savior when his solutions only broke a world that did not need fixing. To think that the day I spent hiding in the Palace of Justice, listening to him and the Spirit Dragon plot the end of the True Evil, I thought I was as close as any mortal would ever be to the divine . . .]
<NAME> savored the taste of the lawmage's ultimate despair as she died. #emph[A true evil] , he thought, #emph[how flattering . . .]
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
Azor stood on the shores of Torrezon in a maelstrom of his own magic.
The sphinx performed a feat of hieromancy that no being had ever attempted and none would ever be able to match, severing his spark to create the artifact he called the Immortal Sun. The sphinx stood atop his masterpiece, exhausted yet ever prideful.
He spoke across worlds, for this was a time when Planeswalkers possessed the strength of gods. "Ugin, my strength is increased tenfold with the help of my creation. I am ready to secure our prisoner."
Ugin heard, and answered in kind. His voice traveled across the Blind Eternities and resonated clearly in Azor's mind. "Our life's work will be complete soon, my friend," Ugin said, coating "friend" with the lure of kinship Azor had never been able to resist. "I have only to bait the trap and wait for the destroyer to arrive."
Ugin soared above the craggy mountains of Tarkir, so absorbed in making preparations that he could not suppress his utter shock when his nemesis appeared before him.
Bolas's wings spread wide in Ugin's path, like a billowing cloak, and his scales glinted in the light of the storm around him.
"Your idiot cat is too fond of statues of himself," <NAME> mused. "I might not even have been listening to your charming long-distance talks if he hadn't left so many little clues here and there."
Ugin bristled. "The Immortal Sun will seal you in your prison, Planeswalker."
<NAME> laughed, and launched himself at his foe as his laugh broadened into a deafening roar.
They fought and raged through the air, titans in a tempest.
#figure(image("004_Sabotage/01.jpg", width: 100%), caption: [Crux of Fate | Art by <NAME>], supplement: none, numbering: none)
But Bolas lifted a claw, and hundreds of pairs of dragon eyes looked down on Ugin in unison. They curved their great bodies and dove to attack. The Spirit Dragon tried to escape, but was caught in a tempest of fire and claws.
He hit the ground. He would have died, perhaps, but a man out of time intervened. That man preserved Ugin's body in a cocoon of stone and vanished.
And <NAME> planeswalked away, never to return, for he had won.
Azor waited for a year.
He kept vigil, standing atop the Immortal Sun with his attention focused on the heavens, waiting for a signal from his friend.
But no signal ever came, and by the time Azor realized that something must have happened to Ugin, there was no dragon to summon. No foe to seal in his trap. No great sacrifice to be made in the fight against evil.
Azor was left without a spark, and his prison without a prisoner.
He waited for decades before finally realizing that there was nothing left for him to do here except what he did best: build yet another system of law there, on Torrezon.
He gifted the Immortal Sun to a monastery that would later give rise to the Legion of Dusk, but they were inept, so Azor took the Immortal Sun back before it could be used by Torrezon's would-be conquerors.
He gifted it to the Sun Empire, and for a while their kingdoms prospered, but their leaders grew paranoid, launching preemptive attacks on their neighbors. So Azor took his masterpiece back again, this time sealing himself within the walls of Orazca and charging the River Heralds—the only wise people on Ixalan—to make certain no one could find him or awaken the power within.
For years beyond counting, Azor brooded upon his towering throne in an empty city, cursing the name of the friend who had abandoned him.
And all the while, unbeknownst to Azor, Ugin slept.
= VRASKA
#figure(image("004_Sabotage/02.jpg", width: 100%), caption: [Sanctum of the Sun | Art by Yeong-Hao Han], supplement: none, numbering: none)
Jace told Vraska everything he knew about <NAME>.
The failed attempt to take the Planar Bridge, the army of Eternals on Amonkhet.
Vraska in turn told him everything she knew about <NAME>. The Meditation Plane and the spell-key that granted her access, how frightened she was that Bolas would kill her if she failed him. The more Vraska told Jace, the more they both began to realize the immensity of <NAME>'s plan. Vraska felt guilty and terrified in equal measure, as though the weight of all the planes was bearing down on her.
She held her head in her hands. "I'm supposed to contact one of Bolas's associates, and they will retrieve the Immortal Sun—"
"—using the Planar Bridge," Jace finished with a grim shake of his head. "It's Tezzeret. He's the one you're meant to call."
Vraska briefly shook her head. She didn't know who that was. Jace grimaced. "The man with the . . . arm. From when I was younger."
Vraska swore with revulsion.
Jace rubbed his face in his hands. "Bolas sent Tezzeret to Kaladesh to retrieve a portal that can transport objects. He sent you to retrieve something that locks planeswalkers on a plane—"
"And he went to Amonkhet to blow up his corpse factory. What does he plan to do with zombies that are stuck on a dead plane?"
Jace's face went pale. Vraska could see the whites of his eyes. He shut them and groaned. "They aren't just corpses anymore. They were treated with lazotep; it's this mineral that affixed to the Eternals' organic matter—"
"—To make them objects that could survive interplanar travel." Vraska shook her head. "He made an army he could transport across the Multiverse. And the Immortal Sun will make sure no one could leave once they've arrived. Jace, is there #emph[anything ] that might tell us what his endgame is?"
Jace paused. "I need to check. One moment."
He shut his eyes, and Vraska waited.
The room had grown stuffy, and little motes dappled the beams of sunlight that shone through the opening to the outside. She could feel her heart beating a worried rhythm in her chest, but for two entire minutes, Jace remained entirely still.
At last he opened his eyes, and looked at her with the saddest expression she had ever seen on someone's face.
"Show me," Vraska commanded.
And Jace did.
The air rippled with the now-familiar signs of illusion, and Vraska watched through Jace's eyes.
#figure(image("004_Sabotage/03.jpg", width: 100%), caption: [Hour of Devastation | Art by Simon Dominic], supplement: none, numbering: none)
Gold scales. Sandstone. Heat. Rough sand on his lips and in his eyes and in his throat. Broken, doomed friends. He was trying to break into Nicol Bolas's mind. Sense what the dragon's plan was, stop him from doing harm, and for a brief moment, #emph[he had done it] , he saw the goal, and the answer stopped his heart in his chest—
Ravnica was writ large upon the ambition in Nicol Bolas's mind.
It was not purposefully laid out, as traps of the mind often are, but woven into the dragon's intentions, stamped broad and bright across his subconscious.
<NAME> noticed Jace's presence, and retaliated by slamming his psychic strength into the mage's mind. But when he did, and when the dragon scoured his insides, Vraska felt some kind of trap being sprung, and though Bolas managed to scramble Jace's memories, a part of Jace's mind propelled him from Amonkhet to Ixalan.
#emph[Ravnica ] was <NAME>'s goal.
Everything led there.
Vraska opened her eyes, and Jace's projection ceased.
She realized her hands were trembling.
"He wants to unleash an army. On our #emph[home] . With my #emph[help.] "
They were both very quiet. It was too much. Too large, too overwhelming. The object Vraska had voyaged for months to find was hanging above them.
Vraska briskly stood up. She paced, swearing over and over and over, picking up a rock and throwing it at the Immortal Sun above.
"If I don't deliver the Sun I'm trapped here, and if I do deliver it <NAME> will destroy Ravnica. Ravnica is #emph[our home] !"
Jace was silent.
"And you!" said Vraska. "He'll look in my mind see that I met you! That I know you, that all of this happened. He's going to kill us both!"
She sat down and tried to breathe away her panic. No matter what happened, the rest of the Golgari would suffer. No matter what happened, she would die.
"This has all been such a farce," Jace said weakly. "Kaladesh, Amonkhet, here. The Gatewatch wasn't protecting anything. Not really. I've let everyone down."
Vraska's head was in her hands. She was rambling, trying to work out the plan verbally. "<NAME> intends to trap Planeswalkers and, what, eliminate the rest of the Ravnica? Muffle it so he can trap the enemies he's worried about and destroy somewhere else? Both of those seem pointless—if he wanted to kill Planeswalkers, he would just do it. I don't understand his intent."
Survival had been at the core of every choice Vraska had ever made. But now, she could not see a way out. She would either remain trapped on Ixalan while Ravnica burned, or else return and be killed immediately by the dragon for working alongside his enemy. No matter what she chose, so long as <NAME> was able to peer into her mind, her home would be destroyed.
#emph[But what if he looked and saw nothing?]
A terrible idea sparked in her mind. A terrible, brilliant idea.
Vraska closed her eyes and let out a long, shaking breath. It was the most frightening idea she had ever had in her life. But if <NAME> looked and saw nothing, continued to trust her, allowed her the power he had promised her in return for her service . . . then she could hurt him all the more. #emph[They ] could hurt him all the more.
"Jace."
Jace glanced back at her, distraught.
"I have an idea, but you're not going to like it."
Jace shook his head. Helplessness was etched into the lines of his grimace. "I don't know what I could do that could help."
Vraska built up as much courage as she could to get the request past her lips. What she was about to say was terrifying, alarmingly drastic, and utterly necessary for their shared survival.
"I need you to temporarily take my memories of you."
Jace recoiled in disgust. "I won't do that."
"Jace, it's temporary and it's the only way to keep us both from getting killed." Vraska swallowed hard. She knew how awful this sounded, but the more the idea marinated in her mind the more she knew it was the right choice. The only choice.
Jace shook his head in disbelief. "I'm not hurting you like that—"
"You would not be hurting me, you would be protecting #emph[us] ," she said emphatically. "You take my memories of you from my mind and hold onto them. Keep them safe, keep them away from the dragon's view, so when he sees me he thinks the mission went off without a hitch. And then, on Ravnica, at the right moment, you give the memories back."
Jace went still. Vraska could almost see him thinking through the plan. He spoke slowly and deliberately, in a tone drenched in fear with a dash of dangerous curiosity. "You want to betray <NAME>."
Vraska nodded. She found herself scowling, her tendrils waving with anger and determination. "If that bastard thinks I would stand by and allow him to conquer my plane with #emph[my help] , he's got another thing coming. And I'd betray him a thousand times over to stop him from doing to Ravnica what he did to Amonkhet."
The revulsion on Jace's face had been replaced with intrigue. He looked at Vraska with conspiratorial curiosity. "What sort of sabotage are we talking about?"
A splash of criminal talent had remained with him in the years since the manablade after all. Vraska gave Jace an approving look and began to talk out the beginnings of her plan.
"He promised me the title of guild leader. Law magic was built into the fabric of Ravnica, even before Azor arrived. The metaphysics of the plane are built around hierarchy, and guild leaders have access to that power, especially when they work together. I'll accept the position and keep working as his lackey while you do you do your Guildpact thing and work on devising a plan. The dragon won't suspect anything because I won't be on your side until you #emph[remind me] that I am. When you're ready, and when we can hurt <NAME> the most, return my memories and we'll set whatever plan you make in motion. Even if he catches on to what you're doing, he won't think it will work, because he'll think I'm loyal to him."
The plan felt insane to say out loud, but Vraska knew it would work. Jace was probably the second-best telepath in the Multiverse #emph[before] he remembered what his mentor had taught him. But now? He was whole. Fractured no more. If he could break a sphinx as a boy, what could he do as an adult?
Vraska could tell Jace was beginning to understand. He looked at her reluctantly. "You would trust me with your memories?"
"I trust you absolutely," she responded with iron resolution.
How could she not? He was like her. Vraska realized for the first time that this was what a partnership felt like, and her conviction deepened. How strange it was, to have someone to trust and to be trusted in return.
The look on Jace's face told her that he had never heard that from anyone. He gave her a look of awe and sadness, briefly closed his eyes, and opened them once more.
"There's a technique Alhammarret taught me," Jace said with trepidation. He was leaning forward where he sat with his elbows on his knees. His body language had shifted away from guarded terror to problem-solving focus. "Oubevir's Maneuver. It's a way to smooth over evidence of mental tampering. I can reverse-engineer the spell Ugin put on me to further disguise the gap left behind. Bolas shouldn't be able to tell anything has been removed."
"Are you certain?"
"Bolas won't see the absence of something he wouldn't know to look for. He's too proud, and he doesn't know I'm here."
Vraska was beginning to feel hopeful. "Who on Ravnica could help come up with a sabotage plan?"
Jace thought for a moment and nodded. "Niv-Mizzet. He could challenge <NAME> both physically and mentally, plus he'll be furious to know there's a dragon smarter than he is."
"Then we know what we have to do."
Vraska held out her hand. Jace took it in his and grasped tightly.
"Are you certain we don't have time to plan this out further?" he asked.
Vraska shook her head. "Ravnica is in danger and you've been gone for months."
Jace let out a long, slow breath. "Then let's do this before I talk myself out of it."
He looked at Vraska with calm determination. "You have my word as the Living Guildpact that your memories will be kept safe and returned intact. I swear to find a plan we can use against <NAME>, and I swear to uphold my responsibility to protect Ravnica, my home."
Vraska spoke with confidence. "You have my word as captain of the #emph[Belligerent ] that I will do whatever it takes to sabotage <NAME> upon the return of my memories. I swear to commit my conscious self to his destruction."
Vraska squeezed Jace's hand, and they let go. The pact was made.
A smile tugged at one corner of Jace's mouth. "Let's sabotage that bastard."
Vraska grinned.
She felt excited, terrified, but comforted all the same. Jace would keep a part of her safe, no matter what. They were going to save Ravnica.
"Where will you go after it's gone?" she asked, nodding up at the Immortal Sun.
Jace stood. "I need to meet my friends on Dominaria."
"To recruit them?"
"Mostly to apologize for being absurdly late."
"At least you have a good reason." Vraska shrugged.
"I won't stay on Dominaria after I find them, though." He went strangely quiet. A little crease was cut between his eyebrows. "The Guildpact belongs on Ravnica. I don't want to be like Azor."
Vraska understood why he would have that fear, holding the title he did. She nodded, and her mind wandered as Jace went quiet again.
After a moment she laughed a little. "I just realized I will still recognize you when I see you next . . . but I'll definitely try to kill you."
"I know," he said sweetly.
Vraska couldn't help but smile at that. What an odd secret he would have to keep.
She wondered how it would feel to remember Ixalan after it was over. Would she remember the #emph[Belligerent] ? Would she remember her friends? "Can you sense where my crew is?" she asked aloud.
Jace paused for a moment, listening for something that she could not hear. He nodded. "Yes. They're in the room above. I can send <NAME> Breeches a message, if you like."
Vraska sighed with guilt. "Tell them both we've been captured. Tell them to return to the ship, Amelia's in charge, and that this crew is the best thing that has ever happened to me. That's the truth."
Jace's eyes briefly lit with the azure glow of his magic. "It's done," he said sadly. "I'll miss them, too."
"We'll see them again," Vraska said with determination. "I don't want to forget them."
"You won't," Jace reassured her. "I'll make certain of it."
Vraska rolled her shoulders. Limber up. Time for the finale. "How should this work? Should I call Tezzeret first?"
"I'll need to identify each memory you have of me, first," Jace replied. "You'll call Tezzeret after I'm through. I assume he's fixed the Planar Bridge, so he'll pull the Immortal Sun through that. Then we can planeswalk away."
"Wait." Vraska's brows were knit with concern. "How will I know my memories are real when I get them back?"
Jace moved to stand across from her. "I'll call you by your title when I see you next, before I return your memories."
"You'll call me Guild Leader?"
His gaze softened. "I'll call you Captain."
Happiness tugged at the lines of her eyes. "That will work."
He reached toward her, hands held up. "May I?" he asked. Vraska nodded, and he placed his fingers on either side of her head.
Vraska smiled. "After all this is over . . . can I show you Tin Street Market back on Ravnica?"
Jace returned a sad little smile of his own. "I remember where Tin Street Market is."
"Yes, but . . . I want to give you a tour. Get some coffee. I know a really good bookstore."
"You like books?" Jace asked, a hopeful, happy look in his eyes.
Vraska nodded. "I'll get a history, you can get some schematics or whatever it is you like to read," she teased.
He laughed. "I like memoirs."
"Really? #emph[You ] like memoirs?"
"I like interesting people," he said with a soft and bashful smile.
Vraska smiled. "It's a date."
She nodded and closed her eyes. "Talk to Niv-Mizzet. Find a plan that needs the guild leaders to work, and save me for last. Don't let the other dragon notice. And then . . ."
"Sabotage," Jace finished excitedly.
He opened a connection between their minds. Vraska suddenly felt as though she had been standing on a stage behind a curtain that was now being gently raised. His presence was polite, but she felt him tiptoeing his way through her mind.
#emph[If I go near anything you don't want me to see, just say so and I'll back away.]
Vraska nodded.
#emph[I'll also leave some memories for <NAME> to find so he doesn't see any gaps. Is that all right?]
#emph[Yes] , Vraska replied. She felt guilty she had seen so much of Jace's own past.
#emph[That wasn't your fault] , Jace said, pulling up the memory of the riverbank for both of them to see. She felt as he watched it through her eyes, saw how bad things were down in the mud, lost in the flood of his own past. Having Jace present in her mind was strangely comforting, like watching a play alongside a companion. The two of them sifted through the memories of their shared moments, piecing them apart and laying them out. Jace let out a long mental whistle when he saw how he had first looked on that bird-excrement-covered island. They both smiled watching themselves fight side by side in the raid. Vraska felt herself tear up when she saw them talking in the galley.
#emph[Your story deserves to be told] , Jace said.
He paused when he reached the end of the memory of the riverbank, of himself lost in grief and wrapped up in Vraska's arms. Vraska knew Jace understood, with his mind linked to hers, that that was the first time she had touched someone willingly in many years.
Then, Vraska felt as if she were descending. The riverbank vanished, everything went dark and cloudy, and she was presented with something unfamiliar—a well constructed of weathered slate, and down inside of it the walls were lined with countless textures of memory. She saw her memories of Jace tied up in a bundle, placed within a box, sealed with an unbreakable ward. She felt Jace hiding the box away in the well and disguising its presence with a spell.
#emph[Safe and sound] , Jace promised.
#emph[I'll see you soon] , Vraska said.
#emph[Tin Street Market, right? Coffee and a book? ] he asked hopefully.
#emph[Coffee and a book] , she replied, happy. Her face felt warm, and Vraska smiled.
She could have sworn she heard the sound of rain.
#figure(image("004_Sabotage/04.jpg", width: 100%), caption: [Induced Amnesia | Art by <NAME>], supplement: none, numbering: none)
Her thoughts were calm and cool, her body relaxed.
She felt like she was standing outside during a springtime shower.
Pleasant and refreshed.
She opened her eyes.
She blinked and looked around the empty room.
#emph[How did I get here?]
It was stuffy, and an odd throne was standing at the far end. She had the sense that this room was not meant to be accessed by the public. She could hear scuffling in the room above. Above her was a large disc embedded in the ceiling. She pulled out the thaumatic compass and, sure enough, the needle pointed upward.
#emph[I found it!]
Vraska held out her hands and performed the spell her sponsor had taught her months before.
#figure(image("004_Sabotage/05.jpg", width: 100%), caption: [Mastermind's Acquisition | Art by <NAME>], supplement: none, numbering: none)
It was complicated, requiring intense focus and more energy than she expected. The spell shot out and away from her like a bolt of lightning.
Vraska waited for a full minute. She wondered if it had worked, and jumped in surprise when a violet circle opened up directly beneath the Immortal Sun.
She felt a strange shifting inside of herself as the Sun was pulled through to another plane. As the portal closed, Vraska planeswalked away.
|
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/layout/align_05.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
//
// // Error: 8-20 cannot add two vertical alignments
// #align(top + bottom, [A]) |
https://github.com/HenkKalkwater/aoc-2023 | https://raw.githubusercontent.com/HenkKalkwater/aoc-2023/master/parts/day-2-2.typ | typst | #let solve = (input) => {
let game_r = regex("Game (\d+):")
let cubes_r = regex("(\d+) (\w+)")
let games = input
.split("\n")
.filter(line => line.len() > 0)
.map(line => {
let game = int(line.match(game_r).captures.at(0))
let game_draws = line.split(";")
let draws = ()
for draw in game_draws {
let game_matches = draw.matches(cubes_r)
let game_vals = (:)
for match in game_matches {
game_vals.insert(match.captures.at(1), int(match.captures.at(0)))
}
draws.push(game_vals)
}
(game, draws)
})
.map(game => {
let draws = game.at(1)
draws.fold((:), (l, r) => {
let result = (:)
for color in ("red", "green", "blue") {
result.insert(color, calc.max(l.at(color, default: 0), r.at(color, default: 0)))
}
result
}).values().product()
})
.sum()
games
}
|
|
https://github.com/rice8y/cetzuron | https://raw.githubusercontent.com/rice8y/cetzuron/main/src/requirements.typ | typst | #import "@preview/cetz:0.2.2" |
|
https://github.com/fenjalien/cirCeTZ | https://raw.githubusercontent.com/fenjalien/cirCeTZ/main/README.md | markdown | Apache License 2.0 | # circuitypst
# THERES WORK ON THE DEV BRANCH THIS PROJECT ISN'T DEAD
A port of [`circuitikz`](https://github.com/circuitikz/circuitikz) to Typst using [`typst-canvas`](https://github.com/johannes-wolf/typst-canvas). Due to the size of `circuitikz` features will be ported as I need them for my own work, if theres a feature you need feel free to make an issue, PR or contact me through Typst's discord (same username)!

## "Installation"
Because of Typst's current lack of package management the library expects to be placed in the same folder as `typst-canvas`.
```
typst-canvas/
circuitypst/
```
You can either clone the repository or download it as a `.zip` and extract it to the required location.
## Usage
To get started `node` and `to` should be imported from `circuitypst.typ`, ideally inside `typst-canvas`'s `canvas` function.
Here is a template:
```typ
#import "typst-canvas/canvas.typ": canvas
#canvas(length: 1cm, debug: false, {
import "typst-canvas/draw.typ": *
import "circuitypst/circuitypst.typ": node, to
...
})
```
Also see `examples/` for some examples.
## Requirements for First Stable Release
- [ ] Reference manual (doesn't have to inclued tutorials, just a list of currently supported components)
- [ ] Tests
- [ ] CI
- [ ] More components?
|
https://github.com/AxiomOfChoices/Typst | https://raw.githubusercontent.com/AxiomOfChoices/Typst/master/Courses/Math%2018_785%20-%20Number%20Theory/Assignments/Assignment%204.typ | typst | #import "/Templates/generic.typ": latex, header
#import "@preview/ctheorems:1.1.0": *
#import "/Templates/math.typ": *
#import "/Templates/assignment.typ": *
#show: doc => header(title: "Assignment 4", name: "<NAME>", doc)
#show: latex
#show: NumberingAfter
#show: thmrules
#let col(x, clr) = text(fill: clr)[$#x$]
#let pb() = {
pagebreak(weak: true)
}
#set page(numbering: "1")
#let bar(el) = $overline(#el)$
#set enum(numbering: "(a)")
// #show math.equation: set text(font: "Latin Modern Math")
*Sources consulted* \
Classmates: <NAME>, <NAME>, <NAME>. We discussed essentially every single problem together.\
Texts: Class Notes, Algebraic Number Theory by Milne, Elementry and Analytic Theory of Algebraic Numbers by Narkiewicz, Number Fields by Marcus.
#let r5 = $#h(-2pt) root(3,5)$
= Question
== Statement
Let $K = QQ(r5)$
+ Prove that $cal(O)_K = ZZ[r5]$.
+ Factor the primes $p = 2,3,5,7,11,13$ in $QQ(r5)$. Write the prime ideals $frak(q)$ appearing in your factorization in the form $(p, f(r5))$ where $f in ZZ[x]$ has degree at most $3$.
+ Prove that the factorization patterns you found in $(b)$ represent every possible case; that is, every possible sum $[K : QQ] = sum_(frak(q) divides (p)) e_frak(q) f_(frak(q))$ that can arise for this particular field $K$. You should find that there is one numerically possible case that does not occur for $p <= 13$; you need to prove that it cannot occur for any prime $p$.
+ Find a different cubic field of the form $K = QQ(#h(-1pt) root(3,n))$ for which the one factorization pattern missing from $(c)$ does occur (demonstrate this explicitly).
== Solution
Set $alpha = root(3,5)$.
+ It is easy to see that the discriminant of $(1,alpha, alpha^2)$ is $-775 = -3^3 5^2$. Since $x^3 - 5$ is Eisenstein with $p = 5$ then we get that the true discriminant does include $5^2$ as a factor. Then we have $(x+5)^3 - 5 = x^3 + 15 x^2 + 75 x + 120$ which is Eisenstein with $p = 3$ so the true discriminant shares the factor $3^3$ and thus is indeed $-775$, hence $(1,alpha,alpha^2)$ is a basis and thus $cal(O)_K = ZZ[alpha]$.
+ Since $cal(O)_k = ZZ[alpha] iso ZZ[x] quo (x^3 - 5)$, we can reduce the question of is $frak(p)$ prime to asking if $cal(O)_k quo frak(p)$ is an integral domain. Since $frak(p)$ will contain the desired ideal $(p)$ we have that
$
cal(O)_k quo frak(p) iso (cal(O)_k quo (p)) quo (frak(p) quo (p))
$
and hence it is enough to check that $frak(p)$ is prime in $FF_p [x] quo (x^3 - 5)$, which is equivalent to checking that it is generated by an irreducible polynomial, this gives us the following prime decompositions.
$
(2) = (2,alpha+1)(2, alpha^2 + alpha + 1)\
(3) = (3,alpha+1)^3\
(5) = (5,alpha)^3\
(7) = (7)\
(11) = (11, alpha+3)(11, alpha^2 + 3 alpha + 9)\
(13) = (13, alpha+2)(13, alpha + 5)(13, alpha + 6)\
$
+ The only decomposition that does not occur in this list is $(p) = X^2 Y$ for $X,Y$ prime ideals, let us assume that such a decomposition exists, then in our framework $X$ and $Y$ correspond to ideals of $FF_p [x] quo (x^3-5)$ which are all of degree 1, so are generated by linear elements. In other words, $X = (x - a), Y = (x - b)$. We thus have
$
(x-a)^2 (x-b)
=
(x^2 - 2 a x + a^2) (x - b)
=
x^3 - 2 a x^2 - b x^2 + a^2 x + 2 a b x - a^2 b
\
= x^3 + (-2a - b) x^2 + (a^2 + 2 a b) x - a^2 b
$
and so we have the following equivalences
$
-2a - b equiv 0 mod p
quad
a(a + 2b) equiv 0 mod p
$
and so we can now solve these equivalences. If $a equiv 0$ then we have $b equiv 0$ so we do not have distinct roots. We can thus assume that $a$ is invertible so $a + 2b equiv 0 mod p$ and also $2 a + b equiv 0 mod p$ and thus we have $a + 2 b - (4 a + 2 b) = - 3 a equiv 0 mod p$ so $a equiv 0$ and then again $b equiv 0$. We thus have a full contradiction and so such a decomposition cannot exist.
+ We set $alpha = root(3,10)$ and consider the number field $K = QQ(alpha)$, note that the following is an integral element of $cal(O)_K$
$
beta = (1 + alpha + alpha^2)/3
$
because
$
beta^3 - beta^2 - 3 beta - 3 = 0
$
and we have that the trace matrix looks like
$
mat(3,1,7;1,7,19;7,19,43)
$
so the discriminant is $Delta(1,beta,beta^2) = -300$, which factors as $-5^2 dot 3 dot 2^2$. But we know that the true discriminant shares the 2 and 5 factors because $x^3 - 10$ is Eisenstein with $p = 2$ and $p = 5$. We thus have $cal(O)_k = ZZ[x] quo (x^3 - x^2 - 3x - 3)$. Now in this ring we consider the prime ideal $(3)$ and we find using our usual technique that $x^3 - x^2 - 3x - 3 equiv x^2 (x - 1) mod 3$ so
$
(3) = (3, beta)^2 (3, beta - 1)
$
is the prime decomposition we were missing.
= Question
== Statement
For every ideal $frak(p)$ of $cal(O)_K$, show that there exists an order $A = ZZ[theta] seq cal(O)_K$ such that its conductor is coprime to $frak(p)$.
== Solution
Set $(p) = ZZ sect frak(p)$ and we consider the extension $(cal(O)_K)_frak(p) seq (cal(O)_K)_((p))$, since $(cal(O)_K)_((p))$ is finitely generated as a $ZZ_((p))$ module we get that $(cal(O)_K)_frak(p)$ is as well.
Now $(cal(O)_K)_frak(p)$ is a local ring so all its ideals are of the form $(pi^n)$ where $pi$ is a uniformizing element. Now $(cal(O)_K)_frak(p) quo (p)$ is an extension of $(cal(O)_K)_(frak(p)) quo frak(p)$ which is a field isomorphic $FF_p [theta]$ for some $theta$, which is importantly a separable extension. As an extension, $(cal(O)_K)_frak(p) quo (p)$, must then be generated by ${ theta^i pi^j : i,j <= N }$ for some $N$. Thus if we want to show that $(cal(O)_K)_frak(p) quo (p)$ is monogenic generated by $theta$, it is enough to show that we can write some uniformizing element $pi$ as a polynomial in $theta$, that is $pi = f(theta)$. We will choose $f$ to be the minimal polynomial of $tilde(theta)$ in $(cal(O)_K)_frak(p) quo frak(p)$, by definition we have $f(theta) in frak(p)$. Assume now that it is not uniformizing, then $f(theta) in frak(p)^2$. Now we have for any uniformizing element $pi$
$
f(theta + pi) = f(theta) + pi f'(theta) + pi^2 b
$
for some $b in (cal(O)_K)_frak(p) quo (p)$. Now by assumption, both $f(theta)$ and $pi^2 b$ are in $frak(p)^2$, and since the field is separable we know that $f'(tilde(theta)) != 0$ and so $f'(theta) in.not frak(p)$ so $pi f'(theta) in frak(p) backslash frak(p)^2$. Thus $f(theta + pi) in frak(p) backslash frak(p)^2$ and is thus a uniformizing element.
Now finally, $1,theta,theta^2,...,theta^M$ generates $(cal(O)_K)_frak(p) quo (p)$ as a $ZZ_((p))$ module so we have by Nakayama's lemma that for some element $ov(theta)$ with image $theta$, $1,ov(theta),ov(theta)^2,...,ov(theta)^M$ generates $(cal(O)_K)_(frak(p))$ as a $ZZ_((p))$ module.
Now by cancelling out the denominators we have that for some $n in.not (p)$, we have $(n)cal(O)_K seq ZZ[ov(theta)]$ so since $n in.not (p)$ we get that $(n) cal(O)_K$ is coprime to $frak(p)$.
= Question
== Statement
Let $L_1, L_2$ be finite extensions of a number field $K$. If a prime ideal $frak(p)$ of $cal(O)_K$ is split completely in $L_1,L_2$, then it is so in the composition $L_1 L_2$.
== Solution
Let $F$ be any normal extension containing $L_1 L_2$, then let $frak(q)$ be any prime lying over $frak(p)$. Let now, $D_frak(q)$ be the decomposition subgroup of $frak(q)$, then we consider $F^(D_frak(q))$, the elements of $F$ fixed under $I_frak(q)$. As we see in Marcus's book, the field $F^(D_frak(q))$ is the largest subfield of $F$ in which every $frak(p)$ completely splits, but then since $frak(p)$ completely splits in $L_1$ and in $L_2$ then we must have that $L_1$ and $L_2$ are subfields of $F^(D_frak(q))$. Thus $L_1 L_2$ is also a subfield of $F^(D_frak(q))$ and thus $frak(p)$ splits in $L_1 L_2$.
= Question
== Statement
Let $L quo K$ be a finite Galois extension of number fields with non-cyclic Galois group. Show that there are only finitely many non-split primes in $cal(O)_K$.
== Solution
Let $(p)$ be a non-split prime in $cal(O)_K$, then either $(p)$ is ramified or inert, so since there are only finitely many ramified primes then let us assume there are infinitely many inert primes.
For each inert prime $(p)$ we have $D_((p)) iso Gal(L quo K)$ which is a cyclic group.
#counter(heading).step()
= Question
== Statement
Show that for every finite abelian group $G$ there exists a Galois extension $K$ of $QQ$ such that $Gal(K quo QQ) iso G$.
== Solution
We know from class that $Gal(K quo QQ) = (ZZ quo n ZZ)^times$ for $K = QQ(zeta_n)$ where $zeta_n$ is the $n$-th root of unity. Now also from class we know that $(ZZ quo p ZZ)^times iso ZZ quo (p-1) ZZ$ for any prime $p$.
Next we recall that every finite abelian group $G$ has the form
$
G iso (ZZ quo n_1 ZZ) times (ZZ quo n_2 ZZ) times dots.c times (ZZ quo n_k ZZ).
$
Now fix any given $n_i$ and recall that by Dirichlet's Theorem there are infinitely many primes satisfying $p = 1 mod n_i$ so pick one of these primes and denote it $p_i$, with $p_i - 1 = m_i n_i$ for some integer $m_i$. We can pick $p_i$ such that they are all distinct We thus get that
$
G seq (ZZ quo (p_1-1) ZZ) times (ZZ quo (p_2-1) ZZ) times dots.c times (ZZ quo (p_k - 1) ZZ).
$
now the group on the right is exactly the group of units for $ZZ quo (p_1 p_2 p_3 ... p_k) ZZ$ so we get that
$
G seq ZZ quo (p_1 p_2 ... p_k) ZZ iso Gal(QQ(zeta_(p_1 p_2... p_k)) quo QQ)
$
now for an abelian group any subgroup is also a quotient, which you can easily see by Chinese Remainder Theorem.
Now by the fundamental theorem of Galois theory we know that this quotient then corresponds to some subfield of $QQ(zeta_(p_1 ... p_k))$ and thus that subfield is an extension of $QQ$ with the desired property.
= Question
== Statement
Show that every quadratic field is a subfield of some cyclotomic field.
== Solution
Let $m$ be some square free integer and let $m = plus.minus p_1 dots.c p_n$ be the prime decomposition of $m$, with all prime distinct because it is square free, we then have $sqrt(m) = sqrt(plus.minus 1) sqrt(p_1) dots.c sqrt(p_n)$ so it is enough to show that $sqrt(p)$ is contained in $QQ[zeta_n]$ for some $n$.
To that end first assume that $p$ is an odd prime, then we have that $Delta_K = p^(p-2)$ where $K = QQ[zeta_p]$ which we saw in class. But we also know from class that
$
Delta_K = product_(1 <= i < j <= p) (zeta_p^(i-1) - zeta_p^(j-1))^2
$
and so
$
product_(1 <= i < j <= p) (zeta_p^(i-1) - zeta_p^(j-1)) = plus.minus p^((p-2)/2) = plus.minus p^((p-3)/2) sqrt(p).
$
Now $p^((p-3)/2)$ is an integer and thus invertible in $QQ$ and so $sqrt(p)$ is in $QQ[zeta_p]$.
Now if $p = 2$ then we have $sqrt(2) in QQ[zeta_8]$ because $zeta_8 = sqrt(2)/2 + i sqrt(2)/2$, this also contains $sqrt(-1)$. Thus we $QQ[zeta_(8 m)]$ will always contain $sqrt(m)$ and so we are done.
|
|
https://github.com/rqy2002/typst-experiment | https://raw.githubusercontent.com/rqy2002/typst-experiment/main/test.typ | typst | #import "template.typ": *
#import "chn.typ": setCJKmainfont
#import "thm.typ": *
// Take a look at the file `template.typ` in the file panel
// to customize this template and discover how it works.
#show: project.with(
title: "Test",
authors: (
"rqy",
),
)
#show: setCJKmainfont.with( font: "FZFangSong-Z02"
, boldFont: "FZHei-B01"
, italicFont: "FZKai-Z03"
, latinFont: "Iosevka")
#let max(x, y) = if x < y { y } else { x }
#let extarrow(left: $-$, mid: $-$, right: $arrow$,
width) = box(width: width, {
style(styles => {
let m1 = measure(left, styles)
let m2 = measure(mid, styles)
let m3 = measure(right, styles)
place(box(width: width - m2.width / 2,
repeat($-$ + h(-m2.width / 2))))
left
h(width - m1.width - m3.width)
right
})
})
#let dlimit = math.limits(style(styles =>
math.attach(math.limits(math.lim),
bottom: move(dy: -0.3 * measure($arrow$, styles).height,
text(bottom-edge: "descender",
extarrow(measure(math.lim, styles).width))))
))
#let xrightarrow(top: none, bottom: none) = style(styles => {
let l1 = measure(top, styles).width
let l2 = measure(bottom, styles).width
let l = measure($arrow$, styles).width
math.attach(
math.limits(extarrow(max(l, max(l1, l2)))),
top: top, bottom: bottom
)
})
#let xleftarrow(top: none, bottom: none) = style(styles => {
let l1 = measure(top, styles).width
let l2 = measure(bottom, styles).width
let l = measure($arrow$, styles).width
math.attach(
math.limits(
extarrow(left: $arrow.l$, right: $-$, max(l, max(l1, l2)))),
top: top, bottom: bottom
)
})
$ scripts(lim)_(lim_(dlimit_n)) $
$ dlimit_n (ZZ \/ ZZ_n) tilde.eqq product_p ZZ_p $
$ x arrow xrightarrow(top: pi, bottom: phi) y xrightarrow(top: f + g, bottom: tilde.eqq) pi $
#let quad = math.space + math.space + math.space + math.space
#set math.lr(
size: 0%
)
如果我把中文和 English 混排, 会怎么样呢?
#set text(bottom-edge: "baseline")
#set rect(inset: 0pt)
#{rect(fill: aqua, math.lim)}
#{rect(fill: aqua, math.upright([lim]))}
#{rect(fill: aqua, sym.arrow.long)}
#{rect(fill: aqua, [lim])}
limit $dlimit$ lim
#let lemma = newtheorem("lemma", name: "引理")
#let thm = newtheorem("thm", name: [*定理*], bodyFormat: emph)
#lemma([
$op("Ext")^i(M(lambda), M(lambda)^(or)) = 0$.
])
#thm([
若 $n$ 是大于 $2$ 的正整数, 则 $x^n + y^n = z^n$ 没有非平凡整数解.
], title: [Fermat]) |
|
https://github.com/piepert/philodidaktik-hro-phf-ifp | https://raw.githubusercontent.com/piepert/philodidaktik-hro-phf-ifp/main/src/parts/ephid/beurteilen_bewerten/main.typ | typst | Other | #import "/src/template.typ": *
= #ix("Beurteilen", "Beurteilung") und #ix("Bewerten", "Bewertung") <ephid-bub>
*#ix("Beurteilung")* und *#ix("Bewertung")* im Philosophieunterricht stellen zwei verschiedene Arten der #ix("Leistungsauswertung") im Unterricht dar. Während eine #ix("Bewertung") eine Benotung in Form einer #ix("vorformulierten Wertung", "Wertung, vorformuliert") ist, stellt eine #ix("Beurteilung") eine #ix("differenzierte, verbale Einschätzung", "Einschätzung, differenziert, verbal") dar. Am Ende der Bewertung steht also eine Einordnung in ein vordefinietes Raster, während bei einer Beurteilung die Einschätzung wesentlich individueller ausfällt.
#task[Bewertung und Beurteilung][
Grenzen Sie #ix("Bewertung") und #ix("Beurteilung") voneinander ab!
][
#ix("Bewertung") ist eine Benotung oder vorformulierte Wertung. Während Bewertungen häufig in Noten ausgedrückt werden, handelt es sich bei #ix("Beurteilungen", "Beurteilung") um eine #ix("differenzierte, verbale Einschätzung", "Einschätzung, differenziert, verbal").
]
#include "missverstaendnisse_bewertung.typ"
#include "bewertungsnormen.typ"
#include "funktionen_leistungspruefung.typ"
#include "anforderung_bewertung.typ"
#include "bedeutung_schulnoten.typ"
#include "beispiel_kurzkontrolle.typ" |
https://github.com/maxgraw/bachelor | https://raw.githubusercontent.com/maxgraw/bachelor/main/apps/document/src/8-appendix/0-index.typ | typst | == Quellcode <appendix-Quellcode>
#include "code.typ"
#pagebreak()
== Aufgabenstellung <appendix-task>
#include "task.typ"
#pagebreak()
== Ergebnisse <appendix-result>
#include "result.typ" |
|
https://github.com/dismint/docmint | https://raw.githubusercontent.com/dismint/docmint/main/compilers/regex.typ | typst | #import "template.typ": *
#show: template.with(
title: "RegEx and Context-Free Grammars",
subtitle: "6.110"
)
= RegEx
We start off with some kind of alphabet $Sigma$, where the RegEx is built from
- The empty string $epsilon$
- Any letter from the alphabet $Sigma$
- One RegEx followed by another $r_1 r_2$ (sequence)
- Either one RegEx or another $r_1|r_2$ (choice)
- Iterated sequence and choice $r^* = epsilon|r|r r|...$
- Parenthesis to indicate grouping precedence
= Finite-State Automata
We can also visualize the same thing as a FSA, where there are *Start* states and *Accept* / *End* states.
#define(
title: "DFA vs NFA"
)[
What is the difference between *Determinant* and *Non-Determinant* Finite Automata?
/ DFA: Only one possible transition at each state.
/ NFA: May have multiple possible transitions. This means that there could be two or more transitions with the exact same label on them, or transitions that are labeled with the empty string $epsilon$. A string is accepted if *any* execution matches.
]
#define(
title: "Angelic vs Demonic Non-Determinism"
)[
/ Angelic: All decisions made to accept - try to help the string match.
/ Demonic: All decisions made to *not* accept - try to prevent the string from matching.
NFA uses *Angelic* Non-Determinism.
]
Although they are technically the same thing, semantically RegEx is a *generative* form while Automata are a *recognition* form.
|
|
https://github.com/jaapgeurts/typst-templates | https://raw.githubusercontent.com/jaapgeurts/typst-templates/master/article/0.0.1/article.typ | typst | #let acm(
// The paper's title.
title: "Paper Title",
// An array of authors. For each author you can specify a name,
// department, organization, location, and email. Everything but
// but the name is optional.
authors: (),
// The paper's abstract. Can be omitted if you don't have one.
abstract: none,
// A list of index terms to display after the abstract.
index-terms: (),
// The article's paper size. Also affects the margins.
paper-size: "a4",
// The path to a bibliography file if you want to cite some external
// works.
bibliography-file: none,
// The paper's content.
body
) = {
// Set document metadata.
set document(title: title, author: authors.filter( a => "name" in a).map(a=>a.name).join(", "), keywords: index-terms)
// Set the body font.
set text(font: "New Computer Modern", size: 9pt)
// Configure the page.
set page(
paper: paper-size,
// The margins depend on the paper size.
margin: if paper-size == "a4" {
(left: 54pt, right: 42pt, top: 54pt, bottom: 105pt)
} else {
(
x: (50pt / 216mm) * 100%,
top: (55pt / 279mm) * 100%,
bottom: (64pt / 279mm) * 100%,
)
}
)
// Configure lists.
set enum(indent: 10pt, body-indent: 9pt)
set list(indent: 10pt, body-indent: 9pt)
// Display the paper's title.
v(3pt, weak: true)
align(center, text(size:18pt,font: "Helvetica", weight: "bold", title))
v(8.35mm, weak: true)
// Display the authors list.
for i in range(calc.ceil(authors.len() / 3)) {
let end = calc.min((i + 1) * 3, authors.len())
let is-last = authors.len() == end
let slice = authors.slice(i * 3, end)
grid(
columns: slice.len() * (1fr,),
gutter: 12pt,
..slice.map(author => align(center, {
set par(leading: 0.3em)
set text(size: 12pt, font:"Helvetica")
[ #author.name ]
set text(size: 11pt, font:"Helvetica")
if "department" in author [
\ #author.department
]
if "organization" in author [
\ #author.organization
]
if "location" in author [
\ #author.location
]
if "email" in author [
\ #link("mailto:" + author.email)
]
}))
)
if not is-last {
v(16pt, weak: true)
}
}
v(40pt, weak: true)
show: columns.with(2, gutter: 24pt)
set par(justify: true, leading: 0.47em)
show par: set block(spacing: 1.75em)
show heading: it => {
set text(font: "Times New Roman",weight: "bold")
v(0.2em)
block()[#counter(heading).display() #h(0.7em) #upper(it.body)]
}
show heading.where(numbering: none): it => {
set text(font: "Times New Roman",weight: "bold")
v(0.2em)
set par(hanging-indent: 1.7em)
block()[#upper(it.body)]
}
show heading.where(level: 2): it => {
set text(font: "Times New Roman",weight: "bold", size: 11pt)
block()[#counter(heading).display("1.1") #h(0.7em) #it.body]
}
body
// Display bibliography.
// if bibliography-file != none {
// show bibliography: set text(8pt)
// show bibliography: set heading(numbering: "1.")
// bibliography(bibliography-file, title: text(10pt)[References], style: "mla")
// }
} |
|
https://github.com/so298/cv-theme.typ | https://raw.githubusercontent.com/so298/cv-theme.typ/main/cv_en.typ | typst | #set page("a4")
#import "./theme.typ": *
#show: cv
#set text(font: en_sans, size: 10pt, lang: "en")
#title("<NAME>")
#info("Phone", "xxx-xxxx-xxxx")
#info("Email", link("mailto:<EMAIL>", "<EMAIL>"))
#info("GitHub", link("https://github.com/your_user_name")[your_user_name])
#v(5pt)
= Experience
== Education
#cventry("2020/04 - 2024/03", "Nanka Sugoi University", "Graduated", [
- You can write some notes here.
])
== Work Experience
#cventry("2020/12 - 2022/03", "Yabai Kaisha", "Part-time", [
- Description of the work you did.
])
== Other Experience
#cventry("2020/12 - 2022/03", "Some Competition", "", [
- Description of the work you did.
])
= Skills and Interests
== Topics
Description of your interests.
|
|
https://github.com/mielpeeters/pitcher | https://raw.githubusercontent.com/mielpeeters/pitcher/main/0.1.0/README.md | markdown | # Pitcher
A simple and modern slideshow tool featuring configurable theme with automatic color palette selection.
---
## Usage
```typst
#import "@preview/pitcher:0.1.0": *
#let style = define_style(color: rgb("#3271a8"), font: "IBM Plex Sans")
#show: slides.with(
title: "Pitcher Slides",
description: "simple and modern",
style: style,
title_color: true,
)
#new_slide()
#outline()
#new_slide()
= My First Pitcher Slide
#figure(
image("image.svg")
)
#new_slide()
#animated_slide(
style,
[= My Second Pitcher Slide],
[1. my first point],
[2. my #text(fill: style.secondary_color)[second] point],
)
```






# API
## `slides`
This is the main function of this package, which should be used like so:
```typst
#show: slides.with(...)
```
### arguments:
- `title`: `content` or `string`, will be displayed in the first slide and at the footer of every other slide
- `author` / `authors`: one author or an array of authors, will be displayyed in the first slide
- `description`: `content` or `string`, will be displayed in the first slide and at the footer of every other slide
- `style`: a style, generated by function [`define_style`](#define_style), includes colors, font, and `radius`. The latter controls the radius size of figures (default: `15pt`)
- `title_color`: `bool`, default: `true`: whether or not the title should be displayed in a contrasting color or not.
## `define_style`
This function creates a style dictionary, based on a color.
Font and radius of figures can be specified too
### arguments:
- `color`: the main color of this presentation style
- `font`: the font for this presentation style
- `radius`: this radius is applied to figures
## `new_slide`
This function starts a new page, and keeps track of the current slide count (displayed at the right bottom).
## `animated_slide`
This function can be used to create slides which are split up to reveal new content.
### arguments:
- `style`: style dictionary (see [`define_style`](#define_style))
- `..content`: a variable amount of content arguments. For each of these, a new slide will be created.
## `accent_slide`
This function formats its body as an accented slide, with coloured background.
### arguments:
- `style`: style dictionary (see [`define_style`](#define_style))
- `body`: content to be shown in the accented slide style
|
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/.github/pull_request_template.md | markdown | Apache License 2.0 | <!--
Thanks for submitting a package! Please read and follow the submission guidelines detailed in the repository's README and check the boxes below. Please name your PR as `name:version` of the submitted package.
If you want to make a PR for something other than a package submission, just delete all this and make a plain PR.
-->
I am submitting
- [ ] a new package
- [ ] an update for a package
<!--
Please add a brief description of your package below and explain why you think it is useful to others. If this is an update, please briefly say what changed.
-->
Description: Explain what the package does and why it's useful.
<!--
These things need to be checked for a new submission to be merged. If you're just submitting an update, you can delete the following section.
-->
I have read and followed the submission guidelines and, in particular, I
- [ ] selected a name that isn't the most obvious or canonical name for what the package does
- [ ] added a `typst.toml` file with all required keys
- [ ] added a `README.md` with documentation for my package
- [ ] have chosen a license and added a `LICENSE` file or linked one in my `README.md`
- [ ] tested my package locally on my system and it worked
- [ ] `exclude`d PDFs or README images, if any, but not the LICENSE
<!--
The following box only needs to be checked for **template** submissions. If you're submitting a package that isn't a template, you can delete the following section. See the guidelines section about licenses in the README for more details.
-->
- [ ] ensured that my package is licensed such that users can use and distribute the contents of its template directory without restriction, after modifying them through normal use.
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/valkyrie/0.2.0/src/types.typ | typst | Apache License 2.0 | #import "base-type.typ": base-type
#import "assertions.typ": one-of
#import "types/array.typ": array
#import "types/dictionary.typ": dictionary
#import "types/logical.typ": either
#import "types/string.typ": string, ip, email
#import "types/tuple.typ": tuple
#let any = base-type.with(name: "any")
#let boolean = base-type.with(name: "bool", types: (bool,))
#let color = base-type.with(name: "color", types: (color,))
#let content = base-type.with(name: "content", types: (content, str))
#let date = base-type.with(name: "date", types: (datetime,))
#let number = base-type.with(name: "number", types: (float, int))
#let integer = number.with(name: "integer", types: (int,))
#let floating-point = number.with(name: "float", types: (float,))
#let choice(list, assertions: (), ..args) = base-type(
name: "enum",
..args,
assertions: (one-of(list), ..assertions),
)
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/docs/cookery/term.typ | typst | Apache License 2.0 |
#let vector-format = link("https://github.com/Myriad-Dreamin/typst.ts/blob/main/docs/proposals/8-vector-representation-for-rendering.typ")[_Vector Format_]
#let ts-cli = link("https://myriad-dreamin.github.io/typst.ts/cookery/guide/compiler/ts-cli.html")[Command Line Interface]
#let node-js-lib = link("https://myriad-dreamin.github.io/typst.ts/cookery/guide/all-in-one-node.html")[All-in-one Node.js Library]
#let init-option = link("https://github.com/Myriad-Dreamin/typst.ts/blob/main/packages/typst.ts/src/options.init.mts#L40")[`typst.InitOptions`]
|
https://github.com/icyzeroice/typst-packages | https://raw.githubusercontent.com/icyzeroice/typst-packages/main/packages/minimal-styling/sample/main.typ | typst | MIT License | #import "../src/lib.typ": template_minimal_styling
#show: template_minimal_styling
#set page(header: align(right)[Minimal Styling Template])
#let lipsum_fox = "the quick brown fox jumps over the lazy dog"
#outline(depth: 1)
= #link("")[Links]
- #link("")[#lipsum_fox]
- #link("")[#upper(lipsum_fox)]
- #link("")[链接示例]
= Code
This is the sample of ```typ #raw(block: false)``` #lorem(5) #raw(lorem(5)) `sample with space in the end ` #lorem(5)
```ts
// sample of #raw(block: true)
const arr = [1, 2, 3]
for (let i = 0; i < arr.length; arr += 1) {
arr[i]
}
```
= Footnotes
#lorem(10)#footnote([one])
#lorem(10)#footnote([two])#footnote([#link("")[link in footnote]])
= Title
== 二级标题 Heading Level 2
#lorem(20)
=== 三级标题 Heading Level 3
#lorem(20)
==== 四级标题 Heading Level 4
#lorem(20)
===== 五级标题 Heading Level 5
#lorem(20)
====== 六级标题 Heading Level 6
#lorem(20)
= Table
#table(
columns: 3,
[header 1], [header 2], [header 3],
[cell 1], [cell 2], [cell 3],
[cell 1], [cell 2], [cell 3],
)
= Fonts
English:\
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG\
the quick brown fox jumps over the lazy dog\
Emoji: ✅⬜🚩🏆
中文简体
中文繁體
にほんご
한국어 |
https://github.com/zomvie-break/cv-typst | https://raw.githubusercontent.com/zomvie-break/cv-typst/main/modules/certificates.typ | typst | Apache License 2.0 | #import "../brilliant-CV/template.typ": *
#cvSection("Certificates")
#cvHonor(
date: [2022],
title: [Google IT Automation with Python Professional Certificate],
issuer: [Coursera, Google],
)
#cvHonor(
date: [2022],
title: [Google Data Analytics],
issuer: [Coursera, Google],
)
#cvHonor(
date: [2023],
title: [Django for Everybody Specialization],
issuer: [Coursera, University of Michigan],
)
#cvHonor(
date: [2023],
title: [PostgreSQL for Everybody Specialization],
issuer: [Coursera, University of Michigan],
)
#cvHonor(
date: [2023],
title: [Python3 Programming Specialization],
issuer: [Coursera, University of Michigan]
)
|
https://github.com/GartmannPit/Praxisprojekt-II | https://raw.githubusercontent.com/GartmannPit/Praxisprojekt-II/main/Praxisprojekt%20II/PVA-Templates-typst-pva-2.0/template/cover.typ | typst | #let createCover(
title: [],
university: [],
additionalInfo: "Ausarbeitung im Rahmen des Seminars",
seminar: [],
study: [],
semester: [],
examiner: [],
author: "",
dateofBirth: [],
semesterCount: [],
matriculationNumber: [],
address: [],
email: "",
date: [],
cooperation: [],
) = {
set page(numbering: none)
align(center, text[#university])
linebreak()
align(center, text(18pt)[Studiengang]) // change cover describtions here and following where it's within content
align(center, text(18pt)[#study])
linebreak()
align(center, text(16pt)[*#title*])
align(center, text[#additionalInfo])
align(center, text[#seminar])
align(center, text[#semester])
linebreak()
linebreak()
linebreak()
text[Erster Gutachter: #examiner]
linebreak()
text[Eingereicht am: #date]
linebreak()
linebreak()
linebreak()
text[*Vorgelegt von:*]
linebreak()
grid(columns: 2, gutter: 1.5em, [Name:], [#author], [Geburtsdatum: ], [#dateofBirth], [Fachsemester:], [#semesterCount], [Matrikelnummer:], [#matriculationNumber], [Adresse:], [#address], [E-Mail:], [#email], [Kooperationsunternehmen: ], [#cooperation])
} |
|
https://github.com/maucejo/cnam_templates | https://raw.githubusercontent.com/maucejo/cnam_templates/main/template/main-convention.typ | typst | MIT License | #import "../src/cnam-templates.typ": *
#show: cnam-convention.with(
// composante: "lmssc",
convention: "cadre",
titre: [Convention cadre entre xxx et yyy],
date: [01 janvier 2025],
// lieu: "Salle des conseils",
// redacteur: "<NAME>",
// toc: true
)
= Point 1
#lorem(50)
= Point 2
#lorem(50) |
https://github.com/sses7757/sustech-graduated-thesis | https://raw.githubusercontent.com/sses7757/sustech-graduated-thesis/main/sustech-graduated-thesis/pages/list-of-figures.typ | typst | Apache License 2.0 | #import "@preview/i-figured:0.2.4"
#import "@preview/outrageous:0.1.0"
#import "../utils/style.typ": 字号, 字体
#import "outline-page.typ": outline-pagenum, outline-final
// 表格目录生成
#let list-of-figures(
// documentclass 传入参数
twoside: false,
fonts: (:),
// 其他参数
title: "插图目录",
outlined: false,
title-vspace: 0pt,
title-text-args: auto,
// caption 的 separator
separator: " ",
// 字体与字号
font: auto,
size: 字号.小四,
// 垂直间距
vspace: 14pt,
// 是否显示点号
fill: auto,
..args,
) = {
// 1. 默认参数
fonts = 字体 + fonts
if (title-text-args == auto) {
title-text-args = (font: fonts.黑体, size: 字号.三号)
}
// 字体与字号
if (font == auto) {
font = fonts.宋体
}
set page(..outline-pagenum())
// 2. 正式渲染
pagebreak(weak: true, to: if twoside { "odd" })
// 默认显示的字体
set text(font: font, size: size)
heading(level: 1, numbering: none, outlined: outlined, title)
v(title-vspace)
show outline.entry: outrageous.show-entry.with(
// 保留 Typst 基础样式
..outrageous.presets.typst,
body-transform: (level, it) => {
// 因为好像没找到 separator 的参数,所以这里就手动寻找替换了
if (it.has("children") and it.children.at(3, default: none) == [#": "]) {
it.children.slice(0, 3).sum() + separator + it.children.slice(4).sum()
} else {
it
}
},
vspace: (vspace,),
fill: (fill,),
)
// 显示目录
i-figured.outline(target-kind: image, title: none)
outline-final("lof", twoside: twoside)
} |
https://github.com/EpicEricEE/typst-marge | https://raw.githubusercontent.com/EpicEricEE/typst-marge/main/tests/container/columns/test.typ | typst | MIT License | #import "/src/lib.typ": sidenote
#set par(justify: true)
#set page(width: 12cm, height: 5cm, margin: (outside: 4cm, rest: 5mm))
#let sidenote = sidenote.with(numbering: "1")
#show: columns.with(2)
#lorem(15)
#sidenote[A note from the first column.]
#lorem(15)
#sidenote[A note from the second column.]
#lorem(15)
|
https://github.com/ayoubelmhamdi/typst-phd-AI-Medical | https://raw.githubusercontent.com/ayoubelmhamdi/typst-phd-AI-Medical/master/chapters/ch08-ss.typ | typst | MIT License | #import "../functions.typ": heading_center, images, italic,linkb
#let finchapiter = text(size: 24pt, fill:rgb("#1E045B"),[■])
#let S1 = "S1"
#let S2 = "S2"
#let S3 = "S3"
= DETECTING LUNG CANCER NODULES.
== introduction
Lung cancer is the most common cause of death from cancer in the world @Siegel2017Cancer2017. However, if lung cancer is found early by screening chest scans, the chances of survival can be improved@Nationallungscreening. One way to screen for lung cancer is to look for nodules in the lungs@Gould2007EvaluationEdition. Nodules are round or oval-shaped lumps that can be seen in chest scans. Some nodules are cancerous and some are not. A computer system that can help find nodules automatically can save time and resources for doctors and patients.
A computer system for finding nodules typically consists of two steps@Setio2016PulmonaryNetworks:
- first, it identifies a broad range of potential nodules with high sensitivity, but also many false positives;
- second, it reduces the false positives by using more features and classifiers.
- the second step is challenging because nodules have different shapes, sizes, and types, and they can resemble other things in the chest, such as blood vessels or lymph nodes@Gould2007EvaluationEdition@Roth2016ImprovingAggregation.
In this report, we use a method for reducing false positives by utilizing a special type of neural network called multi-scale gradual integration convolutional neural network (mgi-cnn). This method exhibits three main features:
1. it uses three different sizes of patches from the chest scans as inputs. Each size offers different information about the nodule and its immediate surroundings.
2. it gradually combines the patches in different network layers, as opposed to all at once. This enables it to learn more features from different scales.
3. it employs two different ways of combining the patches: one from small to large (zoom-in) and one from large to small (zoom-out). This ensures it can obtain more information from varying perspectives@Karpathy2014Large-ScaleNetworks; @Shen2015; @Shen2017Multi-cropClassification; @Dou2016Multi-levelDetection.
We test this method on a public dataset called LUNA16, which contains chest scans from 888 patients with annotations from four specialists@Setio2016PulmonaryNetworks.
Overall, this method performs better in reducing false positives, especially at low rates. This indicates it can identify more nodules that are cancerous and fewer nodules that are not@Lin2016FeatureDetection; @Kamnitsas2017EfficientSegmentation.
== Related Work
=== Volumetric Contextual Information
Previous approaches for automatic lung cancer screening have focused on extracting nodule morphological characteristics using specific algorithms@Okumura1998AutomaticFilter,@Li2003SelectiveScans. Researchers have attempted to utilize volumetric information about the nodules and their surrounding areas to improve detection@Jacobs2014AutomaticImages. Recent advancements in deep neural networks, particularly CNN-based methods, have demonstrated promising results in classifying nodules correctly@Roth2016ImprovingAggregation,@Setio2016PulmonaryNetworks,@Ding2017AccurateNetworks. However, these methods have limitations in distinguishing diverse nodule types and require reconfiguration for each nodule type@Jacobs2014AutomaticImages.
=== Multi-scale Contextual Information
The use of multi-scale contextual information in lung nodule detection. By using deep learning methodologies, specifically with the Luna16 dataset, varying scales of morphological and structural features are evaluated@Shen2015,@Dou2016Multi-levelDetection. This approach allows for the incorporation of multi-scale contextual data, a method found to enhance overall performance. Several techniques aid in this task, for example:
- _Multi-scale CNN (MCNN)_: This technique is designed to extract high-level features from images at different scales. These features then assist in training classifiers for distinguishing nodules@Shen2015.
- _Multi-Crop CNN_: This method employs multiple cropping and pooling approaches. These enable the extraction of significant data from various regions of convolutional feature maps and can enhance detection accuracy due to this spatial relevance consideration@Shen2017Multi-cropClassification.
The other strategies that could potentially improve the detection of lung abnormalities include the use of _3D patches_ to harness volumetric data for better accuracy@Setio2016PulmonaryNetworks,@Roth2016ImprovingAggregation and mitigating false positives@Dou2016Multi-levelDetection. Another innovative approach is _gradual feature extraction_. This step-by-step method involves sequentially merging context information from various scales and contradicts the conventional idea of radical integration@Shen2015,@Shen2017Multi-cropClassification. The goal behind these techniques is to create a more reliable and robust model for lung nodule detection.
Attention is also given to the regions surrounding potential lung nodules. By assessing these adjacent areas and comparing them with other organs or tissues, distinguishing the nodules becomes more manageable@Shen2017Multi-cropClassification. This holistic approach combines multiple techniques and could potentially boost the accuracy and performance of lung nodule detection significantly@Dou2016Multi-levelDetection,@Shen2017Multi-cropClassification.
== Method
In this section, we describe this method, the Multi-Scale Gradual Integration Convolutional Neural Network (MGI-CNN) @Dou2016Multi-levelDetection, for pulmonary nodule identification. The network consists of two main components: Gradual Feature Extraction (GFE) @Zhang2014ScaleAnalysis,@Shen2015,@Shen2017Multi-cropClassification and Multi-Stream Feature Integration (MSFI) @Nair2010RectifiedMachines.
=== Gradual Feature Extraction
The GFE part of the network gradually integrates contextual information from patches at different scales. We propose two scenarios: Zoom-In and Zoom-Out.
In the Zoom-In scenario, patches at increasing scales are filtered using local convolutional kernels. The resulting feature maps from each scale are concatenated with the patch at the next scale and processed using convolution layers. This process continues until the final integration of contextual information from all scales is achieved. Conversely, in the Zoom-Out scenario, the same operations are performed but with patches in the opposite order.
This method allows the network to progressively integrate contextual features according to the order of scales, capturing both local and global information. By employing this approach, this network can focus on specific nodule regions or surrounding regions, effectively distinguishing nodules from other structures.
=== Multi-Stream Feature Integration (MSFI)
The MSFI part of the network leverages the combination of ‘zoom-in’ and ‘zoom-out’ information streams that capture different scales of nodule morphology and context. These streams have diverse and complementary features that can enhance the nodule detection. This model uses more convolutional and fully-connected layers.
MSFI stands for Multi-Stream Feature Integration, which is a technique to combine features from different scales and perspectives in lung nodule detection. MSFI is part of the MGI-CNN, a multi-scale convolutional neural network that is developed to improve the performance of false positive reduction in lung nodule detection using the Luna16 dataset.
Suppose we have a 3D patch of a lung image that contains a nodule. We want to detect the nodule and reduce the false positives. We can use MSFI to combine features from different scales and perspectives.
First, we create two streams of input patches from the original patch: a zoom-in stream that crops the patch to focus on the nodule region, and a zoom-out stream that expands the patch to include more surrounding context. We can use different scales for each stream, such as $S1$, $S2$, and $S3$.
Second, we feed each stream into a convolutional neural network (CNN) that extracts features from the patches. The CNN can have multiple layers, such as convolution, pooling, and fully connected layers. The output of the CNN is a feature map that represents the characteristics of the patch. The output of MSFI is a combined feature map that contains information from the streams.
Finally, we use the combined feature map to classify the patch as a nodule or non-nodule. We can use a classifier, such as a softmax layer, that assigns probability to each class. The higher the probability, the more confident the prediction.
By using MSFI, we can improve the performance of lung nodule detection by utilizing features from different scales and perspectives. MSFI helps to capture both the morphological and contextual information of the nodule, and thus reduces the false positives.
== Experiments and Results
=== Dataset Luna16
The LUNA16 challenge datasets@Setio2017validation,, comprising 888 patients with lung nodules annotated by four radiologists, were utilized. Patients with a slice thickness exceeding 2.5 mm@Setio2017validation were omitted. *A nodule was deemed as Ground Truth (GT) if at least three radiologists concurred. The total number of nodules was 1186*.
For the False Positive (FP) reduction task, LUNA16 supplied candidate nodule coordinates, patient IDs, and labels.
<!-- Two versions of datasets were available: V1 contained 551065 candidates, including 1351 nodules and 549714 non-nodules, with 1120 nodules matching with GTs. V2 contained 754975 candidates, including 1557 nodules and 753418 non-nodules, with total of 1186 nodules matching with GTs. -->
3D patches were extracted from CT scans at scales of 40x40x26, 30x30x10, and 20x20x6, covering most nodules in the dataset@Dou2016Multi-levelDetection. These patches were resized to 20x20x6 using nearest-neighbor interpolation and normalized within the [-1000, 400] HU range@Hounsfield1980ComputedImaging.
The network was trained using Xavier's initialization@glorot2010understanding, a learning rate of 0.003, and a total of 40 epochs. ReLU activation and a dropout rate of 0.5 were applied for fully-connected layers. Stochastic gradient descent was employed with a batch size of 128.
The network used a Competitive Performance Metric (CPM) for performance evaluation@Niemeijer2011OnSystems.
==== How CPM Calculated.
Let's assume we have a dataset of 100 CT scans with the following results from the model:
- Total lung nodules: 200
- True positives (TP): 150
- False positives (FP): 800
- False negatives (FN): 50
First, calculate the FP per scan level by dividing the total number of false positives by the total number of scans:
FP per scan level = FP / number of scans = 800 / 100 = 8
The FP per scan level in this example is 8, which matches the desired level.
Next, calculate the sensitivity (true positive rate) using the number of true positives and false negatives:
Sensitivity = TP / (TP + FN) = 150 / (150 + 50) = 150 / 200 = 0.75
In this example, the model's sensitivity at a false positive per scan level of 8 is 0.75 or 75%. This means that the model correctly identifies 75% of the lung nodules when it produces an average of 8 false positives per scan.
==== Nodule-to-non-nodule ratio.
A nodule-to-non-nodule ratio of approximately 1:6 is mentioned, which means that for every nodule (a small growth or lump) in the dataset, there are approximately six non-nodule samples. This ratio helps balance the data by ensuring that the model has enough samples of both nodules and non-nodules for training and evaluation.
When the initial ratio is 1:5, to achieve a ratio of approximately 1:6. To do this, we can augment the nodule samples by rotating and shifting them on different planes and axes, creating new nodule samples in the process.
Balancing the data in this manner ensures that the model is trained on a more representative dataset, which can help improve its performance in detecting lung nodules.
=== CPM <RESULT>
The Competitive Performance Metric (CPM) score, the average sensitivity at seven FP/scan levels (0.125, 0.25, 0.5, 1, 2, 4, and 8), is used for performance evaluation@Niemeijer2011OnSystems.
A 5-fold cross-validation was used for evaluation. To balance the data, nodule samples were augmented by rotating and shifting them on different planes and axes, resulting in a final nodule to non-nodule ratio of approximately 1:6.
=== Performance Evaluation
To validate this method, we compared with other existing state-of-the-art methods@Setio2016PulmonaryNetworks@Dou2016Multi-levelDetection and found this method surpassing others in terms of Competitive Performance Metric (CPM) scores over seven different FP/scan values.
=== Efficacy of Proposed Strategies
For contrasting the effects of our strategies in creating a multi-scale CNN, we experimented with other Multi-scale CNNs as well. The performance of this method outclassed all other methods in terms of average CPM and FP reduction, bringing out the significance of our GFE and MSFI strategies.
== Discussions
Lung nodule detection using deep learning techniques can help in early detection and diagnosis of lung cancer. The LUNA16 dataset is a widely used resource for developing and evaluating lung nodule detection algorithms. In this context, the MGI-CNN architecture that has two main advantages:
- It can extract morphological and contextual features at different scales from the input patches. The zoom-in network gradually incorporates contextual information in the nodule region, while the zoom-out network does the opposite. These different ways of integrating multi-scale information provide complementary features that improve the performance.
- It can integrate abstract features from the two streams in MSFI. This maximizes the false positive (FP) reduction by combining features at a high level of abstraction, where the morphological and contextual information are well preserved.
Three different strategies were tested to combine the feature maps of the two streams in MSFI: concatenation, element-wise summation, and 1x1 convolution@Lin2013network. Element-wise summation achieved the best FP reduction, although there was no significant difference among them in average CPM.
The input 3D patches were resized to 20x20x6 to fit the network's receptive field size. This may cause some information loss or distortion in the original patches. However, the resized patches still retained the nodule information, as the nodule occupied most of the patch. Therefore, the resizing operation did not affect the performance significantly.
The 232 false positives that the MGI-CNN failed to remove were analyzed and classified into three groups based on their nodule probabilities: Low Confidence (LC; 0.5 ≤ p < 0.7), Moderate Confidence (MC) $0.7 ≤ p < 0.9$, and High Confidence (HC) $p > 0.9$. Most of the false positives were parts of large tissues or organs that the network could not distinguish from nodules.
For the Moderate Confidence (MC) group, the false positives had low contrast, possibly due to normalization during preprocessing. This suggests that network performance could be improved by using more patches with different scales and normalization methods.
The method improving the FP reduction part of a pulmonary nodule detection system, which typically consists of a candidate detection part and an FP reduction part. The network can work with any candidate detection method, as it is independent of it. Combining the network with more advanced candidate detection methods is expected to yield better results.
= CONCLUSION GÉNÉRALE.
The multi-scale gradual integration CNN (MGI-CNN) for reducing false positives (FPs) in lung nodule detection on chest CT scans utilizes three main strategies:
1. multi-scale inputs with different levels of contextual information.
2. gradual integration of the information inherent in different input scales.
3. multi-stream feature integration by learning in an end-to-end manner.
These methods are instrumental in extracting morphological features by gradually integrating contextual information in multi-scale patches, which help us to reduce the number of FPs and extract morphological and contextual features from the nodule region.
We tested this network on the LUNA16 challenge datasets and achieved the highest performance with an average CPM of 0.942 on the LUNA16 dataset, surpassing state-of-the-art methods by a large margin. This methodology was especially effective in low FP/scan conditions.
We believe that with minor modifications, such as replacing the fully-connected layers with $1 times 1$ convolution layers, our network can directly detect nodules from the CT scans.
For clinical practice, it is also important to classify nodules into different subtypes, such as solid, non-solid, part-solid, perifissural, calcified, spiculated, which may require different treatments. This will be our future research direction.
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/math/vec_00.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
// Test wide cell.
$ v = vec(1, 2+3, 4) $
|
https://github.com/protohaven/printed_materials | https://raw.githubusercontent.com/protohaven/printed_materials/main/common-tools/resaw_band_saw.typ | typst |
#import "/meta-environments/env-features.typ": *
= Resaw Band Saw
The _resaw band saw_ takes off slices of a board. Slices can vary in width from thick planks to thin veneers. A workpiece should have at least one flat face on the table in order to be stable during the cut.
One common use of the resaw band saw is to create bookmatched panels from a board.
== Notes
=== Safety
- Do not put round stock through the saw unsupported.\
_When cutting cylinders, use a jig to prevent the workpiece from spinning or twisting, and to keep the workpiece orientation straight and true as the cut is made._
- Do not cut lumber that has nails or loose knots.
=== Care
- Tension the blade before use, if needed. \
_The blade is under operating full tension at the 11 o'clock position._
== Parts of the Resaw Band saw
=== Full View
#figure(
image("images/resaw_bandsaw-back_quarter-annotated.png", width: 100%),
caption: [
An annotated full view of the resaw band saw.
],
)
=== Guides
#figure(
image("images/resaw_bandsaw-blade_guides.png", width: 100%),
caption: [
Blade guides and adjustments.
],
)
#pagebreak()
=== On/Off/Emergency Buttons
Use the *green button* to turn on the machine.
Use the *red button* to turn off the machine.
The large red emergency stop button is designed to be easy to hit if you need to power off the machine quickly.
#figure(
image("images/resaw_bandsaw-power_switch.png", width: 20%),
caption: [
Resaw band saw power switch.
],
)
=== Tension Lever
Use the tension lever to apply or release tension on the blade.
Before turning the saw on, always use the tension lever to put full tension on the blade.
=== Cabinet Doors
The cabinet doors cover the upper and lower wheels of the saw.
Both the upper and the lower cabinet doors must be closed while operating the machine.
The doors are an important safety feature: they prevent accidental contact with the blade, and will contain the majority of the blade when it breaks.
=== Blade Guard
The blade guard protects the blade, and can be adjusted to only expose enough of the blade to make the cut.
Unlock the blade guard to adjust the height. Set the guard at a height that will allow the workpiece to pass below it without making contact, but will prevent your hand from fitting between the bottom of the guard and the workpiece.
=== Blade Guard Lock Knob
The blade guard lock knob engages the blade guard lock, keeping the blade guard from moving up and down.
Loosen the blade guard lock knob to adjust the blade guard. Turning the crank without unlocking the knob will damage the gears.
Always tighten the blade guard lock knob before using the machine, to keep the blade guard from falling into the workpiece during a cut.
=== Thrust Guide
The thrust guide supports the back of the blade during the cut.
The thrust guide should be adjusted to create a gap of 1/64th of an inch (or less) behind the blade. The thrust guide should not make contact with the blade at idle. This gap provides a small amount of flex towards the rear, but prevents the blade from either rubbing against the guide when idling, or being pushed off the wheel during a cut.
=== Blade Guides
The blade guides keep the blade in proper position laterally, just above the workpiece.
The blade guides should be positioned as close to the sides of the blade as possible without scraping the blade when idling.
The front edge of the guides should be just behind the tooth profile of the blade. The blade guides should never extend into the teeth; the teeth will damage the blade guides.
// TODO: full instructions on knobs and locks for upper and lower sets of guides
=== Blade
The resaw blade is meant for straight cuts of large workpieces.
The blade has large tooth spacing, allowing thick stock to be cut without the swarf getting packed into the gullet.
The workpiece should be checked to make sure that at least two teeth will be buried in the material at all times during the cut. If the workpiece is thinner than two teeth, running the saw can result in individual teeth getting knocked off the blade, damaging it irreparably. If a tooth is broken, power off the saw immediately and report the issue.
=== Table
The table supports the workpiece as it moves past the blade.
Anything put through the saw should have at least one flat surface that can be presented to the table. Any twisting of the material will result in the blade binding in the cut, breaking the blade, and possibly breaking critical parts of the machine.
*Any workpiece that does not have at least one flat edge must be secured in a jig or sled* to safely perform a cut. Once a single cut has been made, the fresh edge can be used against the table for subsequent cuts.
=== Fence
Once a workpiece has two straight edges, use the fence to cut parallel slices off the workpiece.
The fence supports and guides the workpiece past the blade.
Adjust the fence so that the cut is of an appropriate width by lifting the fence release lever and moving the fence.
Once the fence is positioned, lock the fence in place by pushing down on the fence release lever.
#figure(
image("images/resaw_bandsaw-fence_release.png", width: 20%),
caption: [
Lift the fence release lever before adjusting the fence.
],
)
Often a dull or misaligned blade will cause the workpiece to wander away from the fence, causing a crooked cut.
Watch your cut carefully and support your workpiece firmly against the fence to prevent this.
=== Throat
The saw passes through the table via the throat.
Care should be taken to not push the blade laterally into the throat plate.
=== Push Stick
Use push sticks to move the work past the saw blade.
As you approach the end of a cut, you do not want your fingers to get close to the blade. Use a push stick to push your workpiece all the way past the blade. They are often sacrificial, and you can push the tip of the stick straight into the blade.
== Adjusting the Blade Guides
The resaw band saw has six blade guides to support the blade during a cut.
Above the table, there are three blade guides: an inner guide, and outer guide, and a rear guide. The inner and outer guides keep the blade from moving left or right. The rear blade guide supports the back of the blade during a cut, to keep it from being pushed off the wheels.
An additional set of three blade guides in the same configuration support the blade below the table.
The adjust a blade guide:
+ Loosen the guide lock screw.
+ Turn the guide adjustment knob so that the guide spins freely when the blade turns. \
_Do not overtighten the guides so that they clamp the blade._
+ Tighten the guide lock screw.
TODO: more notes on proper tolerances here. (check with Cord)
== Basic Operation
=== Work Holding
Apply pressure to keep the board firmly against the table and the fence.
=== Check the Blade
+ Put the blade in full tension.
=== Prepare the Machine
+ Check the table angle.\
_For most cases, the table should be 90° to the blade._
+ Check the blade guides.
+ Loosen the blade guard lock knob.
+ Adjust the blade guard to just above the height of the workpiece.
+ Adjust the fence for the desired cut width.
+ Make sure there is sufficient support available on both the infeed and outfeed sides of the cut for the size of the workpiece.
+ Turn on dust collection.
+ Turn on the saw and let it spin up to full speed.
+ Check for blade drift.\
_If the blade is drifting, stop the saw and alert a tech._
// do we want to explain drift in the glossary?
=== Making a Cut
#safety_hazard_box([
If the blade binds in the cut, #warning([POWER THE MACHINE OFF IMMEDIATELY]). Keep the workpiece stable until the motor has been disconnected from the power and has stopped completely.
Under normal use the blade will eventually break. This will usually be preceded by a rhythmic pulsing as a developing crack in the blade passes through the workpiece. If you experience this pulsing, stop and inspect the blade for damage. Inform a tech that the cracked blade should be removed from service immediately.
Do not back out of a cut while the blade is running. The blade will be pulled off of the front edge of the wheels, creating a safety hazard and causing irreparable damage to the machine.
])
+ Holding the workpiece firmly against the table and the fence, feed the workpiece into the blade.
+ Feed slowly and consistently through the length of the cut.\
_Make sure the workpiece does not twist or wander away from the fence._
+ As you reach the end of the cut, keep your fingers away from the blade.\
_Use a push stick to feed the trailing end of the workpiece past the blade._
=== Cleaning Up
+ Turn off the saw.
+ Wait for the saw to come to a complete stop before leaving the area.
+ Sweep up any dust. \
_There is a floor intake for the dust collection system on the wall behind the resaw band saw._
+ Turn off the dust collection system, if it is not otherwise in use.
|
|
https://github.com/VisualFP/docs | https://raw.githubusercontent.com/VisualFP/docs/main/Presentations/Post-Survey/presentation.typ | typst | #import "@preview/polylux:0.3.1": *
#set page(paper: "presentation-16-9")
#set text(size: 25pt)
#polylux-slide[
#align(horizon + center)[
= Visual FP
=== _Survery Results & Project Status_
]
]
#polylux-slide[
#v(1fr)
1. Survey Results
#v(1fr)
2. Project Status
#v(1fr)
3. How to proceed?
#v(1fr)
]
#polylux-slide[
= Survey Results
#v(1fr)
- The survey was intended to help us make a decision into which direction we
can go forward
#v(1fr)
- The examples were not fully developed & formally correct since we wanted to
think about those things in the later stages of the project
#v(1fr)
]
#polylux-slide[
= Survey Results
#v(1fr)
- The questionnaire was not up to the expected standard for the final group
of recipients
#v(1fr)
- As already mentioned, images are not able to convey the full interactivity and
scope of the ideas
#v(1fr)
]
#polylux-slide[
= Survey Results
/ Conclusion:
#v(1fr)
- None of the proposed concepts are mature enough, so there is no clear winner
#v(1fr)
- It would probably have been better to replace the questionnaire
with personal discussions
#v(1fr)
]
#polylux-slide[
= Project Status
#v(1fr)
For the SA, we have 14 weeks.
#v(1fr)
$
14 & - 5 && "are already gone" \
& - 5 && "for the minimal PoC" \
& - 1 && "to finalize the documentation" \
& - 2 && "to 'flesh out' a design" \
& = 1 && "to make a decision"
$
#v(1fr)
]
#polylux-slide[
= How to proceed?
#v(1fr)
To make it to the end, we propose to scratch some goals:
#v(1fr)
#pause
- There will not be enough time to think about a powerful type-system that
supports, e.g., type-classes or algebraic-types.
#v(1fr)
#pause
- There will be no concept for extensibility
#v(1fr)
#pause
- We will not further think about interoperability with Haskell
#v(1fr)
#pause
$arrow.double.r$ Without these changes, we worry that the time will run out
]
#polylux-slide[
= How to proceed?
#v(1fr)
As immediate next steps, we could:
#v(1fr)
- Improve one of the existing concepts based on the feedback
- Some suggestions are already covered, but it wasn't
conveyed since the format was lacking
#v(1fr)
- Think about an entirely different approach:
- Research in the direction of Lisp
- Google for another week
#v(1fr)
] |
|
https://github.com/sashiming/typst-test | https://raw.githubusercontent.com/sashiming/typst-test/main/main.typ | typst | // #import "@preview/codelst:2.0.1": sourcefile
// #import "@preview/cetz:0.2.2"
#import "@preview/physica:0.9.3": *
#let report(body) = {
set text(
lang: "ja",
font: (
"Latin Modern Roman",
"<NAME>",
),
weight: "regular"
)
set page(
paper: "a4",
margin: (
bottom: 1.75cm, top: 2.5cm,
left: 2cm, right: 2cm
)
)
}
#let fontSerif = ("Latin Modern Roman", "<NAME>")
#let fontSans = ("Loma", "Harano Aji Gothic")
#set page(
paper: "a4",
margin: (
left: 2.5cm, right: 2.5cm
),
)
#set text(
lang: "ja",
font: fontSerif,
weight: "regular",
size: 11pt
)
#show bibliography: set text(lang: "en")
#show raw: set text(font: ("Ubuntu Mono", "Harano Aji Gothic"))
#show par: set block(spacing: 0.9em)
#set par(first-line-indent: 1em, leading: 0.9em)
#show heading.where(level: 1): it => {
set text(
// font: fontSans,
// weight: "medium",
size: 13pt
)
[#v(3mm)]
it
par(text(size: 0.6em, ""))
}
#show heading.where(level: 2): it => {
set text(
// font: fontSans,
// weight: "medium",
size: 11pt
)
it
par(text(size: 0.6em, ""))
}
#set heading(
numbering: none
)
#set page(numbering: "1")
#let title(body) = {
set align(center)
set text(
size: 18pt
)
[#v(4mm)]
body
}
#let author(body) = {
set align(center)
set text(
size: 12pt
)
body
}
#set enum(numbering: "(1)", )
#title[タイトル]
#v(0.5em)
#author[J4230601 #h(1em) namename]
#v(1em)
= 見出し
ほげほげ
|
|
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/layout/page-margin_01.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
// Set individual margins.
#set page(height: 40pt)
#[#set page(margin: (left: 0pt)); #align(left)[Left]]
#[#set page(margin: (right: 0pt)); #align(right)[Right]]
#[#set page(margin: (top: 0pt)); #align(top)[Top]]
#[#set page(margin: (bottom: 0pt)); #align(bottom)[Bottom]]
// Ensure that specific margins override general margins.
#[#set page(margin: (rest: 0pt, left: 20pt)); Overridden]
|
https://github.com/tony-rsa/thonifho.muhali.cv | https://raw.githubusercontent.com/tony-rsa/thonifho.muhali.cv/main/src/sections/en/projects.typ | typst | MIT License | #import "../../template.typ": *
#cvSection("Projects")
#cvEntry(
title: [Spin],
host: [#link("https://github.com/tensorush/zig-spin")[#gh #hSpc() tensorush/zig-spin]],
date: [September 23, 2023],
mode: [In development],
logo: "assets/logos/spn.png",
desc: [#emoji.lizard #emoji.yoyo Zig SDK for Spin, a serverless application framework, created by the Fermyon team.],
)
#cvEntry(
title: [Meduza],
host: [#link("https://github.com/tensorush/meduza")[#gh #hSpc() tensorush/meduza]],
date: [October 16, 2023],
mode: [On maintenance],
logo: "assets/logos/mdz.png",
desc: [#emoji.lizard #emoji.merperson Zig codebase graph generator that emits a Mermaid class diagram.],
)
#cvEntry(
title: [Bookkeeper],
host: [#link("https://github.com/tensorush/bookkeeper")[#gh #hSpc() tensorush/bookkeeper]],
date: [September 1, 2023],
mode: [Completed],
logo: "assets/logos/bkr.png",
desc: [#emoji.hamster #emoji.books Backend for a bookkeeping service based on gRPC.],
)
#cvEntry(
title: [Zigzag],
host: [#link("https://github.com/tensorush/zigzag")[#gh #hSpc() tensorush/zigzag]],
date: [September 21, 2023],
mode: [On maintenance],
logo: "assets/logos/zgz.png",
desc: [#emoji.lizard #emoji.trident Multi-threaded CPU path tracer.],
)
|
https://github.com/ntjess/showman | https://raw.githubusercontent.com/ntjess/showman/main/examples/simple-local-showman.typ | typst | MIT License | #import "@preview/showman:0.1.1": formatter
#set page(height: auto)
#show: formatter.template
#include("simple.typ") |
https://github.com/jneug/schule-typst | https://raw.githubusercontent.com/jneug/schule-typst/main/src/subjects/cs-db.typ | typst | MIT License | #import "./cs-erd.typ" as erd
#import "../api/helper.typ": table-fill
#let primary-key(name) = underline(stroke: .1em, offset: 2pt, name)
#let foreign-key(name) = box()[#sym.arrow.t.filled#name]
#let pkey = primary-key
#let fkey = foreign-key
#let fpkey(name) = primary-key(foreign-key(name))
// #let schema( content ) = raw(block: false, content)
// #let schema( content ) = text(weight: "bold", content)
// #let schema( name, ..attributes ) = {
// text(weight: "bold", name); [(#attributes.pos().join(", "))]
// }
#let schema(..relations) = {
if relations.pos().len() == 0 {
return []
}
if type(relations.pos().first()) == str {
let (name, ..attris) = (..relations.pos(),)
text(weight: "bold", name + "(")
[#attris.join(", ")]
text(weight: "bold", name + ")")
} else {
set align(left)
list(
marker: "",
..relations.pos().map(((name, ..attris)) => text(weight: "bold", name + "(") + [#attris.join(", ")] + text(
weight: "bold",
")",
)),
)
}
}
#let example-data(name: none, headers: (), ..data) = {
let h-len = headers.len()
headers = headers.map(h => text(hyphenate: false, h))
if name != none {
headers.insert(0, table.cell(colspan: h-len, raw(block: false, name)))
}
table(
columns: h-len,
fill: table-fill(headers: if name != none {
2
} else {
1
}),
table.header(..headers),
..data.pos(),
)
}
|
https://github.com/EGmux/PCOM-2023.2 | https://raw.githubusercontent.com/EGmux/PCOM-2023.2/main/lista2/lista2q13.typ | typst | === Um aparelho de CD grava sinais de áudio utilizando modulação PCM. Assuma que a largura de banda do sinal de áudio vale 15 kHz.
\
==== a) Qual a taxa de Nyquist utilizada?
\
Como a banda do sinal de áudio é de 15kHz então *$f_N = 30 "kHz"$*
==== Se as amostras de Nyquist são quantizadas em 65.536, *$2^l = L$* níveis e então codificadas em binário, determine o número de bits necessários para codificar uma amostra.
\
lembrando da relação entre _l_ e _L_ que é dada pela seguinte equação
#math.equation(block: true, $ l &= log_2 L && \
&= log_2 65.356 && \
&= 16 "bits/amostra" && \ $)
==== Determine a taxa de bits necessária para codificar o sinal de áudio.
\
#math.equation(block: true, $ R_b &= f_N dot l && \
&= 30 "kamostra/s" dot 16 "bits/amostra" && \
&= 480 "kbits/s" && \ $)
==== Por razões práticas, sinais são amostrados a uma taxa superior à taxa de Nyquist. Aparelhos de CD utilizam 44.100 amostras por segundo. Se L = 65.563, determine a taxa de bits requerida para a codificação deste sinal e a largura de banda necessária para se transmitir este sinal codificado.
\
é ver o que muda se alterarmos o *$f_s$*
a taxa de bits muda e será dada por
#math.equation(block: true, $ R_b &= f_s dot l && \
&= 44.100 "amostras/s" dot 16 "bits/amostra" && \
&= 705600 "bits/s" && \ $)
e a largura de banda necessária como é 2-PAM é simplesmente ver o quanto custa
em "Hz" enviar um pacote que no caso é composta por 1 bits
#math.equation(block: true, $ W_"min" &= 705600 / 2 "Hz" && \
&= 352800 "Hz" && \ $)
|
|
https://github.com/polarkac/MTG-Stories | https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/043%20-%20Innistrad%3A%20Midnight%20Hunt/008_The%20Dance%20of%20Undeath.typ | typst | #import "@local/mtgstory:0.2.0": conf
#show: doc => conf(
"The Dance of Undeath",
set_name: "Innistrad: Midnight Hunt",
story_date: datetime(day: 24, month: 09, year: 2021),
author: "<NAME>",
doc
)
My dearest brother—
(If only because our parents never saw fit to give me another, better brother, which was very selfish of them, really. If they weren't interested in making more the slow way, they could have built me something. But as you are both the only brother I have and the only person remotely clever enough to understand my genius, I suppose you will, regretfully, have to do.)
Things have been getting dreadfully dull here in Thraben. I begin to wish you were here, not to make war against me as we did when we were children—those days are properly behind us, and better left buried, which is not a thing I would say of very much—but to build new wonders for my darlings to set themselves against. I have very nearly exhausted the living resources of this once-virile land, and for the life of me, I can't tell you where all the humans have gone! Certainly, a great many of them have died, but as those are still with me, in a slightly more pleasant form, it seems their fellows should have stayed as well, if only for their ridiculous histrionics and waving about of torches.
#figure(image("008_The Dance of Undeath/01.jpg", width: 100%), caption: [Gisa, Glorious Resurrector | Art by: Yongjae Choi], supplement: none, numbering: none)
Really, brother, I had forgotten how much of the fun in this great game is in the unpredictability of the pieces. An army of the dead is a thing of beauty and a joy forever, but there's not much unpredictability in a battalion that follows all orders impeccably and without hesitation. I dream of something worthy of setting myself against!
For all that you are, a slack-jowled abomination in the eyes of the watching moon, dear brother, I dream of you. Of any opponent worthy of the honor of my consideration. Even of your putrid, pointless constructs of sinew and skin, formed from the flesh of good, honest zombies.
I have called so many rats back from the grave. They dance on the rooftops of Thraben like the most gifted of ballet corps, and they never stop, not even when they leave their toes and tails behind, rotting away in ceaseless splendor. But what's the point when no one appreciates my efforts? I have achieved our greatest dream, absolute conquest, and found it to be more hollow than we could have ever imagined.
Your loving sister,
Gisa.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
Gisa—
If you're unhappy in Thraben, you have no one to blame but yourself, and your horrible personality, which has made isolation your inevitability since we were children, as no one can tolerate your company for long while they still draw breath. I've always known that you would only be truly happy among the dead. Well, you have your wish.
If you find no joy in it, that is on your own head. Do not contact me again.
Geralf.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
The plate shattered against the wall, sending shards of priceless antique porcelain scattering in all directions. Gisa shrieked, a banshee's wail drawn from the throat of a living woman, and picked up the matching teacup.
From the pile of shards already heaped against the base of the wall, it was obvious to anyone who looked that she'd been at this for a while. Not that there was anyone left to look; the wreckage of her tantrum would be some archeologist's artifact of the siege of Thraben, someday, when the living took back this city-turned-crypt from its unwanted new regent.
"That filthy, talentless, worthless #emph[waste] of a perfectly good #emph[skeleton] !" Gisa shouted, hurling the teacup after its fellows. The sound it made when it shattered seemed to calm her somewhat, because she paused as she picked up the next plate, weighing it more carefully in her hand, like she was considering the angle of her throw. A casual observer who didn't know any better might have taken this pause as an opportunity to jump in and suggest she do something more soothing with her time or stop smashing teacups and drink a relaxing cup of herbal tea instead.
Sadly, everyone who left in what had been the main cathedral of Thraben, save for Gisa herself, was beyond such suggestions, being quite unmistakably dead. The ghoulcaller had done the sensible thing after Liliana's zombies took the city and Liliana herself moved on; she had secured it. That meant eliminating as much of the remaining living population as she possibly could, since the living were notoriously self-interested, and tended to object to being chewed on.
Having no interest in being overthrown, imprisoned, or worse, watching her beloved dead put back into the ground before she was done with them, Gisa had taken care of the threat.
But the threat was also the source of raw materials with which to expand her army, and not being—ugh—a stitcher like her blighted brother, may he be consumed by boils and burdens of the living flesh until he surrendered himself to the merciful embrace of death itself, she couldn't put her creatures back together once they reached a certain level of damage. Their flesh rotted much more slowly than it would have done in the ground, without her borrowed vitality to sustain it, but it still rotted. Limbs dropped away. Jaws loosened; teeth left their sockets. She could hold the city for now, while her legion was strong and her rule unquestioned; she couldn't hold it forever.
Empress of the empty grave and unchallenged queen of Thraben, Gisa collapsed into the plush chair that served as her throne, dropped her chin onto her knuckles, and sulked.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
Outside the walls of Thraben, on the long, empty road between it and the last human-held city in Gisa's tenuous domain—now a smoldering husk occupied by the slowly gathering geists of the doomed and the dead, left to burn when they refused to rise—an army marched.
It marched without hunger or exhaustion, without pause for rest. When a marcher fell, they were left in the mud, ground to paste beneath the feet of their fellows. Not a single one objected or complained. Those weaknesses were behind them now.
At the head of their column rode a man with sunken cheeks and a still-glorious mane of hair despite the rot and blood that caked it close to his skull. His steed was a once-mighty warhorse whose hide had been mostly peeled away by decay, leaving it a walking sculpture of muscle and bone. Every step flexed its flanks and caused flecks to drop away, wearing it down stride by stride.
It carried its rider onward, single-minded in death as nothing living could ever be, and that rider scanned the horizon, axe in hand, watching for signs of movement near the walls of Thraben.
#figure(image("008_The Dance of Undeath/02.jpg", width: 100%), caption: [Wilhelt, the Rotcleaver | Art by: <NAME>], supplement: none, numbering: none)
He could feel her even now, calling, calling, endlessly calling. He was not one of her mindless thralls, for all that he could name her as the architect of his second, better existence; he would have died a satiated man, happy with the story of his life, with the women he had wooed and the works he had done, had she not spurned him so unfairly. He and Gisa were meant to be together. What truer proof could there be than the fact that when he died, he rose to the mere memory of her call, still the man he was in life, still hale and handsome and ready to woo, ready to be wooed in return? He would seek her. He would find her. And he would take his rightful place at her side, Wilhelt the Breathtaking and Gisa the Glorious, figures worthy of the legend that would surely grow up around them, burying its roots in the fertile soil of their love.
Before his own death and return, he would have said ghouls had no souls remaining, that whatever animated them was beyond human feeling. And true, they had always seemed unfeeling when he walked among the living, when they were monsters to stalk the night and terrorize the innocent; but now he knew the truth. Now that he walked on the other side of the grave, he had finally seen the beautiful complexity that slumbered within the unbeating hearts of the dead. Every day when his army took shelter from the worst of the sun—the smell of sunbaked decay was never going to win any prizes—he would close his eyes and dream his dead man's dreams of Gisa.
Gisa, his purpose. Gisa, his love. Gisa, who would be his queen as soon as she accepted that his love was true and his suit sincere.
At the head of his column of the dead, Wilhelt marched on Thraben, and silence followed behind, unbroken by the screams of men or the caws of carrion birds. Where his army marched, none were left to live.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
Dear <NAME>,
I knew you were my inferior. I never guessed you could be so #emph[cruel] . I played your stupid games. I followed your endless, pointless, insufferable rules. I was the best of sisters, the #emph[very best] of all possible sisters—far finer than #emph[you] deserved—and now you would abandon me to boredom and the dust? You cannot even send something horrible and pointless, cobbled together from a dozen beastly birds, to give me something to do with my time? I mourn and molder here, dear brother, and at times, I even wish the people of Thraben—the ones who survived, weaklings and cowards that they were, to run so before that arrogant girlfriend of yours, Liliana—would take up torches and swords and march against me, as they might have done in days of old.
But alas, I know where the people of Thraben are located, and they are all here with me already, all sworn into my service. I could command them to lay siege to my battlements and threaten their fellows, but it would be little more than a shadow play, all the puppets tethered to my hand. I could release a few from my control, letting them turn feral and furious, but they would be quickly dismantled by the rest of my hoard, and my subjects are good, and obedient, and most importantly, #emph[mine] . To sacrifice them so frivolously would be unkind in the extreme. I cannot do that to them. No matter how powerful the temptation. It would be unfair.
See, I can even treat the dead in my dominion fairly, and you cannot do the same for your own once-beloved sister! Some brother you've turned out to be.
(No longer) Yours,
Gisa.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
Gisa—
I'm gifted at my art, even as I admit you have a flair for your own. Our parents passed down good bones and good blood at the same time, and we would have to be fools indeed to have squandered both. As I know you've made use of our parent's bones, against my strident objections, I must assume you're putting their blood to good use as well in your continued domination of Thraben.
I admit that your quick thought in claiming the city and Liliana's abandoned thralls impressed me. I would have done the same, in your location and possessed of your talents. But I am not jealous. My own work consumes my every waking moment; I'm honestly not sure how I've been able to carve free the time to answer your latest mewling missive.
No, I will not come to save you from the fruits of your own machinations. No, I will not intervene with this disaster of your own making. You wanted this. In the common parlance, you dug your own grave, and now you get to rot in it.
Geralf.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
Gisa stalked the balcony of the cathedral, circling the spire again and again, the wind whipping through her hair and tugging her clothes into barely noticed disarray. A few dead bats squeaked their adoration as she passed them, and she acknowledged their service with a waggle of her fingers, unable to even take pleasure in their leather-winged loyalty. Calling small rodents, even the flying kind, was a child's work; Geralf would surely scoff if he saw them and ask in that smug, superior tone of his whether she didn't think she'd moved beyond such childish pastimes.
Ugh. How she missed the sound of his droning arrogance, the way he stretched his vowels as if they could stand in judgment by themselves, the way he thought he knew more than anyone else, no matter what the topic. She could never have admitted it to his face, and would have denied it to the grave, but she missed her brother.
It was odd, being away from him this long for reasons other than one or both being locked away by small-minded fools who couldn't understand the power of the Cecani genius. Dying in service of their family name was a privilege, not a right, and people shouldn't react so poorly to the honor. Especially since it wasn't like they #emph[stayed] dead for terribly long.
Gisa glared at the cloudy night sky, as if daring it to do something that would offend her more than her brother's latest missive. Then she paused.
Someone was riding along the road to Thraben.
#figure(image("008_The Dance of Undeath/03.jpg", width: 100%), caption: [Visions of Dread | Art by: <NAME>], supplement: none, numbering: none)
No one had come riding along that road in months. It had been quite abandoned since Liliana's dead—now Gisa's dead—had taken the city, and none living dared its boundaries! But now someone was coming, light glinting off the weapon in their hand, and what looked to be a full legion of men marched behind them. Gisa squinted at the shapes moving along the road.
No, not men. They moved as one, oddly organized, but without the smoothness of the living; their feet rose and fell in the herky-jerky rhythm of the dead. These were risen men, and that meant the figure at their head must be their ghoulcaller. Her eyes narrowed. No one was going to claim #emph[her] territory. No one was even going to challenge her for it.
And it was something to do, which was delightful all beyond words. She whirled and ran for the stairs, descending into the depths of cathedral, undead bats fluttering in her wake and squeaking at a register that even most of the dead couldn't hear.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
Wilhelt reached the gates of Thraben, closed and rusted, unattended by human hands for far longer than they should have been, and found Gisa already waiting there, her glorious hair unbound, her fine gown torn into the most artful and elegant of tatters. She must have done it to celebrate his arrival, for why would she have made herself so beautiful for any lesser man?
"Beautiful Gisa," he yelled, and his voice was still clear and strong, despite the darkness of the grave. Surely that alone would tell her he was no ordinary ghoul! How many of the risen could speak so clearly, could remember the name of the woman who they had loved in life? None among his company could manage such a feat! "At long last your loneliness is at an end, for I have come to join you!"
Gisa looked at him, those perfect lips curving into a slow smile, that perfect brow wrinkling in what seemed for all the world to be confusion. Finally, tilting her head to the side, she asked, "Do I know you?"
Wilhelt stared at her. "Of course you do," he replied. "I am <NAME>htaking, and I have come to take your breath away."
"I'm still using my breath," said Gisa.
Wilhelt's stare became a scowl. "We met in the wood! It was a glorious day, made all the more so by the combined radiance of our presence."
"Oh," said Gisa, in sudden recognition. "Wilham. I #emph[do ] remember you. You were that pretty, pretty woodsman I met while I was searching that ancient barrow for new friends. You were less interesting than any of the dead things I'd found, and I left you to your trees. I have no real room for vanity in my life; not with Geralf so consumed by the need to swoon over his own genius." When he didn't move, she raised one hand and waved languidly, like that might be enough to hurry him along.
It didn't. He gaped at her, dead eyes disbelieving. "I came all this way~you would spurn me a second time, after everything I've done for you? I #emph[died] for you!" Well, that wasn't entirely true. But the falling tree that crushed him had certainly possessed a romantic air.
"It didn't seem to stick, and you've risen without the benefit of a ghoulcaller, from the looks of it," said Gisa, and Wilhelt was shocked to hear dismissal in her tone. "Tsk. Sloppy work, if you ask me. Any fool can plant a bush. It takes a master to shape that bush into an elephant."
Wilhelt kept staring at her as she raised her hands and whistled, a long, low note that seemed to hook itself around the base of his spine and yank, like a hook sliding into a fish. He was faced with the sudden, near-irresistible desire to lay down his axe and go to her, to surrender the fierceness of will that had called him from the grave to raise an army of his own and go to her side. To be a thrall and not a commander, subject to the whims and whimsies of her desire.
His arm trembled, muscles suddenly tired of holding his great weapon high, and he trembled as well, with the force of resisting. He had come here to join her as an equal, not as a thrall, but in the eyes of <NAME>, the dead could never be equal, could never be peers, could be beloved, certainly, kept as pets were kept, but could not be her home or comfort.
He was not a possession. He was Wilhelt, dubbed the Breathtaking by every woman who had ever beheld him—every woman save for one—and that was the only woman who could possibly have been good enough for him. He had called his own army forth, despite not being considered a ghoulcaller in life, and they marched to his command. He would not yield. Gisa pulled. Wilhelt pulled back. Gisa #emph[yanked] . Wilhelt nearly stumbled, his will yielding, before he recovered his mental grip and yanked in answer, breaking the tie between them as Gisa's whistle died, choked off in her throat.
She coughed, spitting out a few dissonant notes, then looked at him with narrowed eyes. "So, it's to be like this?" she asked.
He snarled. "I am no doll to be drawn into your games! Give me a chance, beautiful Gisa, and I will prove myself your peer in glorious undeath!"
Gisa's eyes narrowed. "Very well, then. I was getting bored anyway." And she retreated back through the gates of Thraben, slamming them decisively behind her, leaving Wilhelt and his army standing in front of the city, momentum broken, but mind still utterly his own.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
Gisa slammed the door and whirled to press herself against it, as if her narrow body would be the final barrier to keep that #emph[man] and his legion from breaching the walls of #emph[her] city. Imagine, Wilham, #emph[here] ! In Thraben, where he had never once been invited to be, waltzing in as if he owned the place! And risen without aid, as if that weren't unutterably gauche!
People died, becoming corpses. Ghoulcallers pulled them back into the Plane, transforming them into ghouls. Or butchers like her brother used science to imbue them with a hideous, dishonest parody of life, as if electricity and chemical connections could ever replace good old-fashioned necromancy! People didn't simply die and get back up again of their own accord! Or, well, they did, she knew perfectly well that they did, but they #emph[shouldn't] ! It was inappropriate! It was unnecessary! It was~
It was #emph[untidy] . Yes, that was the word she wanted.
Untidy, but welcome all the same, because it was something to #emph[do] . Geralf might think he was the only opponent she could have, but she knew better, and this~Wilham had managed something unlikely and annoying enough that he might well present a decent challenge. There was nothing like the opportunity to test herself and her beloved toys against an opposing force! Oh, she'd been waiting for something like this day.
When something clanged against the outside of the door, Gisa straightened, whistled her subjects back to her, and ran. Not that she was afraid of a dead man, oh no, not in the least, but he was in all his strength on the road before her city, while she was attended only by the few who had been close enough to join her without notice. If he came in his strength, he would meet with her in all her glory, and they would see who was the superior in the dance of undeath. He would learn, as all others had learned before him, that those who underestimated <NAME> did so at their peril.
They rarely did anything else after that, unless she asked them to.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
The hooves of Wilhelt's stallion battered against the rusted doors of Thraben with deep, ringing echoes as Wilhelt urged the beast on, until the door crumbled between one blow and the next and the city lay open before them. Wilhelt urged his troops through the opening, choosing—wisely—to ride at the center of the formation, rather than up at the front. They needed him to direct them, and he couldn't do that if he couldn't see where he was going.
Yes. That was absolutely the reason, and not the vague fear of what an angry ghoulcaller could do when cornered in her own lair. He urged his army forward and they, having no will of their own, went. He rode well-shrouded in the decaying bodies of his fellows and didn't notice the sky above him begin to darken.
They passed under a stonework bridge, and when they rode back out the other side, the sky stayed shadow-dark above them. Wilhelt glanced up.
The swirling veil of bats and ravens, crows and vultures, opened rotting mouths, shrieked with rotting throats, and descended.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
Only the most powerful ghoulcallers can whistle the beasts from their burrows, call them out of their nests, but those who can tend to have a remarkable fondness for the swarm, the nest of rats or flock of bats that has fallen into their hands. Gisa, given the population of a city to bend to her designs, was no different. Undead, rotting birds dropped from the sky to lash their talons at Wilhelt and his men. Fruitlessly, they swatted their attackers away as Wilhelt shielded his face with his arms before roaring with fury and swinging his axe in a great arc, sundered birds falling like rain. He swung again, and again, and laughed as his subjects began plucking flying things out of the air and ripping them in two.
And he rode on.
#figure(image("008_The Dance of Undeath/04.jpg", width: 100%), caption: [Siege Zombie | Art by: <NAME>], supplement: none, numbering: none)
They passed out of the city entrance and onto the broad avenue that had once marked the small but bustling shopping district. The stores stood empty, doors ajar, windows dark. Wilhelt urged his men onward.
They were halfway down the avenue when the dead surged out of the buildings to either side, hands raised, ready to catch and tear and kill.
"#emph[GIIISSSSAAAAA!] " roared Wilhelt, brandishing his axe as the battle raged around him. His horse reared and struck, driving sharp bony hooves through brittle skulls.
"You don't have to #emph[shout] ," said an irritated voice from the walkway above. Wilhelt raised his head.
"Come now, Wilham, it doesn't have to be like this," she said. "Why not surrender them to the superior ghoulcaller? It will be a better ending than the one they're meeting now~"
Desperately, Wilhelt glanced back to his men. They were fighting valiantly, but while he had an army, Gisa had a #emph[population] . For every one his men destroyed, three more rushed in to take its place, still pouring endlessly from the broken stores. If this continued, they would lose. He turned back to Gisa.
"No," he snarled. "I will prove to you that we can be more than toys!"
"But here you are, playing with your little soldiers." Gisa sighed. "Very well. Farewell, Wilham." Then she flounced away down the walk, not looking back, as her soldiers surged forward.
She was still beautiful. Wilhelt watched her go, wistful as he'd ever been, as Gisa's dead struggled with his own line in a listless, brutal slugging match. They couldn't hope to win—he understood that now. But perhaps a triumph of arms (and legs, and severed heads) wasn't the only way to Gisa's heart.
Wilhelt reached under his breastplate and pulled out the letter he had carried next to his own unbeating heart since his resurrection. It had been written before his fingers stiffened beyond the formation of simple words and was still very legible, for a ghoul. Really, how could she help but be impressed by him?
Turning to his men, he selected one of the least decayed, who looked reasonably spry, and thrust the letter in his direction. "Go," he commanded. "You are my gift to her. Run until she bids you otherwise, only see that you give her the letter before you give over your will."
The man took the letter and ran, shuffling and stumbling, in the direction Gisa had gone.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
Gisa positioned herself dead center of the square, flexing her hands and breathing quickly. She shouldn't have been this excited by the idea of a fight with someone other than stupid, #emph[stupid] Geralf, but she was; this "Wilham" might be nothing but a ghoul, but he'd still managed to raise an army of his own and come to face her. He was too clingy—she wasn't going to invite him to share her lair any time soon—but he was intriguing. She was willing to admit that.
A single ghoul ran into the square, heading straight for her, an envelope clutched in his hand. She whistled and felt the hook of her song sink into his rotting mind, seizing him away from Wilham's clutches in an instant. She smiled as the boy walked more sedately to her side, now properly in her control, and plucked the envelope from his hand.
Inside was a single sheet of paper. She blinked, reading it twice before she crumpled it into a ball and tossed it to the ground.
"Beautiful Gisa—
I lived for you. I loved for you. I died for you. I rose for you.
Everything I have done in my existence has been to earn your regard.
Make me the happiest of men or ghouls, and be my queen.
Wilhelt."
#emph[WILHELT. ] As if she would get his name wrong, if he mattered half as much as he thought he did! The #emph[presumption] of the man, to come to #emph[her] territory, to deny her the ghouls that were so rightfully hers, and then to imply that she could be wrong about something as basic as a name!
She resolved to destroy him.
The invading army rode into the square, their handsome, rotting leader at their head. For the first time, he got down from his horse, striding forward with axe in hand.
"Gisa!"
She rolled her eyes. "Yes, Wilham, I know my own name. This is your last chance—surrender your ghouls, and yourself, to me, and I'll let you—well, not live. But you get the idea."
He glanced to the balled-up sheet of paper on the ground and his face fell. "No one has ever resisted my charms."
"Sweet Wilham. There's a first time for everything." She whistled, sharp and quick, and he felt his hold on his men seized again by that unseen force. He knew that was Gisa struggling to rip them away. Wilhelt roared and yanked back, delighted to see Gisa stumble, even if only a small bit; he was strong, see? He could make her listen!
Then Gisa screamed, and all the bats in Thraben descended.
#figure(image("008_The Dance of Undeath/05.jpg", width: 100%), caption: [Ghouls' Night Out | Art by: <NAME>iawan], supplement: none, numbering: none)
It didn't seem possible that something as small as a bat could possess so many razor-sharp teeth, or attack with such ferocity. For every one Wilhelt or his men slapped out of the air, four more surged forward, shrieking tinny shrieks and ripping at any exposed flesh. Even armor was no defense against an endless stream of biting, flying rodents whose own sense of self-preservation had been stripped away.
In the end, with the shambling remnants of his army at his side, Wilhelt was forced to turn and flee, lest his second, presumably final life end as abruptly as his first.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
Gisa picked herself out of the shattered glass covering the cathedral steps, screams of the dead still ringing in her ears, loud enough to almost obscure the soothing hammer of her heart. Geralf would never let her hear the end of it if she died before he did! Bits of broken corpse were scattered around the square, human and otherwise; a pair of undead ravens pecked at the eyes of Wilham's horse, fallen and decapitated, the head—and eyes—some distance from the rest.
Wilham himself was gone. Gisa couldn't find a single piece of him.
She looked around the gore-strewn square and sighed. That was the end of this game, then. Well, there was always the next to resume.
And wouldn't Geralf be pleased to see her?
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
My dearest brother—
I have concluded that you are lost without me and need my loving sisterly presence to give meaning to your wasted life. I am on my way to you now and should be there inside of the sennight. Have a room ready for me. I can't wait to see what you've been doing while I was occupied with ruling the city your useless girlfriend abandoned!
Once more, your adoring sister,
Gisa.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
Gisa,
What? No! I don't require your presence, which has never been loving, and can be called sisterly only on the technicality that we are unfortunately related! You will only disrupt my research. Please, please, if you must leave Thraben, go anywhere else in all of Innistrad, I beg. Anywhere but here.
Most certainly NOT yours,
Geralf.
|
|
https://github.com/SillyFreak/typst-scrutinize | https://raw.githubusercontent.com/SillyFreak/typst-scrutinize/main/src/task.typ | typst | MIT License | #let _label = <scrutinize-task>
#let _start = <scrutinize-start>
#let _end = <scrutinize-end>
/// Encloses the provided body with labels that can be used to limit what tasks are considered
/// during lookup. This is helpful if there are independent exams/sections in the same document, or
/// for this documentation (separate examples).
///
/// The lookup functions in this package properly handle nested scopes.
///
/// Example:
///
/// #{
/// import task: t
/// set heading(numbering: none, outlined: false)
/// show: task.scope
/// example(
/// mode: "markup",
/// ratio: 1.8,
/// scale-preview: 100%,
/// scope: (t: t),
/// ```typ
/// #task.scope[
/// Number of tasks: #context task.all().len()
/// #task.scope[
/// = A (counts) #t()
/// ]
/// = B (counts too) #t()
/// ]
/// = C (doesn't) #t()
/// ```
/// )
/// }
///
/// - body (content): the scope's body
/// -> content
#let scope(body) = {
import "utils/scope.typ": scope
scope(_start, _end, body)
}
/// Sets the task data for the most recent heading. This must be called only once per heading;
/// subsequent calls won't do anything. The task metadata can later be accessed using the other
/// functions in this module.
///
/// - ..args (arguments): only named parameters: values to be added to the task's metadata
/// -> content
#let t(..args) = {
assert(args.pos().len() == 0)
[#metadata((: ..args.named())) #_label]
}
#let _extract-tasks(tasks-headings, level, depth, top-level: false, flatten: false) = {
let tasks = ()
if depth == 0 { return tasks }
let new-depth = if depth == auto { auto } else { depth - 1 }
for (i, h) in tasks-headings.enumerate() {
// we want to only consider headings
if h.func() != heading { continue }
// if we leave the requested level, we're done
if h.level < level {
if top-level {
// we're enumerating top-level tasks; keep going but ignore this
continue
} else {
// we just exited the parent task; stop here
break
}
}
// we want to only consider headings at the requested level
if h.level > level { continue }
let task = (heading: h, data: none)
// we found a heading at i, so if there's task metadata it's at i + 1
if i + 1 < tasks-headings.len() {
let candidate = tasks-headings.at(i + 1)
if candidate.func() == metadata {
task.data = candidate.value
}
}
if new-depth == 0 {
// the task is complete, push it
tasks.push(task)
} else {
let subtasks = _extract-tasks(tasks-headings.slice(i + 1), level + 1, new-depth)
if flatten {
// push the task and its subtasks separately
tasks.push(task)
tasks += subtasks
} else {
// push the task after adding the subtasks
task.subtasks = subtasks
tasks.push(task)
}
}
}
tasks
}
/// Looks up the most recently defined heading of a certain level and retrieves the task data, in
/// a dictionary of the following form:
/// - `heading` is the heading that starts the task; through this location information can also be
/// retrieved.
/// - `data` contains any data passed to @@t().
/// - `subtasks` recursively contains more such dictionaries.
/// `subtasks` only exists down to the specified `depth`: if the depth is 1, no subtasks are
/// retrieved, `auto` means an unlimited depth.
///
/// Only tasks within the specified range are considered. For example, if this is called within a
/// @@scope() but the enclosing level 1 heading is _outside_ the scope, this function will not find
/// anything and fail. To still succeed, you need to either increase the range via `from` and `to`,
/// or provide a location via `loc` that is outside the problematic scope.
///
/// This function is contextual and must appear within a ```typ context``` expression.
///
/// Examples:
///
/// #{
/// import task: t
/// set heading(numbering: none, outlined: false)
/// show: task.scope
/// example(
/// mode: "markup",
/// ratio: 1.8,
/// scale-preview: 100%,
/// scope: (t: t),
/// ```typ
/// = Example task
/// #t(points: 2)
/// #context [
/// #let name = task.current().heading.body
/// #let points = task.current().data.points
/// "#name" is worth #points points,
/// or up to #(points + 1) points for great answers!
/// ]
/// ```
/// )
/// }
///
/// #{
/// import task: t
/// set heading(numbering: none, outlined: false)
/// show: task.scope
/// example(
/// mode: "markup",
/// ratio: 1.8,
/// scale-preview: 100%,
/// scope: (t: t),
/// ```typ
/// = Example task
/// #context [
/// #let subtasks = task.current(depth: 2).subtasks
/// #let total = subtasks.map(t => t.data.points).sum()
/// This task gives #total points total.
/// ]
/// == Subtask 1 #t(points: 2)
/// == Subtask 2 #t(points: 2)
/// ```
/// )
/// }
///
/// - level (int): the level of heading to look up
/// - depth (int, auto): the depth to which to also fetch subtasks
/// - from (location, auto, none): the location at which to start looking;
/// `auto` means start of the enclosing @@scope(), `none` means start of the document
/// - to (location, auto, none): the location at which to stop looking;
/// `auto` means end of the enclosing @@scope(), `none` means end of the document
/// - loc (location, auto): the location at which to look; `auto` means `here()`
/// -> dictionary
#let current(level: 1, depth: 1, from: auto, to: auto, loc: auto) = {
import "utils/scope.typ": enclosing
let (from, to, loc) = (from, to, loc)
if loc == auto {
loc = here()
}
if from == auto or to == auto {
let (_from, _to) = enclosing(_start, _end, loc: loc)
if from == auto {
from = if _from != none { _from.location() } else { none }
}
if to == auto {
to = if _to != none { _to.location() } else { none }
}
}
let h = query(heading.where(level: level).before(loc)).last()
let sel = selector(_label).or(heading).after(h.location())
if from != none { sel = sel.after(from) }
if to != none { sel = sel.before(to) }
let tasks-headings = query(sel)
_extract-tasks(tasks-headings, level, depth).first()
}
/// Locates all tasks in the document (or scope, or region of the document), which can then be used
/// to create grading keys etc. The return value is an array with elements as described in
/// @@current(), except: if `flatten` is true, there will never be subtasks and instead subtasks
/// down to the specified depth will follow their parent. Note that even then, nesting information
/// is present through `heading.level`.
///
/// Headings of the specified `level` are treated as top-level tasks; any higher level headings,
/// even if they have an associated @@t(), are ignored.
///
/// This function is contextual and must appear within a ```typ context``` expression.
///
/// Examples:
///
/// #{
/// import task: t
/// set heading(numbering: none, outlined: false)
/// show: task.scope
/// example(
/// mode: "markup",
/// ratio: 1.8,
/// scale-preview: 100%,
/// scope: (t: t),
/// ```typ
/// #context [
/// #let tasks = task.all(level: 2)
/// Number of tasks: #tasks.len() \
/// Total points: #tasks.map(t => t.data.points).sum()
/// ]
/// == A #t(points: 2)
/// == B #t(points: 3)
/// === B1 #t(points: 1)
/// ```
/// )
/// }
///
/// #{
/// import task: t
/// set heading(numbering: none, outlined: false)
/// show: task.scope
/// example(
/// mode: "markup",
/// ratio: 1.8,
/// scale-preview: 100%,
/// scope: (t: t),
/// ```typ
/// #context [
/// #let tasks = task.all(level: 3)
/// Number of tasks: #tasks.len() \
/// Total points: #tasks.map(t => t.data.points).sum()
/// ]
/// == Part 1
/// === A #t(points: 2)
/// == Part 2
/// === B #t(points: 3)
/// ```
/// )
/// }
///
/// #{
/// import task: t
/// set heading(numbering: none, outlined: false)
/// show: task.scope
/// example(
/// mode: "markup",
/// ratio: 1.8,
/// scale-preview: 100%,
/// scope: (t: t),
/// ```typ
/// #context [
/// #let tasks = task.all(level: 2, depth: auto,
/// flatten: true)
/// Number of tasks & subtasks: #tasks.len()
/// ]
/// == A
/// === A1 #t(points: 2)
/// === A1 #t(points: 3)
/// == B
/// === B1 #t(points: 1)
/// ```
/// )
/// }
///
/// - level (int): the level of heading to look up
/// - depth (int, auto): the depth to which to also fetch subtasks
/// - from (location, auto, none): the location at which to start looking;
/// `auto` means start of the enclosing @@scope(), `none` means start of the document
/// - to (location, auto, none): the location at which to stop looking;
/// `auto` means end of the enclosing @@scope(), `none` means end of the document
/// - loc (location, auto): the location at which to look; `auto` means `here()`
/// - flatten (boolean): whether to flatten subtasks
/// -> array
#let all(level: 1, depth: 1, from: auto, to: auto, loc: auto, flatten: true) = {
import "utils/scope.typ": enclosing
let (from, to, loc) = (from, to, loc)
if from == auto or to == auto {
let (_from, _to) = enclosing(_start, _end, loc: loc)
if from == auto {
from = if _from != none { _from.location() } else { none }
}
if to == auto {
to = if _to != none { _to.location() } else { none }
}
}
let sel = selector(_label).or(heading)
if from != none { sel = sel.after(from) }
if to != none { sel = sel.before(to) }
let tasks-headings = query(sel)
_extract-tasks(tasks-headings, level, depth, top-level: true, flatten: flatten)
}
|
https://github.com/yasemitee/Teoria-Informazione-Trasmissione | https://raw.githubusercontent.com/yasemitee/Teoria-Informazione-Trasmissione/main/2023-10-06.typ | typst | #import "@preview/tablex:0.0.5": tablex
#import emoji: suit
= Introduzione
== Storia
La teoria dell'informazione nasce nel 1948 grazie a *<NAME>* (1916-2001), un impiegato alla "Telecom" americana al quale sono stati commissionati due lavori: data una comunicazione su filo di rame, si voleva sfruttare tutta la capacità del canale, ma al tempo stesso correggere gli errori di trasmissione dovuti al rumore presente.
Nel luglio 1948 infatti viene pubblicato l'articolo "_A Mathematical Theory of Communication_" da parte di Bell Labs, dove Shannon pone le basi della teoria dell'informazione.
Ma non è l'unico personaggio che lavora in questo ambito: infatti, nel 1965, tre matematici russi pubblicano degli articoli che vanno a perfezionare il lavoro fatto anni prima da Shannon.
I tre matematici sono <NAME> (1947-), <NAME> (1926-2009) e *<NAME>* (1903-1987), ma si considerano solo gli articoli di quest'ultimo poiché ai tempi era molto più famoso dei primi due.
== Shannon vs Kolmogorov
La situazione generica che troveremo in quasi la totalità dei nostri studi si può ridurre alla comunicazione tra due entità tramite un *canale affetto da rumore*.
#v(12pt)
#figure(
image("assets/2023-10-06_canale.svg", width: 50%)
)
#v(12pt)
Quello che distingue Shannon da Kolmogorov è l'approccio: il primo propone un *approccio ingegneristico*, ovvero tramite un modello formato da una distribuzione di probabilità si va a definire cosa fa _in media_ la sorgente, mentre il secondo propone un *approccio rigoroso e formale*, dove sparisce la nozione di media e si introduce la nozione di sorgente in modo _puntuale_.
In poche parole, dato un messaggio da comprimere:
- Shannon direbbe "lo comprimo _in media_ così, e lo comprimerei così anche se il messaggio fosse totalmente diverso";
- Kolmogorov direbbe "lo comprimo _esattamente_ così, ma lo comprimerei in modo totalmente diverso se il messaggio fosse diverso".
== Obiettivi di Shannon
Gli obiettivi che Shannon vuole perseguire sono due:
- *massimizzare* l'informazione trasmessa _ad ogni utilizzo del canale_;
- *minimizzare* il numero di errori di trasmissione dovuti alla presenza del rumore nel canale.
La parte "_ad ogni utilizzo del canale_" viene inserita per dire che, ogni volta che si accede al canale, deve essere utilizzato tutto, mentre senza questa parte una sorgente potrebbe mandare l'1% del messaggio ad ogni accesso al canale, mandandolo sì tutto ma senza sfruttare a pieno la banda.
Shannon risolverà questi due problemi con due importantissimi teoremi:
- *$I$° teorema di Shannon*, che riguarda la _source coding_, ovvero la ricerca di un codice per rappresentare i messaggi della sorgente che massimizzi l'informazione spedita sul canale, ovvero massimizzi la sua *compressione*;
- *$\I\I$° teorema di Shannon*, che riguarda la _channel coding_, ovvero la ricerca di un codice per rappresentare i messaggi della sorgente che minimizzi gli errori di trasmissione dovuti alla presenza del rumore nel canale.
L'approccio che viene usato è quello _divide-et-impera_, che in questo caso riesce a funzionare bene e riesce ad unire i risultati dei due teoremi di Shannon grazie al *teorema di codifica congiunta sorgente-canale* e ad alcune relazioni che legano i due problemi descritti.
In un caso generale del _divide-et-impera_ si ricade in una soluzione sub-ottimale.
== Primo teorema di Shannon
Il primo problema da risolvere è il seguente: come è distribuita l'informazione all'interno di un documento?
Vediamo due esempi dove un documento viene spedito su un canale e alcune informazioni vengono perse per colpa del rumore presente nel canale.
#v(12pt)
#figure(
image("assets/2023-10-06_poca-informazione.svg", width: 75%)
)
#v(12pt)
In questo primo esempio notiamo che, nonostante l'informazione persa sia sostanziosa, possiamo in qualche modo "risalire" a quello perso per via delle informazioni che troviamo "nelle vicinanze".
#v(12pt)
#figure(
image("assets/2023-10-06_tanta-informazione.svg", width: 75%)
)
#v(12pt)
In questo secondo esempio notiamo invece che, nonostante l'informazione persa sia molto meno rispetto a quella precedente, "risalire" al contenuto perso è molto più difficile.
Questi due esempi dimostrano come l'informazione contenuta in un documento *non* è uniforme, e quindi che una distorsione maggiore non implica una perdita maggiore di informazioni.
L'obiettivo del primo teorema di Shannon è eliminare le informazioni inutili e ridondanti, comprimendo il messaggio per poter utilizzare il canale per inviare altre informazioni.
Quello che facciamo è concentrare l'informazione, rendendola *equamente distribuita*, quindi impossibile da ridurre ancora e contenente solo informazioni importanti.
Vediamo un altro esempio: supponiamo di avere due dadi a sei facce, uno _normale_ e uno _truccato_, e supponiamo di tirarli assieme per un numero di volte molto grande. Quale dei due dadi mi dà più informazioni?
#v(12pt)
#figure(
image("assets/2023-10-06_dadi.svg", width: 40%)
)
#v(12pt)
La risposta è quello _normale_: nel lungo il dado _normale_ si "normalizzerà" su una probabilità di circa $1/6$ per ogni possibile faccia, quindi è una sorta di evento *regolare* che mi dà tanta informazione, mentre quello truccato posso sapere già cosa produrrà, quindi è una sorta di evento *prevedibile* che mi dà poca informazione.
In poche parole, massimizzo la probabilità di "ottenere" informazioni se le probabilità di estrarre un simbolo sono uguali.
== Secondo teorema di Shannon
Il secondo teorema di Shannon è quello più rognoso, perché si occupa della _channel coding_, ovvero di una codifica che permetta di minimizzare l'informazione persa durante la trasmissione.
Vogliamo questo perché l'informazione che passa sul canale è compressa, quindi qualsiasi bit perso ci fa perdere molte informazioni, non essendoci ridondanza.
Quello che viene fatto quindi è aggiungere *ridondanza*, ovvero più copie delle informazioni da spedire così che, anche perdendo un bit di informazione, lo si possa recuperare usando una delle copie inviate.
La ridondanza che aggiungiamo però è *controllata*, ovvero in base al livello di distorsione del canale utilizzato si inviano un certo numero di copie.
In un *canale ideale* la ridondanza è pari a 0, mentre per canali con rumore viene usata una matrice stocastica, che rappresenta la distribuzione probabilistica degli errori.
#align(center)[
#table(
align: center + horizon,
columns: (7%, 7%, 7%, 7%, 7%, 7%),
inset: 10pt,
[TODO], [a], [b], [c], [d], [e],
[a], [0.7], [0.0], [0.1], [0.1], [0.1],
[b], [0.2], [0.8], [0.0], [0.0], [0.0],
[c], [0.1], [0.0], [0.6], [0.2], [0.1],
[d], [0.0], [0.0], [0.2], [0.5], [0.3],
[e], [0.0], [0.0], [0.0], [0.0], [1.0]
)
]
Ogni riga $i$ rappresenta una distribuzione di probabilità che definisce la probabilità che, spedito il carattere $i$, si ottenga uno dei valori $j$ presenti nelle colonne.
Se il canale è ideale la matrice risultante è la matrice identità.
#pagebreak()
= Codifica della sorgente
Andiamo a modellare e formalizzare il primo problema con un modello statistico, utilizzando però un approccio _semplice e bello_: assumiamo che le regole di compressione non siano dipendenti dalle proprietà di un dato linguaggio.
Ad esempio, data la lettera "H" nella lingua italiana, ho più probabilità che esca la lettera "I" piuttosto che la lettera "Z" come successiva di "H", ma questa probabilità nel nostro modello non viene considerata.
Il codice _zip_ invece prende in considerazione questo tipo di distribuzione statistica dipendente, e infatti è molto più complicato.
== Introduzione matematica
Introduciamo una serie di "personaggi" che saranno utili nella nostra modellazione:
- insieme $Chi space arrow.long.r.bar.double space$ insieme finito di simboli che compongono i messaggi generati dalla sorgente;
- messaggio $overline(x) space arrow.long.r.bar.double space$ sequenza di $n$ simboli sorgente; in modo formale, $ overline(x) = (x_1, dots, x_n) in Chi^n, text(" con") x_i in Chi space forall i in {1, dots, n}; $
- base $D$;
- insieme ${0, dots, D-1} space arrow.long.r.bar.double space$ insieme finito dei simboli che compongono il codice scelto;
- insieme ${0, dots, D-1}^+ space arrow.long.r.bar.double space$ insieme di tutte le possibili parole di codice esprimibili tramite una sequenza non vuota di simboli di codice; in modo formale $ {0, dots, D-1}^+ = union.big_(n=1)^(infinity) {0, dots, D-1}^n . $ Un altro nome per le parole di codice è sequenze $D$-arie;
- funzione $c space arrow.long.r.bar.double space$ funzione (nel nostro caso _codice_) che mappa ogni simbolo $x in Chi$ in una parola di codice, ovvero una funzione del tipo $ c : Chi arrow.long.r {0, dots, D-1}^+. $ Questa funzione va ad effettuare un *mapping indipendente*, ovvero tutto viene codificato assumendo che non esistano relazioni tra due o più estrazioni consecutive.
== Prima applicazione
Vogliamo trasmettere sul canale i semi delle carte da poker utilizzando il codice binario.
Andiamo a definire:
- $Chi = {suit.heart, suit.diamond, suit.club, suit.spade}$ insieme dei simboli sorgente;
- $c : Chi arrow.long.r {0,1}^+$ funzione di codifica;
- $c(suit.heart) = 0$;
- $c(suit.diamond) = 01$;
- $c(suit.club) = 010$;
- $c(suit.spade) = 10$.
La codifica proposta è sicuramente plausibile, ma ha due punti deboli:
- ambiguità: se ricevo "010" ho come possibili traduzioni $suit.club$, $suit.heart suit.spade$ e $suit.diamond suit.heart$;
- pessima compressione: usiamo tre simboli di codice per codificare $suit.club$ e solo uno per codificare $suit.heart$.
Quest'ultimo punto debole viene risolto prima introducendo $l_c (x)$ come lunghezza della parola di codice associata ad $x in Chi$, e poi minimizzando la media di tutte le lunghezze al variare di $x in Chi$.
== Modello statistico
Per completare il modello abbiamo bisogno di un'altra informazione: la *distribuzione di probabilità* che definisce la probabilità con la quale i simboli sorgente sono emessi.
Definiamo quindi la sorgente come la coppia $angle.l Chi, p angle.r$, dove $p$ rappresenta la probabilità prima descritta.
Aggiungiamo qualche "protagonista" a quelli già prima introdotti:
- funzione $P_n space arrow.long.r.bar.double space$ non siamo molto interessati ai singoli simboli sorgente, ma vogliamo lavorare con i messaggi, quindi definiamo $ P_n (overline(x)) = P_n (x_1, dots, x_n) = product_(i=1)^n p(x_i). $ Possiamo applicare la produttoria perché Shannon assume che ci sia _indipendenza_ tra più estrazioni di simboli sorgente;
- variabile aleatoria $XX space arrow.long.r.bar.double space$ variabile aleatoria $XX : Chi arrow.long.r RR$ che rappresenta un'estrazione di un simbolo sorgente;
- insieme $DD space arrow.long.r.bar.double space$ già definito in precedenza come ${0, dots, D-1}$;
- funzione $c space arrow.long.r.bar.double space$ già definita in precedenza, ma che riscriviamo come $c : Chi arrow.long.r DD^+$.
Con questo modello, fissando $Chi$ insieme dei simboli sorgente e $D$ base, vogliamo trovare un codice $c : Chi arrow.long.r DD^+$ che realizzi la migliore compressione, ovvero che vada a minimizzare il _valore atteso_ della lunghezza delle parole di codice, definito come $EE[l_c] = limits(sum)_(x in XX) l_c (x) p(x)$.
La strategia che viene utilizzata è quella dell'alfabeto Morse: utilizziamo parole di codice corte per i simboli che sono generati spesso dalla sorgente, e parole di codice lunghe per i simboli che sono generatori raramente dalla sorgente.
Il primo problema che incontriamo è quello di evitare la _codifica banale_: se usassi il codice $c(x) = 0$ oppure $c(x) = 1 space forall x in Chi$ avrei sì una codifica di lunghezza minima ma sarebbe impossibile da decodificare.
Dobbiamo imporre che il codice $c$ sia *iniettivo*, o _non-singolare_.
|
|
https://github.com/yamoling/ulb-template-typst | https://raw.githubusercontent.com/yamoling/ulb-template-typst/main/template/template.typ | typst | // The project function defines how your document looks.
// It takes your content and some metadata and formats it.
// Go ahead and customize it to your liking!
#let ULB_BLUE = rgb(0, 50, 154)
#let ULB_LIGHT = rgb(218, 230, 255)
#let ULB_DARK = rgb(0, 25, 101)
#let project(
title: "",
subtitle: "",
authors: (),
lang: "fr",
date: none,
faculty: "",
department: "",
body
) = {
// Set the document's basic properties.
set heading(numbering: "1.1.")
set page(numbering: "1", number-align: center)
set text(font: "Libertinus Serif", lang: lang)
set par(justify: true)
set list(indent: 1em)
set enum(indent: 1em)
set math.equation(numbering: "(1)")
set figure(supplement: "Figure")
set heading(supplement: "Section")
// Page header
set page(
margin: (top: 8em),
header: [
#box([
#image(
width: 35%,
height: 10%,
"template/barrette-original.jpg"
)
])
#h(1fr)
#box(
baseline: 70%,
image(
width: 60%,
"template/logo-ULB-ligne.jpg"
))
#v(-3.3em)
#text(
font: "Fira Sans",
size: 0.8em,
weight: "regular",
text(ULB_DARK)[
#faculty\
#v(-0.9em)
#department
])
],
)
// Code style
show raw: it => {
if not it.text.contains("\n") {
box(
baseline: 2pt,
rect(
fill: rgb("#ececec"),
outset: 0pt,
inset: 2pt,
radius: 2pt,
it
)
)
} else {
block(
width: 100%,
fill: rgb("#f2f2f2"),
inset: 8pt,
radius: 5pt,
align(left, it)
)
}
}
show link: name => underline(text(blue, name))
// Title row.
align(center)[
#block(text(weight: 700, 1.75em, title))
#block(text(weight: 700, 1.5em, subtitle))
#if date != none {
block(text(weight: 600, 1.5em, date))
}
]
// Author information.
let ncols = calc.min(authors.len(), calc.max(4, authors.len()))
pad(
top: 0.5em,
bottom: 0.5em,
grid(
columns: (1fr,) * calc.min(ncols, authors.len()),
gutter: 1em,
..authors.map(author => align(center, strong(author))),
),
)
body
} |
|
https://github.com/leesum1/brilliant-cv | https://raw.githubusercontent.com/leesum1/brilliant-cv/master/modules_zh/professional.typ | typst | // Imports
#import "@preview/brilliant-cv:2.0.2": cvSection, cvEntry, hBar
#import "@preview/fontawesome:0.4.0": *
#let metadata = toml("../metadata.toml")
#let cvSection = cvSection.with(metadata: metadata)
#let cvEntry = cvEntry.with(metadata: metadata)
#cvSection("实习经历")
#cvEntry(
title: link("https://github.com/iEDA-Open-Source-Core-Project/iEDA-data-set")[#fa-icon("github") 开源核心移植成果仓库链接],
society: [北京开源芯片研究院],
logo: image("../src/logos/bosc.png"),
date: [2023.3 - 2023.12],
location: [一生一芯-开源核心移植项目组],
description: list(
[学习开源处理器设计,将其总线修改为 *AXI4* 并接入「yxys-SOC」仿真环境;为其移植 BenchMark、RT-Thread 等测试程序],
[完成了 DarkRiscv、Ibex、蜂鸟E203、CVA6 等开源核心的移植与测试工作;掌握了各种*系统软件的移植*方式,能够理解并修改开源核心的 RTL 代码,以适应不同的 SOC环境,*熟练使用Verilog 或 Chisel
语言*,能够*独立完成 RTL 设计与仿真工作。*],
),
)
// #cvEntry(
// title: [一生一芯-助教],
// society: [北京开源芯片研究院],
// logo: image("../src/logos/bosc.png"),
// date: [2023.11 - now],
// location: [线上实习],
// description: list([担任 “一生一芯” 项目助教,负责 “一生一芯” 学员的日常答疑,组织组会,学员认证考核等工作。]),
// )
|
|
https://github.com/typst/packages | https://raw.githubusercontent.com/typst/packages/main/packages/preview/touying/0.4.0/utils/states.typ | typst | Apache License 2.0 | // touying slide counters
#let slide-counter = counter("touying-slide-counter")
#let last-slide-counter = counter("touying-last-slide-counter")
#let last-slide-number = locate(loc => last-slide-counter.final(loc).first())
#let touying-progress(callback) = locate(loc => {
if last-slide-counter.final(loc).first() == 0 {
callback(1.0)
return
}
let ratio = calc.min(1.0, slide-counter.at(loc).first() / last-slide-counter.final(loc).first())
callback(ratio)
})
// sections
#let sections-state = state("touying-sections-state", ((kind: "section", title: none, short-title: none, loc: none, count: 0, children: ()),))
#let _new-section(short-title: auto, duplicate: false, title) = locate(loc => {
sections-state.update(sections => {
if duplicate or sections.last().title != title or sections.last().short-title != short-title {
sections.push((kind: "section", title: title, short-title: short-title, loc: loc, count: 0, children: ()))
}
sections
})
})
#let _new-subsection(short-title: auto, duplicate: false, title) = locate(loc => {
sections-state.update(sections => {
let last-section = sections.pop()
let last-subsection = (kind: "none")
let i = -1
while last-subsection.kind != "subsection" {
last-subsection = last-section.children.at(i, default: (kind: "subsection", title: none, short-title: none, loc: none, count: 0, children: ()))
i += 1
}
if duplicate or last-subsection.title != title or last-subsection.short-title != short-title {
last-section.children.push((kind: "subsection", title: title, short-title: short-title, loc: loc, count: 0, children: ()))
}
sections.push(last-section)
sections
})
})
#let _sections-step(repetitions) = locate(loc => {
sections-state.update(sections => {
let last-section = sections.pop()
if last-section.children.len() == 0 or last-section.children.last().kind == "slide" {
last-section.children.push((kind: "slide", loc: loc, count: repetitions))
last-section.count += 1
sections.push(last-section)
} else {
// update for subsection
let last-subsection = last-section.children.pop()
last-subsection.children.push((kind: "slide", loc: loc, count: repetitions))
last-subsection.count += 1
last-section.count += 1
last-section.children.push(last-subsection)
sections.push(last-section)
}
sections
}
)})
#let touying-final-sections(callback) = locate(loc => {
callback(sections-state.final(loc))
})
#let touying-outline(self: none, enum-args: (:), padding: 0pt) = touying-final-sections(sections => {
let enum-args = (full: true) + enum-args
if self != none and self.numbering != none {
enum-args = (numbering: self.numbering) + enum-args
}
pad(padding, enum(
..enum-args,
..sections.filter(section => section.loc != none)
.map(section => [#link(section.loc, section.title)<touying-link>] + if section.children.filter(it => it.kind != "slide").len() > 0 {
let subsections = section.children.filter(it => it.kind != "slide")
enum(
..enum-args,
..subsections.map(subsection => [#link(subsection.loc, subsection.title)<touying-link>])
)
})
))
})
#let current-section-title = locate(loc => {
let sections = sections-state.at(loc)
sections.last().title
})
#let _typst-numbering = numbering
#let current-section-number(numbering: "01", ignore-zero: true) = locate(loc => {
let sections = sections-state.at(loc)
if not ignore-zero or sections.len() - 1 != 0 {
_typst-numbering(numbering, sections.len() - 1)
}
})
#let current-section-with-numbering(self, ignore-zero: true) = locate(loc => {
let sections = sections-state.at(loc)
if self.numbering != none and (not ignore-zero or sections.len() - 1 != 0) {
_typst-numbering(self.numbering, sections.len() - 1)
[ ]
}
sections.last().title
})
#let current-subsection-number(numbering: "1.1", ignore-zero: true) = locate(loc => {
let sections = sections-state.at(loc)
let subsections = sections.last().children
if (not ignore-zero or sections.len() - 1 != 0) and (not ignore-zero or subsections.len() - 1 != 0) {
_typst-numbering(numbering, sections.len() - 1, subsections.len() - 1)
}
})
#let current-subsection-with-numbering(self, ignore-zero: true) = locate(loc => {
let sections = sections-state.at(loc)
let subsections = sections.last().children
if self.numbering != none and (not ignore-zero or sections.len() - 1 != 0) and (not ignore-zero or subsections.len() - 1 != 0) {
_typst-numbering(self.numbering, sections.len() - 1, subsections.len() - 1)
[ ]
}
subsections.last().title
})
#let touying-progress-with-sections(callback) = locate(loc => {
callback((
current-sections: sections-state.at(loc),
final-sections: sections-state.final(loc),
current-slide-number: slide-counter.at(loc).first(),
last-slide-number: last-slide-counter.final(loc).first(),
))
}) |
https://github.com/Myriad-Dreamin/typst.ts | https://raw.githubusercontent.com/Myriad-Dreamin/typst.ts/main/fuzzers/corpora/text/quotes_02.typ | typst | Apache License 2.0 |
#import "/contrib/templates/std-tests/preset.typ": *
#show: test-page
// Test sentences with numbers and apostrophes.
The 5'11" 'quick' brown fox jumps over the "lazy" dog's ear.
He said "I'm a big fella."
|
https://github.com/RBAS-Workshop/RBAS_Docs | https://raw.githubusercontent.com/RBAS-Workshop/RBAS_Docs/main/book.typ | typst |
#import "@preview/book:0.2.3": *
#show: book
#book-meta(
title: "typst-book",
summary: [
#prefix-chapter("sample-page.typ")[Hello, typst]
]
)
// re-export page template
#import "/templates/page.typ": project
#let book-page = project
|
|
https://github.com/k0tran/typst | https://raw.githubusercontent.com/k0tran/typst/sisyphus/vendor/svg2pdf/README.md | markdown | # svg2pdf
[](https://github.com/typst/svg2pdf/actions)
[](https://crates.io/crates/svg2pdf)
[](https://docs.rs/svg2pdf/)
Convert SVG files to PDFs.
This crate allows to convert static (i.e. non-interactive) SVG files to
either standalone PDF files or Form XObjects that can be embedded in another
PDF file and used just like images.
Apart from groups with filters on them, the conversion will translate
the SVG content to PDF without rasterizing it, so no quality is lost.
## Example
This example reads an SVG file and writes the corresponding PDF back to the disk.
```rust
let path = "tests/svg/custom/integration/matplotlib/time_series.svg";
let svg = std::fs::read_to_string(path)?;
// This can only fail if the SVG is malformed. This one is not.
let pdf = svg2pdf::convert_str(&svg, svg2pdf::Options::default())?;
// ... and now you have a Vec<u8> which you could write to a file or
// transmit over the network!
std::fs::write("target/time_series.pdf", pdf)?;
```
## CLI
This crate also contains a command line interface. Install it by running the
command below:
```bash
cargo install svg2pdf-cli
```
You can then convert SVGs to PDFs by running commands like these:
```bash
svg2pdf your.svg
```
## Supported features
In general, a large part of the SVG specification is supported, including
features like:
- Path drawing with fills and strokes
- Gradients
- Patterns
- Clip paths
- Masks
- Filters
- Transformation matrices
- Respecting the `keepAspectRatio` attribute
- Raster images and nested SVGs
## Unsupported features
Among the unsupported features are currently:
- The `spreadMethod` attribute of gradients
- Text will be converted into shapes before converting to PDF. It is planned
to add support for text preservation in a future update.
- Raster images are not color managed but use PDF's DeviceRGB color space
- A number of features that were added in SVG2
(see [here](https://github.com/RazrFalcon/resvg/blob/master/docs/svg2-changelog.md))
## Contributing
We are looking forward to receiving your bugs and feature requests in the Issues
tab. We would also be very happy to accept PRs for bug fixes, features, or
refactorings! We'd be happy to assist you
with your PR's, so feel free to post Work in Progress PRs if marked as such.
Please be kind to the maintainers and other contributors. If you feel that there
are any problems, please feel free to reach out to us privately.
Thanks to each and every prospective contributor for the effort you (plan to)
invest in this project and for adopting it!
## License
`svg2pdf` is licensed under a MIT / Apache 2.0 dual license.
Users and consumers of the library may choose which of those licenses they want
to apply whereas contributors have to accept that their code is in compliance
and distributed under the terms of both of these licenses.
|
|
https://github.com/IdoWinter/UnitedDumplingsLegislatureArchive | https://raw.githubusercontent.com/IdoWinter/UnitedDumplingsLegislatureArchive/main/legislature/templates.typ | typst | MIT License | #let numbering_from_second = (..numbers) => {
let level = numbers.pos().len()
if (level == 1) {
return
} else {
return numbering("1.1", ..numbers.pos().slice(1, level))
}
}
#let constitutional_amendement_en(title, preamble: [], doc) = {
set heading(numbering: numbering_from_second)
set heading(supplement: "Section")
heading(level: 1)[
#set text(size: 18pt)
Constitional Amendement: #title
]
heading(level: 3, numbering: none)[
#set text(size: 14pt)
Preamble
]
preamble
show heading.where(level: 3): (it) => {
parbreak()
counter(heading).display()
}
counter(heading).update(1)
doc
}
#let constitutional_amendement_he(title, preamble: []) = {
heading(level: 1)[
Amendement Constitutionnel: #title
]
heading(level: 2)[
"הקדמה"
]
preamble
counter(heading).update(1)
doc
}
#let show_hebrew = false
#let eng_heb(eng: [], heb: []) = {
if show_hebrew {
heb
} else {
eng
}
}
#let show_hebrew(heb: true, doc) = {
if heb {
doc.hebrew
} else {
doc.english
}
} |
https://github.com/danfunc/UseTYPST.cmake | https://raw.githubusercontent.com/danfunc/UseTYPST.cmake/main/README.md | markdown | # What is UseTYPST.cmake?
UseTYPST.cmake is cmake extension to use typst like UseLATEX.cmake.
# How to use?
You should include UseTYPST.cmake!!!
You can make pdf document from typst files with only one command like add_executable(). You use add_typst_document(${DOCUMENT_NAME} ${ROOT_typst_file}) to make it. If you want to add extra typst file, you can use typst_document_sources(${DOCUMENT_NAME} ${ADDITIONAL_FILES} ...) to make a document to detect changed ADDITIONAL_FILES then build.
./CMakeLists.txt, ./example.typ, ./subdir/CMakeLists.txt, and ./subdir/subdir_example.typ is to make example document. Read them!
Enjoy typst with cmake!
|
|
https://github.com/takotori/PhAI-Spick | https://raw.githubusercontent.com/takotori/PhAI-Spick/main/ost-summary-template.typ | typst | #let conf(lecture: "", authors: "", doc) = {
let line_skip = 0.4em
let font_size = 7.5pt
let level1_color = "#8c195f";
let level2_color = "#a12b66";
let level3_color = "#b63d6d";
let level4_color = "#cb4f74";
let level5_color = "#C63B65";
show: set block(below: line_skip)
show: set par(leading: line_skip, justify: true)
set page(
paper: "a4",
flipped: true,
margin: ("top": 8mm, "rest": 5mm),
header-ascent: 1.5mm,
header: align(center, text(
1.1em,
weight: "bold",
[#lecture / #authors / #counter(page).display()],
)),
)
set text(size: font_size, font: "Noto Sans")
set terms(hanging-indent: 0mm)
show outline.entry.where(level: 1): set text(weight: "bold")
show heading: set text(white, size: font_size)
show heading: set block(
radius: 0.65mm,
inset: 0.65mm,
width: 100%,
above: line_skip,
below: line_skip,
)
show heading.where(level: 1): set block(fill: rgb(level1_color))
show heading.where(level: 2): set block(fill: rgb(level2_color))
show heading.where(level: 3): set block(fill: rgb(level3_color))
show heading.where(level: 4): set block(fill: rgb(level4_color))
show heading.where(level: 5): set block(fill: rgb(level5_color))
set heading(numbering: "1.1")
columns(4, gutter: 2mm, doc)
}
|
|
https://github.com/felsenhower/kbs-typst | https://raw.githubusercontent.com/felsenhower/kbs-typst/master/examples/lorem2.typ | typst | MIT License | #let lorem2(words) = {
let lorem_ipsum = "Lorem ipsum [...]"
let arr = lorem_ipsum.split(" ")
let n = calc.ceil(words / arr.len())
arr = n * arr
arr = arr.slice(0, words)
let text = arr.join(" ")
if text.ends-with(",") {
text = text.slice(0, -1)
}
if not text.ends-with(".") {
text = text + "."
}
text
}
|
https://github.com/dead-summer/math-notes | https://raw.githubusercontent.com/dead-summer/math-notes/main/notes/ScientificComputing/ch1-intro-to-scicomp/modelling-discretization-and-implementation.typ | typst | #import "/book.typ": book-page
#import "../../../templates/conf.typ": *
#show: thmrules.with(qed-symbol: $square$)
#show: book-page.with(title: "Modelling, Discretization and Implementation")
= 1 Modelling, Discretization and Implementation
Scientific problems are often raised (or proposed) as mathematical models, which are typically described by differential equations, either or dinary differential equations or partial differential equations. After discretization by appropriate numerical algorithms, mathematical equations are further solved by computer programs.
The steps, modelling with mathematics, discretization by algorithms and implementation for computers, form the major components of scientific computing.
Each step may introduce errors, which are respectively called modelling errors, discretization errors and implementation errors. In this course, we are mainly focused on discretization errors by numerical algorithms or methods while pay attention to implementation errors.
#exm[
Spring
]
#exm[
Pendulum
]
#exm[
Motion of a planet around the sun
]
#exm[
Two point boundary value problem
]
|
|
https://github.com/TechnoElf/mqt-qcec-diff-thesis | https://raw.githubusercontent.com/TechnoElf/mqt-qcec-diff-thesis/main/content/background/quantum.typ | typst | #import "@preview/cetz:0.2.2": canvas, draw
#import "@preview/gentle-clues:0.9.0": example
#import "@preview/quill:0.3.0": quantum-circuit, lstick, rstick, ctrl, targ, mqgate, meter
#import "@preview/tablex:0.0.8": tablex
== Quantum Computation and Quantum Circuits
A quantum computer is a device that performs calculations by using certain phenomena of quantum mechanics @nielsen2010quantum.
The algorithms that run on this device are specified in quantum circuits.
Quantum circuits consist of quantum gates that operate sequentially on a set of qubits.
Quantum circuits, quantum gates and qubits function analogous to their classical counterparts in electronics.
Unlike classical gates and bits, however, quantum gates and qubits have the ability to operate on quantum states.
Whereas classical computers operate on the binary states '0' and '1', quantum computers operate on linear combinations of these states by exploiting a phenomenon from quantum mechanics known as superposition.
It is this simultaneity of classical states in quantum computers that can give them an edge over classical computers for certain problems.
#figure(
canvas({
import draw: *
scale(1)
circle((0, 0, 0), radius: 2)
group({rotate(x: 90deg); circle((0, 0, 0), radius: 2)})
group({rotate(y: 90deg); circle((0, 0, 0), radius: 2)})
circle((0, 0, 0), radius: 0.1, fill: black)
line((0, 0, 0), (0, 0, -1.5), mark: (end: ">"), name: "x")
line((0, 0, 0), (1.5, 0, 0), mark: (end: ">"), name: "y")
line((0, 0, 0), (0, 1.5, 0), mark: (end: ">"), name: "z")
content("x.end", anchor: "north", [x])
content("y.end", anchor: "west", [y])
content("z.end", anchor: "south", [z])
content((0, 2.5, 0), [|0〉])
content((0, -2.5, 0), [|1〉])
}),
caption: [A Bloch sphere.]
) <example_bloch>
Qubits are usually represented in one of three forms shown in @example_vec and @example_bloch.
The Bloch sphere is a good visualisation for the superposition that can occur in a single qubit.
Besides the two basis states (usually called |0〉 and |1〉) it is possible for the qubit to have any value on the surface of the sphere.
These quantum states can be mapped to classical states by projecting them onto the z axis.
This corresponds to a probability of either state being observed in a real quantum system.
The coefficients $alpha$ and $beta$ thus also correspond to the probability of either basis state being measured when the state is observed.
#figure(
[$alpha|0〉 + beta|1〉$ #h(2em) $vec(alpha, beta)$],
caption: [A qubit in algebraic and vector notation.]
) <example_vec>
The Bloch sphere is, however, not suitable for demonstrating entanglement; another phenomenon from quantum mechanics that is essential to quantum computation.
Abstractly, entanglement refers to the ability of single qubit states to depend on the state of other qubits.
To show entanglement of qubits, it is necessary to fall back on the algebraic or vector notation.
@example_vec2 shows two-qubit system in these forms.
#figure(
[$alpha_00|00〉 + alpha_01|01〉 + alpha_10|10〉 + alpha_11|11〉$ #h(2em) $vec(alpha_00, alpha_01, alpha_10, alpha_11)$],
caption: [Two qubits in algebraic and vector notation.]
) <example_vec2>
Instead of two basis states, there are now four representing each permutation of possible classical states of the two qubits.
An example for an entangled state in this system would be $frac(1, sqrt(2))|00〉 + 0|01〉 + 0|10〉 + frac(1, sqrt(2))|11〉$.
If the first qubit where to be measured in this system, we would also know the classical state of the second qubit; A measured '0' would imply a '0' for the other qubit as the probabilities for all other states are $0$.
Additionally, there are a few important restrictions on quantum states and quantum operations that stem from quantum mechanics.
Unlike classical electronic circuits, from which this analogy is derived, quantum circuits must have the same number of inputs as outputs.
They may also not contain loops.
These restrictions are summarised in the reversibility constraint @nielsen2010quantum.
Besides being reversible, quantum gates must also be unitary.
Quantum states must also be normalised, a condition which is satisfied by the requirement for unitary operations.
#example(breakable: true)[
@example_qc_dj shows a simple quantum circuit that implements a specific quantum algorithm.
The Deutsch, or, more generally, the Deutsch-Jozsa algorithm, solves the problem of determining whether a function is constant or balanced @deutsch1992quantum.
A constant function produces the same output for all inputs, whereas a balanced function produces a '0' for half of all possible inputs and a '1' for the other.
The Deutsch algorithm does this for any boolean function with a single bit input and the Deutsch-Jozsa algorithm generalises this to any number of bits.
While there are currently no known applications for this algorithm, it serves as a good example for the capability of quantum computation to outperform classical computation.
#figure(
quantum-circuit(
lstick($|0〉$), $H$, mqgate($U$, n: 2, width: 5em, inputs: ((qubit: 0, label: $x$), (qubit: 1, label: $y$)), outputs: ((qubit: 0, label: $x$), (qubit: 1, label: $y plus.circle f(x)$))), $H$, meter(), [\ ],
lstick($|1〉$), $H$, 1, 1, 1
),
caption: [A quantum circuit implementing the Deutsch-Jozsa algorithm]
) <example_qc_dj>
The input may be represented as a state vector $S_1$ corresponding to the state $0|00〉 + 1|01〉 + 0|10〉 + 0|11〉$.
The leftmost Hadamard gates may in turn be represented as the unitary matrix $U_1$.
$ S_1 = vec(0, 1, 0, 0) #h(1cm) U_1 = frac(1, sqrt(2)) mat(1, 1; 1, -1) times.circle frac(1, sqrt(2)) mat(1, 1; 1, -1) = frac(1, 2) mat(1, 1, 1, 1; 1, -1, 1, -1; 1, 1, -1, -1; 1, -1, -1, 1) $
Multiplying these yields the state vector $S_2$. The oracle $U$ has the unitary matrix $U_U$.
$ S_2 = frac(1, 2) vec(1, -1, 1, -1) #h(1cm) U_U = mat(overline(f(0)), f(0), 0, 0; f(0), overline(f(0)), 0, 0; 0, 0, overline(f(1)), f(1); 0, 0, f(1), overline(f(1))) $
Applying this again to the preceding state vector results in the new state vector $S_3$.
The rightmost Hadamard gate is described by the matrix $U_2$.
$ S_3 = frac(1, 2) vec(overline(f(0)) - f(0), f(0) - overline(f(0)), overline(f(1)) - f(1), f(1) - overline(f(1))) #h(1cm) U_2 = frac(1, sqrt(2)) mat(1, 1; 1, -1) times.circle mat(1, 0; 0, 1) = frac(1, sqrt(2)) mat(1, 0, 1, 0; 0, 1, 0, 1; 1, 0, -1, 0; 0, 1, 0, -1) $
This results in the final state vector $S_4$.
$ S_4 = frac(1, 2 sqrt(2)) vec(overline(f(0)) - f(0) + overline(f(1)) - f(1), f(0) - overline(f(0)) + f(1) - overline(f(1)), overline(f(0)) - f(0) - overline(f(1)) + f(1), f(0) - overline(f(0)) - f(1) + overline(f(1))) $
This vector cannot be split into the individual qubits, so the following table shows all possible output states for each realisation of $f$.
#tablex(
columns: (1fr, 1fr, 6fr, 2fr),
[*f(0)*], [*f(1)*], [*Output State*], [*Measurement*],
[$0$], [$0$], [$frac(1, sqrt(2))|00〉 - frac(1, sqrt(2))|01〉 + 0|10〉 + 0|11〉$], [$0$],
[$0$], [$1$], [$0|00〉 + 1|01〉 + frac(1, sqrt(2))|10〉 - frac(1, sqrt(2))|11〉$], [$1$],
[$1$], [$0$], [$0|00〉 + 1|01〉 - frac(1, sqrt(2))|10〉 + frac(1, sqrt(2))|11〉$], [$1$],
[$1$], [$1$], [$-frac(1, sqrt(2))|00〉 + frac(1, sqrt(2))|01〉 + 0|10〉 + 0|11〉$], [$0$]
)
Observing the possible measurements, it is clear that this circuit does indeed satisfy the problem statement given by Deutsch.
When the function is balanced (produces the same number of '0' outputs as '1' outputs), the measurement is '1', whereas a constant function (the output is always '0' or '1') is measured as '0'.
Initially, this example may seem counter intuitive.
Computing the output of the quantum circuit necessitated the computation of all possible outputs of $f$ in addition to multiple matrix / vector multiplications and processing of state vectors.
It would therefore appear that the quantum implementation of this algorithm is less efficient than the classical solution.
This observation, however, disregards the fact that the above calculation solved the problem for all possible $f$.
Additionally, an implementation of this algorithm on real quantum hardware would only have to evaluate the gate $U$ and thus the function $f$ once.
This highlights the inefficiency of simulating quantum circuits on classical hardware, a problem that grows exponentially with the number of qubits.
Another conclusion that can be drawn from this is that it is therefore ineffective to verify the functionality of quantum circuits through plain simulation.
More effective methods will be discussed in this thesis.
]
|
|
https://github.com/lucifer1004/typst-poetry | https://raw.githubusercontent.com/lucifer1004/typst-poetry/main/example.typ | typst | #import "poetry.typ": *
#poem(
title: "The Road Not Taken",
author: "<NAME>",
date: "Aug 1915",
update: "Jan 1916",
)[
Two roads diverged in a yellow wood,\
And sorry I could not travel both\
And be one traveler, long I stood\
And looked down one as far as I could\
To where it bent in the undergrowth;
Then took the other, as just as fair,\
And having perhaps the better claim,\
Because it was grassy and wanted wear;\
Though as for that the passing there\
Had worn them really about the same,
And both that morning equally lay\
In leaves no step had trodden black.\
Oh, I kept the first for another day!\
Yet knowing how way leads on to way,\
I doubted if I should ever come back.
I shall be telling this with a sigh\
Somewhere ages and ages hence:\
Two roads diverged in a wood, and I—\
I took the one less traveled by,\
And that has made all the difference.
][
Another section
][
// Empty section
][
= Section with title
Another section with title
]
|
|
https://github.com/rabotaem-incorporated/algebra-conspect-1course | https://raw.githubusercontent.com/rabotaem-incorporated/algebra-conspect-1course/master/sections/03-polynomials/08-taylor-series.typ | typst | Other | #import "../../utils/core.typ": *
== Формула Тейлора
#pr[
$K$ --- поле, $f, g in K[x], space f eq.not 0, space d = deg(g) >= 1$.
Тогда $f$ можно представить единственным образом в виде:
$
f = h_n g^n + ... + h_1g + h_0,
$
где $n >= 0, space h_i in K[x], space h_n eq.not 0, space deg(h_i) < d, space forall i = 0, ..., n$.
]
#proof[
"Существование":
Индукция по $l = deg f$.
"База": При $l < d$ подходит $n = 0, space h_0 = f$.
"Переход": При $l >= d: space f = g q + r, space deg(r) < d, space q eq.not 0$.
$deg g q >= deg g > deg r$
$==> deg f = deg g q ==> deg q = l - d$
По ИП: $q = h_n g^n + ... + h_1 g + h_0, space h_n eq.not 0, space deg(h_i) < d, space i = 0, ..., n$.
$==> f = h_n g^(n + 1) + ... + h_0 g + r$.
"Единственность":
Индукция по $l = deg f$.
При $l < d$:
$deg h_n g^n >= n d > deg h_i g^i, space i = 0, ..., n - 1 ==> deg f = deg h_n g^n ==> deg h_n g^n < d$.
$n d + d - 1 >= l >= n d ==> n$ --- неполное частное при делении $l$ на $d$.
"База": При $l < d: space n = 0 ==> h_0 = f$.
"Переход": При $l >= d$ предположим, что есть еще разложение $f = hat(h_n) g^n + ... + hat(h_1) g + hat(h_0)$.
$f = g(h_n g^(n - 1) + ... + h_1) + h_0 = g(hat(h_n) g^(n - 1) + ... + hat(h_1)) + hat(h_0), quad deg h_0, space deg hat(h_0) < d$
Тогда $h_0 = hat(h_0)$. По единственности деления с остатком.
По ИП: $deg f_1 = h_n g^(n - 1) + ... + h_1 < deg f ==> h_i = hat(h_i), space i = 1, ..., n - 1$.
]
#pr[
$char K = 0, space f in K[x], space f eq.not 0, space d = deg(f) = n >= 0, space a in K$.
$==> f = limits(sum)_(i = 0)^n (f^((i))(x - a)^i)/(i!), space f^((i)) in K[x], space deg(f^((i))) < d, space i = 0, ..., n$.
]
#proof[
$f = limits(sum)_(i = 0)^n c_i(x - a)^i, space c_i in K, space i = 0, ..., n, space c_n eq.not 0$.
$f^((i)) = limits(sum)_(j = i)^(n) c_(j) j! (x - a)^(j - i),quad i = 0, ..., n$.
$f^((j))(a) = c_j j! ==> c_i = (f^((i))(a))/(i!)$.
] |
https://github.com/0xPARC/0xparc-intro-book | https://raw.githubusercontent.com/0xPARC/0xparc-intro-book/main/old-stuff/old-intro.typ | typst | #import "preamble.typ":*
= Introduction
== What is programmable cryptography?
Cryptography is everywhere now
as a field that is widely used in everyday life.
To be concrete, let's consider two examples of what protocols designed by
classical cryptography can achieve:
- _Proofs_. An example of this is digital signature algorithms like RSA,
where Alice can do some protocol to prove to Bob that a message was sent by her.
A more complicated example might be a
#link("https://w.wiki/9fXW", "group signature scheme"),
allowing one member of a group to sign a message on behalf of a group.
- _Hiding inputs_: for example, consider
#link("https://w.wiki/9fXQ", "Yao's millionaire problem"),
where Alice and Bob wants to know which of them has more money
without learning the actual incomes.
Classically, first-generation cryptography relied on coming up for a protocol
for solving given problems or computing certain functions.
"Programmable cryptography" is a term coined by 0xPARC for a second generation
of cryptographic primitives that have arisen in the last 15 or so years.
The goal of the second-generation "programmable cryptography" can
then be described as:
#quote[
We want to devise cryptographic primitives that could
be programmed to work on *arbitrary* problems and functions,
rather than designing protocols on a per-problem or per-function basis.
]
To draw an analogy, it's sort of like going from older single-purpose hardware,
like a digital alarm clock or thermostat,
to having a general-purpose device, like a smartphone, which can
do any computation so long as someone writes code for it.
The quote on the title page
("I have a message $M$ such that $op("sha")(M) = "0x91af3ac..."$")
is a concrete example;
the hash function SHA is a particular set of arbitrary instructions,
yet programmable cryptography promises that such a proof can be made
using a general compiler rather than inventing an algorithm specific to SHA256.
#todo[Brian's image of an alarm clock and a computer chip]
== Ideas in programmable cryptography
These notes focus on the following specific topics.
=== The zkSNARK: proofs of general problems
The *zkSNARK*, first described in 2012, was the first type of primitive
that arguably falls into the "programmable cryptography" umbrella.
It provides a way to produce proofs of _arbitrary_ problem statements,
at least once encoded as a system of equations in a certain way.
The name stands for:
- *Zero-knowledge*: a person reading the proof doesn't learn anything
about the solution besides that it's correct.
- *Succinct*: the proof length is short (actually constant length).
- *Non-interactive*: the protocol is not interactive.
- *Argument*: technically not a "proof," but we won't worry about the difference.
- *of Knowledge*: the proof doesn't just show the system of equations has a solution;
it also shows that the prover knows one.
So, you can think of these as generalizing something like a group signature
scheme to authenticating any sort of transaction:
- A normal signature scheme is a (zero-knowledge, succinct, non-interactive)
proof that "I know Alice's private key".
- A group signature scheme can be construed as a succinct proof that
"I know one of Alice, Bob, or Charlie's private keys".
- But you could also use a zkSNARK to prove a statement like
"I know a message $M$ such that $sha(M) = "0x91af3ac..."$",
of course without revealing $M$ or anything about $M$.
- ... Or really any arbitrarily complicated statement.
#todo[gubsheep's slide had a funny example with emoji, link it]
These notes focus on two constructions, PLONK (@plonk) and Groth16 (@groth16).
=== Multi-party computation (MPC)
A *multi-party computation*, in which $n >= 2$ people want to
jointly compute some known function
$ F(x_1, ..., x_n) $
where the $i$th person only knows the input $x_i$
and does not learn the other inputs.
For example, we saw earlier Yao's millionaire problem --- Alice and Bob
want to know who has a higher income without revealing the incomes themselves.
This is the case where $n=2$, $F = max$, and $x_i$ is the $i$'th person's income.
Multi-party computation makes a promise that we'll be able to do this
for _any_ function $F$ as long as we implement it in code.
=== Fully homomorphic encryption (FHE)
In *fully homomorphic encryption*, one person encrypts some data $x$,
and then anybody can perform arbitrary operations on the encrypted data $x$
without being able to read $x$.
For example, imagine you have some private text that you want to
translate into another language.
You encrypt the text and feed it to your favorite FHE machine translation server.
You decrypt the server's output and get the translation.
The server only ever sees encrypted text,
so the server learns nothing about the text you translated.
== Where these fit together
ZkSNARKS, MPC, and FHE are just some of a huge zoo of cryptographic primitives,
from the elementary (public-key cryptography)
to the impossibly powerful (indistinguishability obfuscation).
There are protocols for zkSNARKS, MPC and FHE;
they are very slow, but they can be implemented and used in practice.
This whole field is an active area of research.
On the one hand: Can we make existing tools (zkSNARKS, etc.) more efficient?
For example, the cost of doing a computation in zero knowledge
is currently about $10^6$ times the cost of doing the computation directly.
Can we bring that number down?
On the other hand: What other cryptographic games can we play
to develop new sorts of programmable cryptography functionality?
At 0xPARC, we see this as a door to a new world.
What sort of systems can we build on top of programmable cryptography?
#todo[Import Brian's tree. Talk about reduction? Evan, take a look at the flavor text, idk if I like it - Aard]
== What's all the fuss about zero-knowledge anyhow?
#figure(
image("../figures/care-about.png", width:90%),
caption: [Expectations vs. reality.]
)
#todo[Aard suggests deleting the figure, it's cute but Aard isn't sure about the message]
When we think about how to use programmable cryptography we need to be creative.
As an example, what can you do with a zkSNARK?
One answer: You can prove that you have a solution to a system of equations.
Sounds pretty boring, unless you're an algebra student.
Slightly better answer: You can prove that you have executed a program correctly,
revealing some or all of the inputs and outputs, as you please.
For example: You know a messame $M$ such that
$op("sha")(M) = "0xa91af3ac..."$, but you don't want to reveal $M$.
Or: You only want to reveal the first 30 bytes of $M$.
Or: You know a message $M$, and a digital signature proving that $M$ was signed by
[trusted authority], such that a certain neural network, run on the input $M$, outputs "Good."
One recent application along these lines is
#link("https://tlsnotary.org", "TLSNotary").
TLSNotary lets you certify a transcript of communications with a server
in a privacy-preserving way: you only reveal the parts you want to.
|
|
https://github.com/LDemetrios/Typst4k | https://raw.githubusercontent.com/LDemetrios/Typst4k/master/src/test/resources/suite/math/root.typ | typst | // Test roots.
--- math-root-basic ---
// Test root with more than one character.
$A = sqrt(x + y) = c$
--- math-root-radical-attachment ---
// Test root size with radicals containing attachments.
$ sqrt(a) quad
sqrt(f) quad
sqrt(q) quad
sqrt(a^2) \
sqrt(n_0) quad
sqrt(b^()) quad
sqrt(b^2) quad
sqrt(q_1^2) $
--- math-root-precomposed ---
// Test precomposed vs constructed roots.
// 3 and 4 are precomposed.
$sqrt(x)$
$root(2, x)$
$root(3, x)$
$root(4, x)$
$root(5, x)$
--- math-root-large-body ---
// Test large bodies
$ sqrt([|x|]^2 + [|y|]^2) < [|z|] $
$ v = sqrt((1/2) / (4/5))
= root(3, (1/2/3) / (4/5/6))
= root(4, ((1/2) / (3/4)) / ((1/2) / (3/4))) $
$ v = sqrt(a +\ b) $
--- math-root-large-index ---
// Test large index.
$ root(2, x) quad
root(3/(2/1), x) quad
root(1/11, x) quad
root(1/2/3, 1) $
--- math-root-syntax ---
// Test shorthand.
$ √2^3 = sqrt(2^3) $
$ √(x+y) quad ∛x quad ∜x $
$ (√2+3) = (sqrt(2)+3) $
|
|
https://github.com/TypstApp-team/typst | https://raw.githubusercontent.com/TypstApp-team/typst/master/tests/typ/bugs/flow-2.typ | typst | Apache License 2.0 | // In this bug, the first part of the paragraph moved down to the second page
// because trailing leading wasn't trimmed, resulting in an overlarge frame.
---
#set page(height: 60pt)
#v(19pt)
#block[
But, soft! what light through yonder window breaks?
It is the east, and Juliet is the sun.
]
|
https://github.com/isaacholt100/isaacholt | https://raw.githubusercontent.com/isaacholt100/isaacholt/main/src/app/maths/info.md | markdown | MIT License | These are summary notes I wrote for some of my university mathematics modules. The notes were made with [Typst](https://typst.app/docs/). The template used is available [here](https://github.com/isaacholt100/isaacholt/blob/main/public/maths-notes/template.typ). If you notice a mistake in any of these notes, feel free to create an issue or submit a pull request on this website's [GitHub repository](https://github.com/isaacholt100/isaacholt).
With the exception of the Durham: Year 2 notes, you can choose which kinds of items (theorems, lemmas, definitions, proofs, etc.) are shown in the compiled document, by adding the relevant items to the `hidden` argument of the template, e.g. to hide proofs and remarks:
```rust
#show: doc => template(doc, hidden: ("proof", "remark"))
```
This can be useful e.g. if you simply want to memorise just the definitions or just the results. |
https://github.com/polarkac/MTG-Stories | https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/049%20-%20The%20Brothers'%20War/005_Episode%204%3A%20The%20Ink%20of%20Empires.typ | typst | #import "@local/mtgstory:0.2.0": conf
#show: doc => conf(
"Episode 4: The Ink of Empires",
set_name: "The Brothers' War",
story_date: datetime(day: 24, month: 10, year: 2022),
author: "<NAME>",
doc
)
#strong[44 AR]
Ten miles from the golden domes of Tomakul, Farid sat on the fire step of an old trench and used his knife to chip apart his frozen stew. Stoked with shattered arrow shafts and small wads of packing paper, the coals under the stewpot—his own brass cap, its liner removed—soon had the frozen slurry thawed and simmering. Without reverence, Farid shook the last of his salt out of a small tin into the broth, stirred, and felt his stomach twist with hunger at the thin scent of wild garlic and onions. The smell drew the rats out of their holes as well, but the cold made them sluggish. Farid watched one creep toward his rag-wrapped boots and stop to sniff him. It was fat, large as the golden cats that lounged in Tomakul's temple district streets, and carried itself with the same languid, waddling confidence. The rats owned the trench; the humans huddling in it were just temporary occupants, and food if they died. Farid kicked it away.
#figure(image("005_Episode 4: The Ink of Empires/01.jpg", width: 100%), caption: [Art by: Thomas Stoop], supplement: none, numbering: none)
Their trench neared two decades old, a relic of the early war expanded into something resembling the great earthworks Farid had seen during the retreat out of the trans-Mardun territories of Yotia. Down where the Mardun river bordered Kroog, they had trench lines reinforced with squat stone towers. Bunkers that hid heavy bolt-throwers, subterranean hospitals and mess halls, weather-sealed bunks that were lit and warmed by smokeless powerstones. But all that was a year and miles behind him, abandoned after the Argivians and their allies began their counterattack. Life on the Mardun front was cold and boring until it wasn't.
Farid's war had been one year-long walk home with mechanized death at his back and pestilence where he slept. Every illusion he had of glory, honor, and adventure was ground to pulpy meal, pressed into the mud along with honor and humanity. Each trench Farid's unit had retreated to had been older, shallower, and found in greater disrepair. When the war was last this close to Tomakul, there had been no machines, just foot soldiers and cavalry; only the qadir's closest advisors knew what a dragon engine was, no one had seen an avenger, and Farid hadn't yet been born.
When Farid and his unit first tumbled into this trench, exhausted and bloodied by the artificer's cavalry, they found it a shallow ditch that stretched for a handful of miles across the valley floor, flooded, home only to the rats and the dead. They dug down into the earth, bailed out the water, and reinforced this old line for the realities of modern warfare. Now it was home, with underground dugouts to hide from thopter bombers on clear days, sapper-dug traps to sink advancing avengers and triskelions into the mud, and thickets of needle-wire strung across the front-facing side to tangle any charging enemies.
A month of cold work and thin living followed. Talk burbled through the trench of an attack, but Farid did not put too much stock in talk. Soldiers talked; attacks were slow, grand things these days. They needed soldiers to replace the dead and reinforce the living and officers to holler and shine. Thankfully, it seemed the generals never wanted to attack unless they had at least one dragon engine, or a division of the qadir's own machine soldiers to try and break the enemy line.
So, Farid cleaned his spear, kept his boots patched, rotated his socks, and cooked. This morning it was a stew. When it was ready, Farid poured a portion into Karrak's cup first, then the rest into his own. Farid nudged his friend, who sat wrapped in two cloaks, staring at the opposite wall of the muddy, frost-webbed trench.
#figure(image("005_Episode 4: The Ink of Empires/02.jpg", width: 100%), caption: [Art by: <NAME>], supplement: none, numbering: none)
"Food," Farid said. He had to shove Karrak again before he noticed. Karrak looked over, coughed, took the stew, and ate.
Farid blew on his own cup, sipped, and let the warm broth filter through him. He chewed a chunk of sodden bread and watched as a line of soldiers tromped around the sharp corner of the trench. They walked in single file, shuffling along the plank floor to keep their boots free of the rimy mud underneath. Eyes downcast, the soldiers all looked the same. The mud here dried pale, caking their boots and wool uniforms, staining the once-fine colors of the Imperial Fallaji army from dusty reds to cold shades of white, tan, and brown. All wore their helms wrapped in dark cloth, to prevent the sun from shining off the polished brass. They walked through the trench, short-stepped to not clip the heels of the soldier in front, shuffling to not be clipped by the soldier behind. Some leaned on their spears as they walked. All bowed under the weight of their packs.
"Hey," Farid said, calling up to the soldiers marching past. "Where are you going?"
None of them answered. Few even acknowledged him, and those that did just looked him over with fatigue-sunken eyes while they shuffled by. An older soldier whose coat bore a set of sewn-on sergeant's stripes passed, and Farid called out to her, asking where they were headed.
"Making room," the sergeant said. She stopped to adjust her pack, perching on the fire step. "Replacements due in this afternoon."
Farid cursed. Replacements. "They human?"
The sergeant shook her head. "All we were told was to make room for 'em. You have any more of that soup?"
It was Farid's turn to shake his head. "Just broth and bones now. What do you have?"
The sergeant thought for a moment, then fished into her coat. She pulled out a golden coin and held it out to Farid. It was one of the old ones, thick, with the last qadir's face stamped on both sides.
"For when you go home," the sergeant said. "Live like a qadir for a day in Tomakul, or an emperor for a week anywhere else."
Farid offered the sergeant the remains of the broth. She drank it down, then held the makeshift stewpot tipped to catch the last drops.
"Here, take this," Farid said, passing the sergeant one of the broth bones when he finished. "It's chicken, not rat."
"Chicken! Where did you find one of those?" The sergeant, grateful, took one of the bones.
"That miracle I cannot reveal," Farid said. "The quartermaster would have my head for it." He held a gloved finger to his lips, then pocketed the rest of the chicken bones in a pouch he wore at his waist. "Keep the coin. When you're qadir for a day, send us somewhere warm to dig a trench."
The sergeant laughed. She set the coin down on the fire step next to Farid anyways.
"For when you're home, my boy," the sergeant said, smiling.
Farid saluted. The sergeant nodded and hurried on to join the rest of her regiment as they shambled away. The unit passed through the trench for a few more minutes, the marching soldiers silent but for coughing, and the creaking and squelching of the trench's soggy floorboards. The wounded brought up the rear of the column—those who could walk, who could still carry and thrust a spear, were sent back to the front—shuffling with their heads down and eyes distant.
"A sorry lot we are," Karrak said. He'd come back from his distant staring. A wet cough roughened his voice. "Are you going to take that gold?" he asked Farid, eyeing the coin the sergeant had left on the fire step.
Farid looked at the coin. The sun had started to burn away the mist, and the gold gleamed in the cold morning light. He passed it to Karrak, who bit it and checked the impression. Satisfied, he tucked it into a pocket deep in his coat.
"Replacements, she said?" Karrak grunted.
"Replacements," Farid agreed.
"I hope they're machines," Karrak said. "Some of Mishra's. Not those dead things." Karrak coughed. "No more meat for this beast."
"I say give us the dead ones if it means we can go home," Farid said. "Let the qadir and his brother fight this war with their toy soldiers."
Karrak shrank into his coat and shivered. Farid reached out an arm and pulled him close. He could feel the heat Karrak threw off, like a brazier filled to the brim with coals. The same plague that had savaged him just two weeks prior, Farid guessed.
An officer—a captain in a pristine uniform but for mud-stained boots—brought up the rear of the marching soldiers. Farid noticed him a second too late. Cursing, he stood. Karrak struggled, but Farid hauled his friend up and held him as the captain marched past. The two of them saluted and the captain ignored them, consulting instead a sheaf of orders that a runner had passed him. The runner, a youth in a similarly pristine uniform, paced alongside, hopping between the fire step and the plank walkway above the muddy trench floor, taking notes as the captain rattled off orders to be dispersed to various units up and down the line.
Farid and Karrak and the rest of the men in their section stood for as long as it took for the captain to pass. When the officer turned the corner and was out of sight, they sat back down on the fire step, slouched back into their dugouts, and curled back up to sleep.
Winter's deep chill sank into Farid. He watched over Karrak as his friend shivered. Officers, movement, replacements, and reinforcements–activity. Nothing good could come of activity. Activity meant action, and action meant going over the top, into the blades and fire of the machines.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
The replacements arrived the next day, stooped under their heavy packs, yet to be lightened by the practicalities of war. They were human, not Mishran automatons or those stinking mechanical corpses; a mix of old men and women, out-of-place youths drawn from the farthest corners of the empire, haggard soldiers ferried over from the newly pacified Sarinth, and convicts. The replacements tromped through the trenches, eyes down, under the silent stares of the soldiers long on the line.
Some looked to Farid as if they came from Tomakul, though most of the replacements seemed to be desert types: thin before arriving at the front, either swallowed by their uniforms or barely able to fit into them. A scattering of Zegonians passed, talking in their quiet tongue. A pair of broad, tattooed Sumifans marched past, a nervous song on their lips that left a taste of ozone on the air. A penal unit marched by at a quick step, closely watched by their broad and rough-tongued minders, the lot of them simmering with such a mix of fear, desperation, and brutality that Farid was glad to see them continue down the line, not stopping at his post.
Some of the replacements carried themselves with an air of defiance, but most peered out at the brasscaps with wide eyes, all pity and fear; the front never looked like what you wanted it to. Farid recalled that he had expected to see knights and champions and all that when he first arrived; instead, he found a city compressed into a canal of gray stone and mud a dozen yards wide and miles long, populated by fearsome and beautiful warriors with equally fearsome and beautiful weapons, all arranged toward the glittering Mardun and the ruins of Kroog beyond the river.
Truth was, the front was hell: a nightmare made by men. You dare look too long at its population, and you'd see what you would become: hollow-eyed and sinewy, caked with mud. Gaunt soldiers in uniforms bleached and patched and stained. Farid was glad that moment was behind him. Better to already be the ghost.
At last, the officers came. Lieutenants by their stripes and sashes, shepherding the replacements to their new posts. The young officers carried that Tomakul sturdiness about them and, unlike the soldiers they led, actually wore brass caps and rose cloaks trimmed in gold cloth. Their armor was polished, and they still carried swords. Farid, broke away from the marching mass of soldiers with a squad of replacements in tow.
"Soldier," the lieutenant called to Farid. "What company are you in?"
Farid stood from the fire step and brushed his trousers flat. "D Company," he said, saluting. "Third Tomakul Spears, commanded by Colonel—"
"Sure, fine, that'll do," the lieutenant said. "These are yours, spearman." The lieutenant waved the squad of replacements forward. "Welcome to D company of the Third Tomakul Spears," he said to the replacements. "That spearman will be your senior here," the lieutenant said, pointing to Farid. "Look to him for guidance. I'll be in the officers' dugout that way," the lieutenant waved down the line. "Parade is an hour after dawn tomorrow under the company flags. Dismissed." The lieutenant tugged his brass cap, adjusting it, and then squelched off through the muddy trench, leaving the replacements to Farid.
As soon as the young officer was away down the trench, Farid swore, slumped free of his rigid parade stance, and waved the replacements over. Ten men—mostly youths a few years younger than him and an ancient veteran missing an eye—walked together in a rattling clump of brown wool coats, packs, and long spears.
"Welcome to the Argivian Front," Farid said. "I'm Farid of the Tomakul. This here is Karrak of the Suwwardi," Farid said. "The rest you'll meet at some point. Talk to the quartermaster down that way, she'll get you your regimental patch and some thread to stitch on the company letter," Farid thumbed down the trench, and the replacements all turned to look. "Any of you from Tomakul? Or are you all from the desert tribes?"
The group nodded. The older veteran stared forward with his good eye. He had the same look as Karrak—he was anywhere but here; he was nowhere at all.
"I'd never been out of the city before the war," Farid said to the assembled replacements. "Never been out in the deep desert—I heard it got cold at night, but never expected this. At least the Mist Moon is a great beauty." Farid looked around at the wide-eyed replacements. Nothing there but fear. "Why are you standing?" He said to them. "Grab a seat, find a bunk."
There were little cavities and burrows dug into the trench wall and reinforced by planks, their muddy floors covered with strips of burlap and torn clothing taken from dead soldiers. The replacements scrambled to grab the good ones. Each vacant dugout burrow had housed someone who went over the wall and never came back, and the dead always left small trinkets behind; if you were lucky, you might find something valuable to trade to the quartermaster for smokes or nabiz.
"Have you seen the enemy, sir?" one of the younger replacements asked as they settled into the dugouts. "The Argivians and their machine devils?" The replacement swam under his brown, undyed cloak. He carried a spear, around the blade of which a thin ribbon of rose silk was tied. Farid first thought it a favor from a beloved that the boy had tied on, but as he looked at the replacements' weapons, he realized they all had a similar ribbon fastened to their spears. That was the new mark of regiment, Farid realized. No more brass caps for the brasscaps. The boy, like the rest of the replacements, wore only a soft field cap with flaps tied down over his ears instead of the proud helms Farid and the rest of the long-deployed soldiers had been issued. They must need the metal for more automatons, Farid figured.
"I have seen them," Farid said. "Their machines as well."
"How many have you killed?" the replacement asked, eager.
Farid thought for a moment, recalling what he could of his year on campaign. He shrugged. "I don't think I've killed any."
"What?"
Farid looked to Karrak. "Have you killed any Argivians? Any Yotians?"
Karrak, always bundled, shook his head. "None," he rasped from his wrappings. "I seen many dead. Never killed one myself."
"Come to think of it, I've never even clashed with one blade to spear," Farid said. He flashed the long knife he wore at his side, then nodded toward his can opener—a sturdy pike about as tall as he, with a flat head that tapered to a sharp point.
"These are can openers. We use them on Urza's machines—though I've only ever used mine on fallen avengers and thopter wrecks," Farid said. "Closest I've been to using these in a proper fight was when we followed a unit of scythe runners into a trench. All the Argivians were dead by the time we arrived."
"Seen many dead," Karrak agreed.
"Told you." One of the other replacements said, nudging his fellow. "Trench rats," he said. "Disgraceful cowards. No wonder the Argivians have pushed us so far from Kroog—nothing but soft city-dwellers between them and the heart of our empire."
Farid and Karrak laughed. Some of the other soldiers who had been eavesdropping chuckled, shook their heads, and continued resting, eating, or maintaining their worn equipment.
"The Argivians are only two hundred yards that way," Farid said, thumbing over his shoulder in the direction of the Argivian trench. "You want to storm their line? Wait another hour—the rising sun will be at your back and then you can strike like the midday sun on the head of a waterless traveler," Farid said.
"That—that is exactly what we should do!" The replacement spluttered. He was the bravest of his companions, but they all nodded along with him. "Why are we not driving them off our land?"
Farid stood from the fire step and stepped toward the young man. "How old are you?" he asked, sizing up the youth.
"Fifteen," the replacement said, looking to the side but not stepping back. The boy stood an inch or so taller than Farid, who affected a permanent stoop after this time in the trenches.
"What's your name, boy?"
"Assad."
Farid drew his knife. Assad stepped back, bumping into his companions.
Farid grinned, then turned and stabbed his knife deep into the plank wall of the trench behind him. He levered out a chunk of rotting wood, sheathed his knife, and reached into the earth. He pulled a double handful of clay out from the cavity, dug a few scrapes deeper, and then wrenched something from deep inside the trench wall. He turned and held out a rag-wrapped length of bone, matted hair still clinging to the fetid remains.
"You're younger than this trench," Farid tossed the bone to the ground at the youth's boots. "But not by much." He pointed to the ragged, soggy bone. "Look at that bone. That was a person—can you tell me which uniform they wore?"
The youth stared at the bone and did not answer. The rest of his cadre were silent.
"This land doesn't matter," Farid growled. "You got a cloak?" Farid asked the group. They all nodded, some even grabbing the corners of the cloaks they wore to show him.
"Boots?"
Again, the youths showed Farid the plain but sturdy boots they all wore.
"Good," Farid said. "Listen to me and learn my lesson well: your cloak and boots matter more to you than this trench. If the Argivians make it through our wire, if their metal avengers lead the way, if it looks like we're going to lose this line, you grab your cloak and you grab your boots and you run." Farid kicked the bone off the planks and into the soggy mud of the trench floor. "There's always another trench. Might not always be another cloak or pair of boots." He waited until each of the boys nodded at him. "Good. Lesson over. You're dismissed."
The replacements shuffled away. One remained, not moving from where he stood: the old, one-eyed veteran. He leaned on his spear with the comfort of a killer.
"How long?" the old veteran asked.
"A year and some months as of the start of winter," Farid said. "Karrak here has counted three. You?"
"I lost my eye at the Siege of Kroog," the old veteran said. "Served in the supply corps for a year following, and then they sent me back to train new warriors."
"The Siege?" Farid whistled. "I was only a baby when Kroog burned." Farid waved the old veteran over to sit next to him on the fire step. "What's your name, uncle?"
"Aiman," the old veteran said, setting his pack down. Aiman's voice was low and soft. The old man looked around the trench line, taking it in. "The war has changed since I was last a part of it," he said. "More mud." He fixed his good eye on Farid. "You all are still children."
"The qadir's war," Farid said. He looked away and spat. "We all must do our part."
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
Weeks after the arrival of the replacements, lieutenants and captains hustled up and down the trench line with trails of supply and logistics officers in tow. Grumbling and muttering quartermasters were forced to distribute tins of armor polish, new gloves, squares of cloth with which the spearmen were meant to patch their crimson cloaks, bolts of silk, and other useless things. They also doled out extra rations of nabiz and mutton that were well received by the young replacements, but who did not know what extra rations of wine and mutton meant. In the mornings, the soldiers were woken by runners and their sergeants for parade formations, ordered to line up as best one could in the narrow confines of the trench for presentations to the majors and colonels who walked with scarves held to their noses through the places where the soldiers lived.
Farid, Karrak, and Aiman knew this was not routine. The young, fresh replacements did not. They all thought this was a mighty refutation to Farid's chilly warnings made only days prior. Assad let Farid know as much after their section was dismissed following this morning's inspection.
"Not so bad, this life," Assad said, overloud, to the coterie of conscripts that followed him. "You just need to lose that city softness, you see?" He exhaled a powerful breath, sending a plume of steam roiling out into the cold morning air. He beat a fist against his firm stomach. "Carry that desert heat in your belly and love for our empire in your heart, and you'll never see a sad day in this mighty force," Assad said. "Our qadir means to set us on the attack again." He looked to Farid, smiling. "And I think everyone here should clamor to cover himself in glory after this last year of defeat. Only way to wipe away that shame is to put Tomakul to our back and send the Argivians running, right boys?"
A cheer went up among the replacements and—to Farid's dismay—even among some of the soldiers who had been on the line for months now. Fool's courage, second only to fear, spread quick as fevers. Only those who had been on the line for an actual attack and lived resisted the fervor.
Farid did not engage with Assad. He was not a fighter; besides, he had plans to make.
That evening, Farid, Karrak, and Aiman huddled together in a deep dugout and spoke in hurried whispers over a single low candle.
"Tonight, before dawn," Karrak said.
"Right," Farid said. "The attack is certainly coming by the end of the week. We need to go tonight."
"And how will they know to expect us?" Aiman asked.
"That I can't tell you," Farid said. "Not yet."
"Fine," Aiman grunted. "Whatever gets me through it, I won't complain."
"Good man," Farid said.
"If it must be tonight, then who do we trust to bring in?" Karrak, whose fever had finally broken, spoke around the warm smoke of the trenchroll he smoked. He offered it to Farid, who shook his head. Aiman plucked the roll instead.
"Not Assad," Aiman said. "He reminds me too much of the ones I fought with at Kroog. All muscle and no think."
"Jamal?" Karrak offered.
"Jamal could be good," Farid agreed.
"He's quick," Karrak said. "And quiet."
"No," Aiman said. "Jamal is Sarinthian. The qadir only just suppressed their rebellion," Aiman said. He shook his head. "I like Jamal, but no one outside the unit will trust him. If we get caught out there with a Sarinthian~" Aiman drew his thumb across his throat.
"Right, good point." Farid sighed. He ran a hand over his shorn head. "Damn it, Karrak. Why do we have to take someone new?"
Karrak shook his head. "Sergeant said we have to take someone new to make it look convincing. Says the lieutenant told him that the colonel has ordered night patrols to be teams of four." He shrugged. "If it's just the three of us, we look suspicious."
"Fine," Farid said. "Four it is."
"Ehsan," Aiman said. "Ehsan is nobody. He'll do as he's told and stay quiet after."
"Ehsan?" Farid looked to Karrak, who shrugged. "Perfect," Farid said. "Aiman, you go get young Ehsan."
Aiman nodded and touched his brow. He scooted back from the candle and pulled himself out of the dugout. Farid and Karrak listened to the sound of his boots tromping away down the trench. When they faded and they were alone, Karrak finally spoke.
"Can we trust Aiman?"
Farid looked up at the canvas flap that covered the entrance to their dugout.
"I trust that he wants to live," Farid said. "Same as you and me and everyone else the war didn't kill yet."
"Just as well," Karrak grunted in a tone Farid knew to mean agreement. "Aiman knows who the real enemy is."
A commotion outside broke the long silence that followed. Boots thudding past on the plank flooring of the trench, excited murmurs and cursing. A shout.
Karrak started to his feet, hand to the long knife at his belt. Farid darted past him, bursting out into the trench in time to collide with a group of soldiers jogging past. They all tumbled to the ground, cursing and blaming each other for their clumsiness. Trading shoves, they pulled each other to their feet and parted. Farid hollered curses at the soldiers as they hustled down the trench; they shouted curses back, but they continued down the line.
"What's going on?" Karrak asked, poking his head out from the dugout. Not an attack—if there was an attack, it would be much louder. This was something else.
"I don't know," Farid said. He stepped to the side as more soldiers jogged past. "Something down that way, maybe a fight, maybe some new war machine." Farid offered his hand down to Karrak. "You coming?"
Karrak laughed and ducked back inside their dugout, twitching the curtain closed behind him. A no, then. Farid buttoned his coat against the evening's chill and joined the stream of curious troopers heading down the trench, shuffling along with them through the zigs and zags and blastbreaks. Though the sun had only just set and the world above the trench still clung to the day's light, the belly of the battleworks were plunged already into deep night. The trench's lights hummed on and burned dim, banishing the umbral dark with warm, blood-red light. To Farid that light–meant to save their vision in case of a nighttime assault–always made everything seem darker. To this moment it added a special horror.
Muttering filtered through the close-packed soldiers ahead. A pair of troopers crouched at the lip of the trench, offering their hands down to help haul any who wanted up. Whatever drew this crowd happened behind their line; it was not the Argivians.
When it was Farid's turn, both soldiers hauled him up. They were silent, grim-faced, ashen. Farid did not ask questions. The last fingers of light bled below the horizon. Dozens of soldiers stood a short distance away, their breath puffing white into the deepening night sky. Red and green lights flashed and slipped through the gaps in this wall of bodies.
Farid went alone to join them.
The stink hit Farid first. Like an open latrine pit before the sanitary corps got to it, or a battlefield thick with the dead. A weight to the chilly evening air. He pushed through the crowd, which seemed more than willing to part. Some of the soldiers even turned and started back to the trench, prayers tumbling from their lips.
The sound of chains and marching. The crunch of frosted ground trod over by hundreds of bare feet. The dim red and green nightlights topped poles carried by their minders, marker lights that the chained creatures followed. The dead ones. Farid thought he felt the blood drain from his face. Transmogrants. Hideous, piteous things that were once human, now a rotting amalgam of flesh and machine.
Whispers spread through the line of onlooking soldiers as the transmogrants marched past not ten yards away. The work of Mishra's protege, these things. The fate of any who died on the line, or those who passed of illness, or those who did not want to fight when the conscription gangs came to take them.
The transmogrants were chained together at their ankles with some distance allowed between them, but they moved at a uniform step, more perfect than any drilled line of human soldiers Farid had seen. In the dying, light he could not make out many details of these horrors, but what he did see burned into his memory. He saw dead and graying skin, scoured from the cold and the sun, stretched and woven through dark metal. They walked without outward care of the cold. They carried no weapons, but wicked claws burst from weeping stumps. Bloodless flaps with dead tufts of hair pulled taught over polished metal domes. Chain veils hiding the ruins of faces, but not the hot breath puffing out from between the links.
Farid's stomach soured, but he did not retch. The horror of what he saw made sense. It was the battlefield he knew, embodied in a decaying legion of killing machines. Farid pitied the people these things had been. He pitied himself. He turned to head back. By the time he reached the trench a short distance away, officers had already begun shouting and bellowing at the soldiers to head back to their posts, lest they be volunteered for mechanical service.
The night was cold. Outside Farid's dugout, the trench was alive with movement. Soldiers quietly hustled by with crates of handheld bombs, replacement spearheads, bomb-lance tips, armor-piercing bolts, wire-cutters, spare powerstones, and various other ordnance.
An attack was coming. Farid guessed they would be ordered over the top within the week. He did not sleep, and neither did Karrak or Aiman. Instead, with Ehsan sitting confused but silent with them, the four spearmen huddled together over a dim candle and planned for a long night.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
Farid, Karrak, and Aiman, with Ehsan between them, moved quietly and quickly through the trench, taking care not to disturb any of the sleeping soldiers. They carried only their knives, no spears, and left their brass caps behind, favoring instead dark clothing and soft wool caps. Ehsan didn't ask any questions, though Farid could tell he had many. The boy was as quiet as Aiman promised he was, small and quick, likely no older than fourteen.
Farid carried one of the red-lensed nightlights. It was powered by a powerstone chip and burned dim enough not to call attention, but bright enough to dispel some of the trench's deep darkness.
"Wait here," Farid said, pointing the nightlight at a wooden sign. Aiman put his hands on Ehsan's shoulders to steady him—he was old enough to be the boy's grandfather, Farid thought. Karrak held a trenchroll between his lips but did not light it.
"<NAME>," Farid whispered as he crept into this section of trench. He knocked quietly on the planks outside of each dugout, calling the sergeant's name. "<NAME>, it's Farid of D Company, Third Tomakul Spears."
A rustle, and one of the dugout flaps flipped back. "You're late, Farid," Sergeant Usman said, crawling out from his dugout. "I expected you an hour ago." He yawned, tugged his cap down around his ears, and crossed his arms for warmth. "Where are your men?"
"Here," Farid said. He looked back to Karrak, Aiman, and Ehsan and waved them over. The three of them moved quietly to join them.
"Good, four, good," Usman said, tallying the small group. "Here, one moment." Usman whistled between his teeth, a short and clipped sound that slipped quickly away into the night. Another soldier emerged from a dugout with an armful of soft satchels. Usman took them and passed them to Farid, who handed them out one by one to his companions.
"One full satchel for me and my boys, remember," Usman said, wagging a finger at Farid. "Or I talk, and you join the machines."
"Uncle, you'll be cheering when I return," Farid said, a quick smile on his lean face. "Do you have the order chit?"
Usman reached into his coat and pulled out a ring of thin, tin tabs. He snapped one off and held it out to Farid.
"You'll need to think of an excuse for why you're late and far from your unit," Usman said. "But that chit will make your story believable to any officer that might stop you."
"Outstanding," Farid said, reaching for the chit. Usman did not release it.
"One full satchel," Usman said. "If it's not bursting at the seams—"
"You'll talk," Farid said. "It's not my first time, sergeant, don't worry. You'll have a full satchel by the dawn."
Usman released the chit. Farid pocketed it and Usman waved toward the fire step, where a ladder had been built into the trench wall. "We cut the wire this morning. Go up here and stay low. Whistle when you return."
"You'll hear a tune as pretty as the flowers of Tomakul," Farid said, turning from the sergeant. "Boys, let's go." Farid crossed the trench and tested the ladder. Finding it sturdy, he started to climb. Karrak followed, with Ehsan and Aiman bringing up the rear.
As Ehsan watched the other men's boots disappear over the lip of the trench, he hesitated. The boy looked back to Aiman, who he had followed close behind until now.
"Uncle," Ehsan whispered to Aiman. "Where are we going?"
"Quiet," Aiman whispered.
"Are we going to fight?"
"No," Aiman said. "Now, up over the top—and be quick, we don't want any officers to see us," he said. He gave Ehsan a soft push, encouraging him to climb. "I'll be right behind you."
War had ruined Farid's faith, but he still regarded the world above the trench as hell. It was a place out of balance. Paradise was all things distributed in harmony and proper apportionment: the balances of stone, fire, sky, and water, imbued in one's body and soul, in the land and in dreams.
No-man's-land then was the opposite, a crucible into which people were fed and ghosts emerged. It was a hell of the body, the soul, dreams, and the land. It was colder up here than in the trenches: Every surface was exposed to the bitter valley wind and watching eyes of soldiers on both sides. Nothing remained of the forest that once filled this valley. The trees that hadn't been harvested before this valley became a battlefield were now cinder-blackened stumps. The river that once coursed here had been dammed somewhere near Tomakul to deny the Argivians any of its bounty. Of the towns that once dotted the valley, only a single low, ragged stone wall remained. It was a landmark to the soldiers: how far from the wall has one moved in a year? How close to it?
#figure(image("005_Episode 4: The Ink of Empires/03.jpg", width: 100%), caption: [Art by: <NAME>], supplement: none, numbering: none)
Farid led his small group across this alien landscape, moving as quickly and quietly as he could while scurrying, belly low to the ground, guiding his party around the worst of the dead and the craters flooded with sour water. One crossed this hellscape by scrambling between craters and along old and decaying plank walkways, laid by advancing forces in long-forgotten attacks. One plankway had its builders' corpses rotting alongside, festooned with order chits dropped upon them by soldiers from both sides, grateful for their sacrifice in making this place more navigable.
They reached their first landmark without incident: a downed bomber thopter, a heavy Argivian flying craft that resembled a fat-bellied bird. The four of them crawled inside through a rent in its thin metal fuselage.
"Damned cough," Karrak said. He wheezed, struggling to breathe.
"Take a moment," Farid said. "All of you, take a moment to rest here."
"Like a wanderer gull," Aiman said, peering through the dusty glass of the thopter's crew compartment. "Great big birds that would soar alongside my father's ship." He spoke out loud, but to Farid it seemed as if he talked to only himself. Aiman looked through the wreckage toward the Argivian lines. "I never saw them land. I never thought they could."
"Where are we?" Ehsan said. His voice was still high and soft, very much a child's.
"Lower than the Nine Hells," Karrak grumbled. He set his heavy pack down on the damp floor of the thopter, groaning in relief at the weight off his shoulders. One hand rubbing his throat, he clambered over to Aiman and tapped him on the shoulder. "Let me look."
Farid offered Ehsan a sip of his water. The boy took it, drank, and passed it back.
"About fifty yards that way—where Aiman and Karrak are looking—is the Argivian line," Farid said.
Ehsan looked bug-eyed toward the enemy lines.
"Don't worry," Farid said. "We're not going to attack"—he indicated the packs Karrak and Aiman carried—"We're going to trade. All we have to do is hang this flag here," he said as he pulled a short bolt of white cloth out from a pocket on his coat. "And wait."
"I don't think I've ever seen an Argivian before," Ehsan said. "I was wondering how I'd kill one without a spear—the officers said they're made out of metal, and all I have is this little knife."
"It's not the people you gotta worry about," Karrak said.
"They die quick as cut flowers," Aiman said, agreeing. "Same as us."
"We're not going to kill anyone," Farid said, quieting the group. "You can keep that knife hidden away, Ehsan. You won't need it, unless it is to cut chocolate or sausage."
Ehsan smiled at the mention of chocolate. Farid could tell it had been a long time since Ehsan last smiled. For that matter, it had been a long time since Farid had smiled. It took humanity to smile and mean it, and Farid had none. This was not a condemnation; it was an admission, a necessary act of survival. Tunnel your vision to the task at hand and survive.
Farid, quickly, hung the strip of cloth on the outside of the crashed thopter, facing the Argivian trenches. Then, they settled in to wait.
The cold pre-dawn night was endless, stretching across this blasted valley from Tomakul to Kroog and beyond. It wormed into the hearts and desires of every bejeweled lord and power-hungry emperor, flooded their eyes like blood in milk. Eager, they reared up and sent a million of their children to fuel the night's appetite, which was now indistinguishable from their own.
Farid was only one of millions. The princes of the world would see Ehsan's soul added to the butcher's tally and, unmoved, call for a million more.
He looked to Ehsan, reached out, and patted his cheek.
"You don't need to worry," he said. "You'll be fine."
And then an explosion boomed somewhere in the distance, followed by a series of sharp pops and long, sizzling whines. Spotting flares launched from both sides illuminated a section of trench and no-man's-land a mile and a half down the line, far enough that the light from the flares' ignition flashed a heartbeat before the sound of their detonation. They could hear the echoes of distant screams somewhere down the valley but could not tell whose side cried out.
"Down," Farid hissed. He waved his palm down and put a finger to his lips. "Down, now!"
The four of them dropped to the shadowed belly of the crashed thopter, hands over their heads, and waited. The harsh, steady light of the parachuting flares cast stark and nightmarish shadows through the cracked and dirty glass of the ornithopter's crew compartment and bombing windows. That light was unrelenting, white and furious, the gaze of a god who only knew fire.
The thunder quieted. Not a battle, just a fight of no consequence. Farid let out a long and trembling exhale. He counted as the light from the flares faded and night returned.
"They're coming," Aiman said. He peered through the thopter's dusty glass canopy. "I see four of them at least, thirty yards distant."
"Just them, right?" Karrak asked. "No avengers? No walkers?"
"Just them," Aiman said. "Farid?"
Farid looked over to Ehsan, who had crawled into a corner, pale-faced and trembling. His hopeful smile gone. The boy knew he would never be fine. Even if by some grace Farid could resurrect this ornithopter and fly it home, Ehsan would never be a child again. None of them could steal back what had been ripped from them. It was easy to become one of the next million, harder to resist the momentum of lords and emperors. Unless—
"Karrak," Farid said. "Go greet our friends."
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
The Argivians spoke some Fallaji, and likewise Farid, Karrak, and Aiman had some Argivian. Four Argivians clambered into the wreck of the bomber. One of them produced a canteen filled with some acrid spirit, Karrak broke out his trenchrolls, and the soldiers got to talking, joking, and swapping small things. Though hesitant at first, Ehsan soon joined the rest of them, and the eight soldiers together made a warm escape from the war. In the wreckage of the downed ornithopter, this small group may as well have been comfortable acquaintances at a cafe in Tomakul or a tea shop in Argive; if Farid closed his eyes, he could almost imagine a world outside of this one.
"I want to apologize for being late," the Argivian leader said in lightly accented Fallaji. She was a windbitten woman who reminded Farid of his mother. Stern, but he could see the laugh lines worn into her face. Laria, Farid remembered her name.
"Crossing our line was difficult," Laria said. "Lots of officers. Many new ones." She pointed to her eyes, and then to her group. "They don't trust us, so they watch."
Karrak grunted. "Sounds like officers," he said, speaking his own rough Argivian. "Always looking to use their swords."
The Argivians chuckled. Laria smiled. She looked past Farid and Karrak to Aiman and Ehsan, who, though part of the group, had kept quiet. "And who are they?"
"This is Ehsan," Aiman said, speaking before Farid could. The old man's Argivian, though accented, was perfect; he spoke with the comfort of one who had heard a language young and grown up with it close. "He's new on the line, from Tomakul. My name is Aiman. I am not new to the line, though I thought myself retired from the war many years ago after I was wounded."
"You speak our language well," Laria said. She switched to Argivian and introduced herself. Farid only caught a few words as she and Aiman carried on a rapid, gregarious conversation. Farid watched the two of them talk and felt a distant sort of hope. Aiman, like Ehsan, could still spark into the person he was before the war—the only difference was he had been through it before. The old man had been shoved into hell, all but torn to ribbons by the death machines there, and still knew how to make someone laugh. His smile was not sweet; many of his teeth were missing and the scars that webbed out from his ruined eye tugged at the corner of his mouth. But it was a beautiful smile. Laria's quiet laughter was the sound of Farid's sisters and mother, kneading dough.
This moment was good. The war didn't make this moment happen; it happened despite the war. Farid looked from Aiman's broken smile to Laria's graying hair, Karrak's gaunt face to the bandaged brow of the Argivian soldier he compared and traded knives with. Farid was not a poet, but the beauty of this moment sat with him. He committed to memory the tragedy of this little peace: their blood was the ink in which lord and emperors rewrote the borders of the world.
"It's nearing dawn," Laria said after some kind hours passed. The eight of them were well comfortable now, their helms discarded and packs piled, laden with the goods they all brought to trade. "We should get back."
#emph[Now] , Farid thought. The mighty could not write without ink; rob them of their medium. "There is an attack coming," Farid said. "Our officers have been preparing an assault. The whole front."
Laria raised an eyebrow. She looked to her soldiers, who paused as they adjusted their packs.
"Farid," Karrak said, speaking Fallaji. "This could get us killed."
"Quiet," Farid snapped.
Karrak quieted, glowering. Farid ignored him and continued, switching back to Argivian.
"Our generals have moved in a whole regiment of transmogrants—the qadir's dead men," Farid said. "Those silks and kits we gave you? They passed them out to us just days ago. They've given us wine and meat. Brought in thousands of replacements from across the Empire," he said, gesturing to Aiman and Ehsan.
Laria nodded. Any soldier this long on the line knew what extra rations and troop movements meant. "Thank you, Farid," she said. She looked to Aiman and spoke to him in Argivian, far too fast for Farid to understand. Aiman responded, Laria smiled, and with a salute, she and her troops left the ornithopter.
"What did she say?" Farid asked Aiman.
"Clay statues," Aiman said.
"What?"
"Their general," Aiman said. "A man named Tawnos. He's an artificer in service to their Lord Urza. He has brought with him a dozen units of his Clay Soldiers." Aiman nodded toward the Argivian line. "Laria said they know our attack is coming. They've been preparing for weeks. It's going to be a slaughter on both sides," Aiman said. "But if we stay back, she said, it will only be a slaughter of machines."
Farid exhaled. He had been holding his breath the whole time without realizing it. He looked at Karrak, who was pale.
"We have to keep this to ourselves," Karrak said. He looked at Aiman and Ehsan. "We can't tell anyone."
"I know," Farid said.
"If anyone else discovers that we know this," Karrak whispered, "we'll be hung as traitors if we don't die first."
"Yeah," Farid nodded. He closed his eyes and sighed. Pinched his brow. "Fine. We keep this between us, agreed?"
"Aye," Aiman said. He muttered a quick prayer.
"Agreed," Karrak said.
Ehsan said nothing but nodded.
"Good," Farid said. It was far from good, but it was enough.
As they crawled, silent and burdened, through the cold mud back to their trench, Farid wrestled with hope. What other choice do the disposable people of the world have? The men above them had weapons, gold, blessings from the gods—all that Farid had was his body. All he could do was refuse to be ink and try to save the ones that could still be pulled out from the night.
The order to attack came two days later.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
The officer's whistles thrust the cold morning into blinkered clarity. One purpose now: survive and advance. Farid flinched as another barrage of energy beams and shells rumbled overhead, whistling and screaming through the sky. The earth shook, his heart pounded against his cuirass.
The first wave had already gone over the top, only a handful from Farid's section tumbling back into the trench, feathered with bolts. The second wave stood ready on the fire step; Farid, Karrak, Aiman, and Ehsan stood in the final wave of the day, shoulder to shoulder with the other soldiers of D Company, Third Tomakul Spears. Stinking fear and shallow breath fogged the air above them. Someone retched, as someone always does. Farid's leg could not stop shaking.
A sound like thunder rumbled overhead, constant and bone-rattling. Heavy bomb-lobbers, catapulting shells overhead from somewhere well behind the line. Farid had seen those machines before: they looked to him like beetles with smokestacks bristling from their backs—cannons, the engineers and artificers called them. They had been firing for the better part of an hour now, pounding the Argivian line with explosions and shrapnel. Acrid smoke drifted back. Though he could not see from inside the trench, Farid could smell the raging, terrible fire. They would continue that bombardment until the first wave was nearly upon the Argivian lines.
#figure(image("005_Episode 4: The Ink of Empires/04.jpg", width: 100%), caption: [Art by: <NAME>], supplement: none, numbering: none)
An officer stood directly behind Farid, sword drawn, and bellowed about glory and honor and driving the Argivian dogs back to the Mardun. He promised the first soldier of his company to reach the Argivian trench a sack of gold coins, a commendation to any who captured an Argivian flag. If any cowards remained behind, he promised to have them taste Tomakul steel.
D Company's lives were packed onto their backs. If this attack was successful—which the officers demanded and assured them it would be—then they would move into the cleared-out trench. If they died, then it was easy for the quartermasters and supply officers to collect. D Company wore their coats, their long knives, brass caps if they had them or soft campaign covers if they did not. They carried their short spears and bandoliers of extra bomb-tipped heads, clubs, trench nails. Anything to make them better killers.
The bomb-lobbers fell silent, the last reports of shells echoing away down the valley.
Another whistle. The barking of sergeants and hollering of officers drove the second wave up from the fire step, up over the ladders, up over the lip of the trench and into the swirling smoke. No land beyond the lip of the trench, Farid thought as he stepped up to the fire step. He cheered along with the rest of the men, cheered until his throat hurt so the officers would not turn on him. Aiman bellowed, Ehsan's voice cracked and wobbled. Karrak cursed over and over.
They were next.
"What do we do?" Ehsan looked up at Farid, clutching his spear in a white-knuckled grip.
"We go slow," Farid whispered. It wasn't safe to talk here. "Stay with me. Be my shadow. Don't go anywhere I don't go. If I die, look for Karrak or Aiman." Farid looked down at Ehsan. "If you can't find any of us, get down and stay down until night. Don't fight, just stay alive."
Ehsan nodded. He shuffled closer to Farid, who put an arm around his shoulder.
"Ready up, spearman!" The officer behind them shouted, slapping Farid's arm with the flat of his sword. Farid cursed and removed his arm from Ehsan's shoulder.
Shouts up and down the line. Runners hurrying with last-second orders. Officers clenched whistles between their teeth but did not blow, reading the small scrolls.
The wind changed. The rotten stink of decay washed over the trench from behind as the officers shouted at their soldiers to pull up their masks. Farid and the rest of the company tugged their muslin masks from their pouches and tied them on. The fabric was soft and did little to banish the eye-watering stink of the transmogrants. Freed of their chains, they trod in shuffling lockstep over narrow plank bridges laid across the trench. But for the sound of their bare flesh-and-metal feet thudding on the wood or squelching in the cold mud, they were quiet.
Farid, thankfully, was not under one of the bridges. He hazarded a look over to the nearest crossing and watched in horror as the transmogrants advanced; though mass-produced in some charnel factory, each one seemed a unique body, a one-off marriage of dead flesh and iron. They were each a nightmare.
Farid tugged his cloth mask tighter and set his eyes straight to the ladder in front of him. When the whistle blew, he climbed, pushed along by those behind him. Near the top of the ladder, he reached up and took Karrak's hand, pulling himself up over the lip of the trench. He turned and helped Ehsan up, and then left the officer behind to fend for himself.
#figure(image("005_Episode 4: The Ink of Empires/05.jpg", width: 100%), caption: [Art by: Daarken], supplement: none, numbering: none)
The charge was slow despite the screaming of the officers' whistles and hoarse cry from the third wave. Smoke drifted over everything, shrinking their world down to a hazy ring a dozen yards in diameter. Farid, Aiman, Karrak, and Ehsan moved slowly forward, spears level, spaced only a few feet apart, marching rather than running toward the Argivian line. A dozen or so spearmen walked in rank alongside them, vanishing into the smoke on either side. An officer walked behind them, sword drawn.
"Steady boys," Farid said. "Steady. Watch your footing." A hot rain fell, mud and water tumbling down from the morning's mighty bombardment. Here and there, they came across the fallen bodies of their comrades, torn and burned. Casualties of the shells that missed their mark and fell among their own ranks.
The charge across no-man's-land was a slow tumbling of balance and recovery. They slipped and slid across muddy craters and used their spears as walking sticks. Shouts rang up and down the line, drifting in from the smoke along the advance. Together they crossed the crater field and passed by the ruined ornithopter. Ahead it was quiet, without the usual sound of battle. No cries of pain or fear, no shouts, no clash of metal on metal, no great booms and reports of bombs or the massive weapons of the machines. Just the crackle of fire, the soft rattling of their equipment, and the quiet encouragement of the officers behind.
They reached the Argivian trench and found it empty. Their bombardment had been effective and terrible, churning the well-engineered battlements into a mess of wire, burning wood, and abandoned equipment. Some lightly wounded Fallaji soldiers of the first and second wave sat smoking or resting on captured crates of Argivian equipment. They greeted the third wave with exhausted nods and sardonic cheers.
"Where are the Argivians?" a lieutenant screamed at the wounded soldiers. "Where is the enemy?"
"Front's moved," a wounded corporal said. She thumbed over her shoulder, down the valley toward the distant Mardun. "Rest of the Third went on to the next trench. Looks like the Argivians are running back to Kroog."
The officer stamped and fumed, then ordered D Company to check the trench while he went to find out what he should do. Farid, Karrak, Aiman, and Ehsan went together, the four of them wandering off into a section of the trench that was largely intact.
They found it to be a mirror of their own. Dugouts and small chambers for soldiers to crouch and sleep in. Empty racks where they would have kept weapons stowed for quick access should an attack come. Plenty of small things left behind in the hurry to escape. Not a single soul remained. Farid and Ehsan found a transmogrant that had tumbled into the trench and snapped in half. Farid stabbed it with his spear, thinking to put the beast out of its misery, but it only grabbed the weapon and turned its eyeless gaze to him. Farid released his spear and staggered back. The transmogrant shuddered, as if trying to stand, but made no sound. Aiman pulled Ehsan from the transmogrant, wordlessly steering him away before the boy could try to use his own spear on the fallen creature.
"Hey, Farid," Karrak called. He stood halfway in a dugout, spear tucked under his arm. "Look what I found." He held up a small packet of paper wrapping, secured with a shred of familiar fabric. Farid walked over and saw it was a strip of Fallaji silk–one of the sashes they'd traded with Laria and her soldiers.
"What is it?" Farid asked.
"No clue." Karrak said, offering it to him.
Farid took the packet. For a moment, he worried it was a trap, but that moment passed. Karrak, Aiman, and Ehsan crowded him, curious. Farid tugged the silk free, stuffed it in his pocket, and unwrapped the contents, revealing a small piece of chocolate and a note.
#emph[Our gratitude] , written in Fallaji script by an Argivian hand.
Farid smiled. A small and human thing. Ink, blotting the page.
The officers' whistles started up again. Forward, the order.
Eleven miles from the golden domes of Tomakul, the front was on the move once more.
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
#strong[44 AR]
Teferi appeared at night in a place very much like hell. Fire burned low on all sides of the spot where he snapped into coherence. He was grateful that as a spirit he could not smell what he saw: The dead were so closely packed that in some places there was no visible ground, only bodies atop bodies. Ruined machines ticked and cooled. Earthworks, once mighty testaments to engineering and human brilliance, were empty and abandoned. A battlefield at night, after some bloody price paid. Teferi looked around, grim-faced, and tried to get his bearings; the last two jumps had rattled him.
The Last Battle took place on Argoth, an island shattered and buried by the sylex blast. Histories recorded by survivors elsewhere on Terisiare spoke of it as a verdant jewel, the last green place where the brothers fought. This place was not that. A bit of wall stood alone in a valley stripped of trees and greenery, boiled to mud and crisscrossed by wire-bordered trenches. Fires burned on what surface it could eat. Not Argoth; likely somewhere on the mainland.
The knot of time around the Last Battle was a confusing morass of recursive loops, potentialities, and branching paths. Navigating them, even with the aid of Saheeli's brilliant Temporal Anchor, was a nightmare. Or Teferi thought it was, until he realigned here on this battlefield. This was the true nightmare. Worse even than the burning streets of Kroog. He'd returned shaken from that experience, but time—even for him, and even with the anchor at his disposal—was running out. He had to return, quickly.
Teferi guessed and, against Kaya and Saheeli's protestations, had engaged the anchor once more, seeking the Last Battle in the manifold mess of time that was the Brothers' War. On paper his search was simple enough: find what he came to think of as "blotted time," where tens of thousands of lives met and came to an end. Blotted time looked to Teferi like holes chewed in a hanging curtain, or stars in the night sky. Its cause was great death—the infinite possibilities of all those lives ending in a moment, taking with them a piece of the great tapestry of time.
Time was running out; the moment Teferi sought was difficult to find. He was only one observer; he was not a god. All other possibilities were slipping away from him.
What did he know of the Last Battle? Urza brought a colossus of stone and iron, and it fought a titan of wood and resin and the dead of Argoth. Then Urza and the sylex killed the world.
Teferi glided over the ground, giving himself a few minutes before heading back and trying again. He didn't see a stone colossus or a titanic forest creature, like Kayla's poem mentioned. There was no ocean. Only mud and the dead.
And the scavengers.
Teferi didn't see them when he first arrived, but he saw them now. Lone figures stalked across the field, bending every now and then to examine a body. Alone or in small groups, they dragged bodies behind them, stacking them on carts that others wheeled off into the night. Some collected the ruined parts of fallen automatons, prying powerstones from sockets and working joints from shattered bodies.
#figure(image("005_Episode 4: The Ink of Empires/06.jpg", width: 100%), caption: [Art by: <NAME>], supplement: none, numbering: none)
"Who are you?"
If Teferi had blood, it would have run cold. He turned, slowly, and looked into the hideously augmented face of one of the black-robed scavengers.
"Are you the one from our dream?" the person whispered. They stepped forward, a deep whirring and clicking issuing from them. Their eyes were black chips of glass set deep into puffy, red sockets. Their mouth was lipless, toothless, replaced with a studded, tumbling cylinder that clicked thin metal strips as it turned. The sound was flat, soft, and hideous.
They did not seem to be in pain. Instead, it looked as if they were smiling.
Teferi drifted backwards, avoiding the scavenger as they reached toward him. The hem of their sleeve fell away, revealing an arm that ended in a cluster of dozens of small grasping manipulators.
"Brothers," the scavenger screamed. "Do you see him?"
Teferi had seen enough. This was not the Last Battle, only a footnote lost in the great void on time's tapestry that was the Brothers' War.
It was time to go.
|
|
https://github.com/jgm/typst-hs | https://raw.githubusercontent.com/jgm/typst-hs/main/test/typ/layout/list-attach-04.typ | typst | Other | // Test that wide lists cannot be ...
#set block(spacing: 15pt)
Hello
- A
- B
World
|
https://github.com/polarkac/MTG-Stories | https://raw.githubusercontent.com/polarkac/MTG-Stories/master/stories/041%20-%20Kaldheim/001_Episode%201%3A%20Travelers.typ | typst | #import "@local/mtgstory:0.2.0": conf
#show: doc => conf(
"Episode 1: Travelers",
set_name: "Kaldheim",
story_date: datetime(day: 07, month: 01, year: 2021),
author: "<NAME> & <NAME>",
doc
)
They came in ships like nothing the villagers of Sevalgr had seen before. Long and trim, inscribed with tales of glorious battle and cunning victory, gliding over the waves like the drakes and serpents carved into their prows. They were nothing like the meager fishing boats, which provided the sole source of food for the village now that they could no longer go into the forest.
#figure(image("001_Episode 1: Travelers/01.jpg", width: 100%), caption: [Mistgate Pathway | Art by: Yeong-Hao Han], supplement: none, numbering: none)
Neither were the men and women aboard these ships shrunken, bent by hunger and fear, as the people of Sevalgr were; even the greybeard who accompanied them, the one with the raven on his shoulder, didn't seem to lean too heavily on his walking stick. They wore hoods and scarves, fishskin jerkins, armor—though nothing that would drag them to the bottom of the sea if they were to fall into the water. Their bodies were tattooed with navigational maps. There could be no mistaking them. Omenseekers.
The hersir invited them into the longhall, where he had put together as well a meal as they could offer the travelers. Such was tradition in Kaldheim; you never knew when the stranger at your door was one of the gods in disguise. But the clan leader—the blind woman, who somehow needed no help navigating the narrow, muddy streets—declined the offer. They were not here for salted fish and hard tack.
"When did the disappearances start?" she asked. None of the villagers had ever met Inga Rune-Eyes, the clan leader of the Omenseekers, but her strange white gaze left no doubt as to whom they spoke.
"They aren't disappearances, they're murders," said one woman, near the front of the crowd that had assembled. She had lost two daughters over the last month.
"You don't know that!" shouted another man, his eyes sunken and red from weeping. He'd lost his husband.
"You haven't found any bodies," said Inga, gently. "Is that right?"
Both nodded stiffly.
"No bodies. But one of the hunters saw it," said the hersir.
"Saw what?" asked Inga.
"Go on, Hras," said the alderman. "Tell them."
A young man stepped forward, no older than sixteen. In one of the braziers, a coal snapped with sparks; he flinched at the noise.
"Boy, what did you see?" asked Inga. Slowly, so as not to alarm the lad. "What is doing this to your town?"
He rubbed at his arms, as if cold. Refused to look up at her. "A monster. It was a monster."
If Inga was surprised, she didn't show it. "Asi," she said, waving over the old man with the bird, "I want a war party ready to set off within the hour. Skeleton crews aboard the ships until we return. Everyone who can be spared is going into the Aldergard forest."
The old man, who had been nodding intently until then, paused. "And your~guest? Will she be coming as well?"
The villagers had seen her, of course. That woman in strange garb, loitering by the ships while the Omenseekers took down sails and secured their vessels to the aging Sevalgr docks. The one who looked at them like they were curiosities pulled from the depths.
"Kaya?" said Rune-Eyes. "All this was her idea in the first place."
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
#figure(image("001_Episode 1: Travelers/02.jpg", width: 100%), caption: [Inga Rune-Eyes | Art by: <NAME>], supplement: none, numbering: none)
Yeah, fine—it had been her idea. Journey into the wilderness, slay the terrible beast that's been eating up townsfolk. It seemed like the kind of thing heroes did, and she supposed she was a hero now. It didn't hurt that she was getting paid for it, though she certainly wished she knew who was paying her. But anonymous coin, minted from half a dozen different planes, was hard to argue with, and as an added benefit, it seemed nice and simple. Nothing like that messy business on Ravnica.
It was all going according to plan so far, only she didn't count on the wilderness being so~wild. Kaya was used to the solidity of cobblestones underfoot, the press of a crowd around her. She was used to noise. Out here, in the Aldergard, each crunching footstep in the snow seemed to echo out between the massive pines for miles. She'd had a persistent case of goosebumps since they set off, and not just from the cold.
"Is this place always so quiet? I've been in tombs that were livelier," she said when they stopped for a moment of rest under the branches of the great trees above.
The old man—Asi, he'd said his name was—raised an eyebrow. "Perhaps a lively tomb is not so rare, when one is a hunter of spirits."
"You may have a point." Inga, leader of the Omenseekers, was the first person Kaya had met on this plane, and she seemed a good enough sort. Hard to get to know, though—she always seemed distracted, as if talking to you was dragging her attention away from something more pressing. The old man, she'd found, was better company.
"The Aldergard is an old and strange place. The Omenseekers are legendary explorers, but even they seldom travel this far into the forest. Too far from the sea, from their ships. Inga Rune-Eyes has sight beyond most mortals; she has knowledge of every location to which her clan members have gone. Even she knows little of this place, though."
"Strange, old—I get all that. Still would have expected to see some animals. A squirrel, at least. You have those here, don't you?"
"Oh, yes. In fact, Toski, the messenger of the gods, is a great cousin of the common squirrel. There are many stories of him scampering about the branches of the World Tree, delivering news across the many realms of Kaldheim."
He had that voice Kaya associated with doddering grandfathers, but she had to remind herself that these "stories" probably weren't far off from the truth. She'd seen the branches of the World Tree herself in the skies of Bretagard—hanging there, massive beyond reckoning, disappearing behind the passing clouds. A giant squirrel. Well, why not? She had seen stranger.
"It #emph[is ] unusual, though, to go so long in these woods without a sign of life. Almost as if the birds and beasts mean to avoid this place," said Asi.
"Maybe they've got better sense than us."
"You would be surprised how many do."
"People taken in the night"—an Omenseeker began muttering near them. The fear was plain in his voice—"at the edge of the woods, like sheep. You heard what that hunter said—he saw a monster. What if this isn't just some overgrown beast?"
"What are you suggesting it is we're tracking, young man?" said Asi.
"Sarulf," he said, dropping his voice to a whisper, as if speaking the name might cause the thing suddenly to appear. "The Dread-Wolf. The Realm Eater."
"A wolf? That's what has you jumping at every snowflake?" said Kaya.
"Sarulf is no ordinary animal," said Asi. "He is one of the Cosmos Monsters. Created at the birth of the world, dwelling in the void between the realms. He would be a mighty foe to face indeed—but I wouldn't worry," said Asi. "It isn't the way of such beings to lurk and linger in the dark corners of the Aldergard. Were they to come to Bretagard, they would not do so in secret."
From the bows above them came a harsh caw. Kaya's hand went to one of the daggers at her belt. A raven wheeled in a circle above them, dropping lower and lower, black wings stark against the snow-white sky.
"Ah," said Asi. "Hakka's back."
It landed on his arm, then hopped to his shoulder, where it seemed to lean close to his ear. Kaya heard nothing, only saw the bird's beak opening and closing, the old man cocking his head thoughtfully.
"Well," he said, "my friend may have found us a lead."
#v(0.35em)
#line(length: 100%, stroke: rgb(90%, 90%, 90%))
#v(0.35em)
#figure(image("001_Episode 1: Travelers/03.jpg", width: 100%), caption: [Kaya the Inexorable | Art by: <NAME>], supplement: none, numbering: none)
It looked, to Kaya, exactly like the sort of place to find a monster. Ahead of their party, the mouth of the cave yawned wide and dark. What faint light made its way through the cloud cover and forest canopy didn't reach beyond the first few steps. In front of the cave, the snow was marred by a long streak of blood and dirt; something had been dragged inside.
Quietly, hands on their weapons, the Omenseekers whispered little prayers to their gods. Kaya couldn't say she blamed them; to be honest, she wished she had a few gods to pray to just then. Monster hunting. Whose bright idea had that been, anyway?
#emph[Oh, right] , she thought. #emph[Mine.]
"Are you ready, Kaya?" asked Inga. She had no weapon of her own; only a lantern, lit with a flickering blue flame. Funny that she was the one carrying their light source. "You have traveled long and far to get here."
"Yeah, well. Guess we'd better get on with it," she said. With much more confidence than she really felt, Kaya stepped inside.
It was warmer in the cave. That was something, at least; Kaya could let the heavy furs she'd been wrapped in all this time slip a little looser. Together, she and the Omenseekers crept forward, each scuff of boots on stone or steel on leather seeming to reverberate past them into the depths. Soon, even the weak light of the surface was gone, and the azure beam of Inga's lantern was all they had to part the darkness. As it swept over one portion of the cave wall, something glittered.
"Wait," said Kaya. "Bring that light back."
In the lantern beam, Kaya was sure of it: veins of some kind of metal ran along the wall and ceiling of the cave. It didn't resemble any mineral she'd ever seen, though. In places, it seemed to fork into webbed, root-like fractals, forming a broad latticework over the stone.
"Was there ever a mine here?" she asked.
"No," murmured Inga. "This place should be barren rock."
"Well, it's pretty obviously not. Not anymore."
Next to her, one of the Omenseekers reached out toward the wall. Kaya caught his wrist. "I wouldn't touch that."
He pulled back his hand. "Why not?"
"Call it a hunch."
Wordlessly, they kept moving. Hard to say how long they spent shuffling forward, the dark on all sides seeming to press the breath out of them. It felt like a long, long time—hours, not minutes—so that when the passage finally opened up into a wide chamber, the earthen ceiling disappearing above them into darkness, it would have felt like relief. Would have, if not for what they saw at the center of the cave chamber.
At first, Kaya thought the hulking figure hunched over the carcass of a dire bear was simply eating. The wet choking noises, the sound of meat tearing from bone, all supported this theory. But when Inga's lantern beam swept over the creature and it turned to face them, Kaya could see that it wasn't quite right—the monster's arms were embedded in the bear's side, somehow fused with its flesh. With an awful popping sound, Kaya watched as the monster ripped itself free.
"That," hissed Kaya, "is #emph[not ] a wolf."
It stood twelve feet, maybe higher, its body a raw pinkish-red color. Across its shoulders was a ruff of patchy fur, a dozen different hues swirled together. The arms that had been sunken into the bear looked long and powerful, ending in horrible, curving talons. Two additional spindly arms extended from its chest, clawed hands twitching like spiders. All strange, but nothing as strange as its head; a skull-like face flanked by razor tusks and broad, spined antlers, all of it the color of bone, even as it gleamed like metal in the light of Inga's lantern.
It opened its mouth, red sinews working beneath its plated mask, and made a noise that scared Kaya in a way no spirit ever had—like a bear's roar, but wrong. #emph[A bad imitation.] Then it dropped into a loping charge straight for them.
Kaya leapt out of the way, rolling across the cave floor and coming up with her daggers in hand. Two of the Omenseekers hadn't been so quick; one was pinned beneath the creature, screaming as the spindly arms sank into his face as if his flesh were only water. The other struggled as he was lifted in one monstrous hand.
It was a horrifying display, enough to send lesser warriors fleeing in terror, and the Omenseekers were not really warriors at heart. Traveling with them from the Kirda Pillars, Kaya had learned what it was that really drove them forward: the thrill of exploration, of discovery. They were willing to fight, as part of this, but they never relished it. To their credit, though, none of them turned and ran. #emph[Not like they'd get far] , she thought.
Forming a semicircle around the monster, several jabbed spears at it while others hacked at its outstretched limbs with sword and axe, opening great bloody gashes with each swing.
"Don't touch it!" shouted Kaya over the screaming of the trapped man, until something cut him off with a wet gurgle.
Before her eyes, the wounds seemed to knit shut, muscles welding themselves back together. From a particularly deep gash, whipping tendrils snaked out, latching on to one swordswoman's arm and dragging her shoulder-deep into the monster's flesh. Stuck there, she drew a knife from her belt and stabbed at the horrible creature over and over until it released her. She fell to the ground, clutching her arm and screaming in pain.
#emph[It's not enough to cut the meat] , thought Kaya, willing energy into her knives. She had to cut deeper.
The creature pounced again, its wounds already sealed. For all its muscle and bulk, it moved with terrifying speed. Before another blow could land, though, its talons slowed, then stopped cold a foot from a flinching axeman. There was a blue aura surrounding its arm, Kaya realized, and it seemed to be growing denser before her eyes, hardening into a translucent kind of crystal. Kaya followed the light back to its source: Inga's lantern. As the creature dragged and strained against the stasis spell, Inga's face twisted with effort.
#emph[Not bad] , thought Kaya. Now was her chance. Kaya lunged forward, her dagger vibrating with magic, and swiped straight through the monster's trapped arm, lopping it off at the shoulder. Flesh, bone, spirit—if it could be severed, she had severed it.
The arm hit the stone floor of the cavern with a wet thud and began to blacken and crumble to ash where Kaya had cut it. The creature roared again, that bear-sound mingling with something underneath—a noise like the grinding of metal. As it twisted in pain, the dead Omenseeker, still melded to its smaller front claws, flopped about, limp as a fish.
With a motion sickeningly like an embrace, the monster pressed the limp man into its body. He disappeared into the raw pink flesh, slowly absorbed. Then, from the stump where its arm had once been, another began to grow. It happened with remarkable speed—the muscles tying themselves together, the talons hardening from a juvenile translucence to a hard black edge in the few seconds she was held transfixed by the horrid spectacle. Finished, it flexed one complete hand, something quietly popping into place, before turning those empty eye sockets toward her.
#emph[Oh, gods and monsters] , thought Kaya. Then it charged.
She ducked under its first swipe and turned her torso to ghostly aether so the second passed right through. #emph[I can hurt it at least semi-permanently] , she thought. #emph[That's something. ] Now she just had to find another opening in which to strike, a moment where she could channel power into one of her blades instead of using her magic to phase out of these ceaseless blows. She danced and weaved, just as quick as her foe.
Suddenly, her heel hit rock. The cave wall. She swore. It hadn't been mindlessly attacking—it had been herding her, driving her into a corner where all her nimbleness would be useless.
The monster drew back one terrible claw just as another prism of blue light sealed around it, trapping the blow mid-air. Inga, from the regrouping Omenseekers, worked that lantern light into another spell of holding. #emph[Nice one, Rune-Eyes. ] Another prism locked the other talon in place. She was holding it, if only for a moment.
Then the monster did something that surprised her: it tore its own arm off, leaving the trapped hand floating in the air, and swung at Kaya with the stump, the muscles twitching and reaching for her.
#emph[Don't touch it] , she thought. Only one way to go, then.
Kaya fell back into the cave wall, the cold shock of phasing ripping through her entire body. It was only for a moment—but what a long moment it seemed. Her heart stopped. Everything that made her alive, that made her #emph[Kaya] , gone gray and faded.
Then she was tumbling back onto the cave floor, a few feet to the monster's left. She saw it pivot, those heavy simian legs propelling it toward her, and Kaya fought to restart her lungs. #emph[Get up. Get up!]
"Enough!" bellowed a voice, echoing off the walls of the cave. To Kaya's surprise and relief, the creature actually slowed, its attention pulled toward the sound for a moment. That was enough; she jammed all the arcane power she could muster into her blade and lunged, cutting low, right through one of the monster's legs.
#emph[That voice] , she thought, tucking into a roll on the other side of the howling creature, coming up into a fighting stance. It sounded familiar, and yet~
It was only then that she noticed the pavonine, shifting radiance that now filled the cave. She looked back at the Omenseekers and saw Asi.
#figure(image("001_Episode 1: Travelers/04.jpg", width: 100%), caption: [Alrund, God of the Cosmos | Art by: <NAME>anner], supplement: none, numbering: none)
No—not Asi. Not exactly. His hood was thrown back, and from his eyes spilled that strange light illuminating the cavern walls, a shifting pattern of greens and blues and purples. Not just a charming old man, then. Or, not #emph[just ] that.
"Never have I seen such filth dare to desecrate these realms! Even the demons of Immersturm are not so foul."
Unclear, thought Kaya, how much of that was getting through to the monstrosity before them. Its leg gone, crumbling to ash, it had balanced itself on its three remaining limbs while the smaller hands stayed folded up near its chest. Hunched over, it looked even more bestial than before. Kaya was no master hunter, but even she knew that an animal was always at its most dangerous when wounded.
The monster threw itself toward her yet again, but Kaya was ready this time. It was slowing down, now. She could get it on the next pass. One clean swipe through the neck should do it.
Suddenly, the monster crashed into—nothing. It stumbled back, then hurled its weight forward again. There was a deep thrum, and the air rippled where it made contact. A magical barrier, realized Kaya, and a damn strong one at that. Even she would have had trouble phasing through that.
She turned. Behind her, Asi had his arm outstretched, that coruscating energy rippling around his hand. The monster looked between her and Asi with something she thought she recognized as uncertainty. Then, with one more grinding roar, it turned to flee.
"Wait!" shouted Kaya. "Stop it!"
But it was too late. Loping forward with that strange three-legged gait, the monster ran straight for a section of the cave wall where all the fungal metal seemed to be spreading from. Without slowing, it threw its body into the silvery surface. Rather than stopping—or collapsing the cave on all their heads—it seemed to sink into the metal, as it if were a thick and viscous liquid. A moment later, it was a bulbous intermingling of flesh and ore, and a moment after that, it was gone.
Silence settled over the cave. The Omenseekers seemed to be shrinking back from the still-radiant Asi, shielding their eyes. Even Inga seemed shaken; those sightless white eyes stayed fixed on her former advisor.
"Alrund," whispered Inga. "I—I had heard the sagas, of course, but I never thought~"
"Indeed, Inga Rune-Eyes. It suits the gods, from time to time, to travel in mortal guise, so that we may observe Kaldheim without being observed in turn," said Asi, his voice deep, folded in unnatural echo. "And what I have seen concerns me greatly. Across the realms are—"
"You let it get away!" snapped Kaya, pushing her daggers sharply back into their sheaths.
Asi—Alrund? #emph[Whatever] —paused at that. Clearly no one had spoken to him in such a manner for many, many years.
"We had weakened it," Kaya said. "I saw it slowing down. Next time it will know we're coming. It will be ready for us. That thing's not as dumb as it looked."
"So you intend to pursue it further, even after seeing what it's capable of," said Alrund.
"Job's not done. And I've already been paid." It wasn't just professional courtesy, though she wasn't about to admit that in front of this whole crowd. That thing was dangerous—and, she was starting to suspect, not from around here. But that didn't make sense. Did planeswalkers come in that shade of ugly?
"The beast has already fled Bretagard. You cannot track it by normal means," said Alrund. "It moves between the realms, as the Cosmos Monsters do. Though I am certain that horror could not be counted among their number."
"Okay then. How do I follow it?" said Kaya. "You owe me, after all. For letting it escape in the first place."
That seemed to give the god some pause. "I must consult with my kin. There are too many riddles which need answering. But if you are set on pursuing that creature, the longship of Cosima will aid you in this quest. I will see to it."
Kaya heard more than a few gasps from the Omenseekers. Cosima—she'd featured in just about every prayer they'd made while at sea.
"You will find it docked in Sevalgr upon your return. I trust the Omenseekers will guide you back, though from there you will have to make your own way. The ship is~selective about its passengers, but it will keep you safe in your journey between realms."
"And how exactly am I supposed to know where I'm going? I'm not exactly an experienced sailor," said Kaya.
"Follow the light of Starnheim, atop the highest branches of the World Tree. It will guide you along whatever path you are meant to walk."
Kaya suppressed a sigh at that. Gods and their riddles. Just once she'd like a straightforward answer.
"I must be off." Alrund waved toward the wall of the cave. The stone seemed to ripple and melt into waves of undulating light; interweaving knotwork, beautiful and strobing lines in the same colors that emanated from Alrund, formed the outline of a door. Then the stone vanished, and in its place was—nothing. She could see lights in the distance, like the slow shifting of stars, but in between was nothing but vast, empty darkness. Suddenly, Kaya was very glad she had a magic boat to help her cross that gulf.
Alrund stepped toward the doorway he had created, then paused. "Inga Rune-Eyes. Kaya Far-Traveler. I fear the arrival of this creature is an omen—a sign of terrible things to come. In all my auguries, I see death and destruction throughout Kaldheim. I fear a Doomskar approaches—one unlike any in living memory."
A hush fell over the Omenseekers. For not the first time, Kaya felt a step behind. "Doomskar. That doesn't sound great," she said.
"A collision of the realms," said Inga. "And with it, inevitably, comes war and chaos. A time of great suffering."
#emph[Perfect] , thought Kaya bitterly. #emph[Hunt a monster. Save some townsfolk. Nice and simple—nothing like that mess in Ravnica.]
|
|
https://github.com/Mufanc/hnuslides-typst | https://raw.githubusercontent.com/Mufanc/hnuslides-typst/master/templates/end.typ | typst | #import "/utils/background.typ": bgimage
#import "/utils/fonts.typ": font
#let end = {
bgimage("/assets/images/bg-end.png")
set align(center + horizon)
text(size: 3em, font: font.HYYK, tracking: 1.5em, "谢谢观赏")
v(-1.5em)
text(size: 1.8em, font: font.KABEL, tracking: 0.25em, "THANKS FOR WATCHING")
}
|
|
https://github.com/noahjutz/AD | https://raw.githubusercontent.com/noahjutz/AD/main/uebungen/4/measure_table.typ | typst | #import "/config.typ": theme
#block(stroke: 1pt)[
#show table.cell.where(y: 0): strong
#table(
columns: 7,
align: (x, y) => {
if x == 0 or y in (0, 1) {center + horizon} else {right}
},
inset: (x, y) => {
if x == 0 or y in (0, 1) {4pt} else {(x: 4pt, y: 10pt)}
},
stroke: (x, y) => (
right: if x == 0 {black} else {theme.bg_trans},
bottom: if y == 1 {black} else {theme.bg_trans},
),
fill: (_, y) => {
if y == 4 {theme.success_trans}
},
table.header(
"",
table.cell(colspan: 2)[Bubblesort],
table.cell(colspan: 2)[Quicksort],
table.cell(colspan: 2)[Mergesort],
"", $n$, $t$, $n$, $t$, $n$, $t$
),
"lo", $2^14$, $50s$, $2^17$, $20s$, $2^22$, $57s$,
"hi", $2^15$, $>60s$, $2^18$, $0.3s$, $2^23$, $>60s$,
"=", $24K$, $46s$, $229K$, $24s$, $8M$, $46s$
)
]
|
|
https://github.com/frectonz/the-pg-book | https://raw.githubusercontent.com/frectonz/the-pg-book/main/book/194.%20ace.html.typ | typst | ace.html
Billionaires Build
December 2020As I was deciding what to write about next, I was surprised to find
that two separate essays I'd been planning to write were actually
the same.The first is about how to ace your Y Combinator interview. There
has been so much nonsense written about this topic that I've been
meaning for years to write something telling founders the truth.The second is about something politicians sometimes say � that the
only way to become a billionaire is by exploiting people � and why
this is mistaken.Keep reading, and you'll learn both simultaneously.I know the politicians are mistaken because it was my job to predict
which people will become billionaires. I think I can truthfully say
that I know as much about how to do this as anyone. If the key to
becoming a billionaire � the defining feature of billionaires �
was to exploit people, then I, as a professional billionaire scout,
would surely realize this and look for people who would be good at
it, just as an NFL scout looks for speed in wide receivers.But aptitude for exploiting people is not what Y Combinator looks
for at all. In fact, it's the opposite of what they look for. I'll
tell you what they do look for, by explaining how to convince
Y Combinator to fund you, and you can see for yourself.What YC looks for, above all, is founders who understand some group
of users and can make what they want. This is so important that
it's YC's motto: "Make something people want."A big company can to some extent force unsuitable products on
unwilling customers, but a startup doesn't have the power to do
that. A startup must sing for its supper, by making things that
genuinely delight its customers. Otherwise it will never get off
the ground.Here's where things get difficult, both for you as a founder and
for the YC partners trying to decide whether to fund you. In a
market economy, it's hard to make something people want that they
don't already have. That's the great thing about market economies.
If other people both knew about this need and were able to satisfy
it, they already would be, and there would be no room for your
startup.Which means the conversation during your YC interview will have to
be about something new: either a new need, or a new way to satisfy
one. And not just new, but uncertain. If it were certain that the
need existed and that you could satisfy it, that certainty would
be reflected in large and rapidly growing revenues, and you wouldn't
be seeking seed funding.So the YC partners have to guess both whether you've discovered a
real need, and whether you'll be able to satisfy it. That's what they
are, at least in this part of their job: professional guessers.
They have 1001 heuristics for doing this, and I'm not going to tell
you all of them, but I'm happy to tell you the most important ones,
because these can't be faked; the only way to "hack" them would be
to do what you should be doing anyway as a founder.The first thing the partners will try to figure out, usually, is
whether what you're making will ever be something a lot of people
want. It doesn't have to be something a lot of people want now.
The product and the market will both evolve, and will influence
each other's evolution. But in the end there has to be something
with a huge market. That's what the partners will be trying to
figure out: is there a path to a huge market?
[1]Sometimes it's obvious there will be a huge market. If
Boom manages
to ship an airliner at all, international airlines will have to buy
it. But usually it's not obvious. Usually the path to a huge market
is by growing a small market. This idea is important enough that
it's worth coining a phrase for, so let's call one of these small
but growable markets a "larval market."The perfect example of a larval market might be Apple's market when
they were founded in 1976. In 1976, not many people wanted their
own computer. But more and more started to want one, till now every
10 year old on the planet wants a computer (but calls it a "phone").The ideal combination is the group of founders who are
"living in
the future" in the sense of being at the leading edge of some kind
of change, and who are building something they themselves want.
Most super-successful startups are of this type. <NAME>
wanted a computer. <NAME> wanted to engage online with his
college friends. Larry and Sergey wanted to find things on the web.
All these founders were building things they and their peers wanted,
and the fact that they were at the leading edge of change meant
that more people would want these things in the future.But although the ideal larval market is oneself and one's peers,
that's not the only kind. A larval market might also be regional,
for example. You build something to serve one location, and then
expand to others.The crucial feature of the initial market is that it exist. That
may seem like an obvious point, but the lack of it is the biggest
flaw in most startup ideas. There have to be some people who want
what you're building right now, and want it so urgently that they're
willing to use it, bugs and all, even though you're a small company
they've never heard of. There don't have to be many, but there have
to be some. As long as you have some users, there are straightforward
ways to get more: build new features they want, seek out more people
like them, get them to refer you to their friends, and so on. But
these techniques all require some initial seed group of users.So this is one thing the YC partners will almost certainly dig into
during your interview. Who are your first users going to be, and
how do you know they want this? If I had to decide whether to fund
startups based on a single question, it would be "How do you know
people want this?"The most convincing answer is "Because we and our friends want it."
It's even better when this is followed by the news that you've
already built a prototype, and even though it's very crude, your
friends are using it, and it's spreading by word of mouth. If you
can say that and you're not lying, the partners will switch from
default no to default yes. Meaning you're in unless there's some
other disqualifying flaw.That is a hard standard to meet, though. Airbnb didn't meet it.
They had the first part. They had made something they themselves
wanted. But it wasn't spreading. So don't feel bad if you don't hit
this gold standard of convincingness. If Airbnb didn't hit it, it
must be too high.In practice, the YC partners will be satisfied if they feel that
you have a deep understanding of your users' needs. And the Airbnbs
did have that. They were able to tell us all about what motivated
hosts and guests. They knew from first-hand experience, because
they'd been the first hosts. We couldn't ask them a question they
didn't know the answer to. We ourselves were not very excited about
the idea as users, but we knew this didn't prove anything, because
there were lots of successful startups we hadn't been excited about
as users. We were able to say to ourselves "They seem to know what
they're talking about. Maybe they're onto something. It's not growing
yet, but maybe they can figure out how to make it grow during YC."
Which they did, about three weeks into the batch.The best thing you can do in a YC interview is to teach the partners
about your users. So if you want to prepare for your interview, one of the best
ways to do it is to go talk to your users and find out exactly what
they're thinking. Which is what you should be doing anyway.This may sound strangely credulous, but the YC partners want to
rely on the founders to tell them about the market. Think about
how VCs typically judge the potential market for an idea. They're
not ordinarily domain experts themselves, so they forward the idea
to someone who is, and ask for their opinion. YC doesn't have time
to do this, but if the YC partners can convince themselves that the
founders both (a) know what they're talking about and (b) aren't
lying, they don't need outside domain experts. They can use the
founders themselves as domain experts when evaluating their own
idea.This is why YC interviews aren't pitches. To give as many founders
as possible a chance to get funded, we made interviews as short as
we could: 10 minutes. That is not enough time for the partners to
figure out, through the indirect evidence in a pitch, whether you
know what you're talking about and aren't lying. They need to dig
in and ask you questions. There's not enough time for sequential
access. They need random access.
[2]The worst advice I ever heard about how to succeed in a YC interview
is that you should take control of the interview and make sure to
deliver the message you want to. In other words, turn the interview
into a pitch. ⟨elaborate expletive⟩. It is so annoying when people
try to do that. You ask them a question, and instead of answering
it, they deliver some obviously prefabricated blob of pitch. It
eats up 10 minutes really fast.There is no one who can give you accurate advice about what to do
in a YC interview except a current or former YC partner. People
who've merely been interviewed, even successfully, have no idea of
this, but interviews take all sorts of different forms depending
on what the partners want to know about most. Sometimes they're all
about the founders, other times they're all about the idea. Sometimes
some very narrow aspect of the idea. Founders sometimes walk away
from interviews complaining that they didn't get to explain their
idea completely. True, but they explained enough.Since a YC interview consists of questions, the way to do it well
is to answer them well. Part of that is answering them candidly.
The partners don't expect you to know everything. But if you don't
know the answer to a question, don't try to bullshit your way out
of it. The partners, like most experienced investors, are professional
bullshit detectors, and you are (hopefully) an amateur bullshitter.
And if you try to bullshit them and fail, they may not even tell
you that you failed. So it's better to be honest than to try to
sell them. If you don't know the answer to a question, say you
don't, and tell them how you'd go about finding it, or tell them
the answer to some related question.If you're asked, for example, what could go wrong, the worst possible
answer is "nothing." Instead of convincing them that your idea is
bullet-proof, this will convince them that you're a fool or a liar.
Far better to go into gruesome detail. That's what experts do when
you ask what could go wrong. The partners know that your idea is
risky. That's what a good bet looks like at this stage: a tiny
probability of a huge outcome.Ditto if they ask about competitors. Competitors are rarely what
kills startups. Poor execution does. But you should know who your
competitors are, and tell the YC partners candidly what your relative
strengths and weaknesses are. Because the YC partners know that
competitors don't kill startups, they won't hold competitors against
you too much. They will, however, hold it against you if you seem
either to be unaware of competitors, or to be minimizing the threat
they pose. They may not be sure whether you're clueless or lying,
but they don't need to be.The partners don't expect your idea to be perfect. This is seed
investing. At this stage, all they can expect are promising hypotheses.
But they do expect you to be thoughtful and honest. So if trying
to make your idea seem perfect causes you to come off as glib or
clueless, you've sacrificed something you needed for something you
didn't.If the partners are sufficiently convinced that there's a path to
a big market, the next question is whether you'll be able to find
it. That in turn depends on three things: the general qualities of
the founders, their specific expertise in this domain, and the
relationship between them. How determined are the founders? Are
they good at building things? Are they resilient enough to keep
going when things go wrong? How strong is their friendship?Though the Airbnbs only did ok in the idea department, they did
spectacularly well in this department. The story of how they'd
funded themselves by making Obama- and McCain-themed breakfast
cereal was the single most important factor in our decision to fund
them. They didn't realize it at the time, but what seemed to them
an irrelevant story was in fact fabulously good evidence of their
qualities as founders. It showed they were resourceful and determined,
and could work together.It wasn't just the cereal story that showed that, though. The whole
interview showed that they cared. They weren't doing this just for
the money, or because startups were cool. The reason they were
working so hard on this company was because it was their project.
They had discovered an interesting new idea, and they just couldn't
let it go.Mundane as it sounds, that's the most powerful motivator of all,
not just in startups, but in most ambitious undertakings: to be
genuinely interested in what
you're building. This is what really
drives billionaires, or at least the ones who become billionaires
from starting companies. The company is their project.One thing few people realize about billionaires is that all of them
could have stopped sooner. They could have gotten acquired, or found
someone else to run the company. Many founders do. The ones who
become really rich are the ones who keep working. And what makes
them keep working is not just money. What keeps them working is the
same thing that keeps anyone else working when they could stop if
they wanted to: that there's nothing else they'd rather do.That, not exploiting people, is the defining quality of people who
become billionaires from starting companies. So that's what YC looks
for in founders: authenticity. People's motives for starting startups
are usually mixed. They're usually doing it from some combination
of the desire to make money, the desire to seem cool, genuine
interest in the problem, and unwillingness to work for someone else.
The last two are more powerful motivators than the first two. It's
ok for founders to want to make money or to seem cool. Most do.
But if the founders seem like they're doing it just to make money
or just to seem cool, they're not likely to succeed on a big
scale. The founders who are doing it for the money will take the
first sufficiently large acquisition offer, and the ones who are
doing it to seem cool will rapidly discover that there are much
less painful ways of seeming cool.
[3]Y Combinator certainly sees founders whose m.o. is to exploit people.
YC is a magnet for them, because they want the YC brand. But when
the YC partners detect someone like that, they reject them. If bad
people made good founders, the YC partners would face a moral
dilemma. Fortunately they don't, because bad people make bad founders.
This exploitative type of founder is not going to succeed on a large
scale, and in fact probably won't even succeed on a small one,
because they're always going to be taking shortcuts. They see YC
itself as a shortcut.Their exploitation usually begins with their own cofounders, which
is disastrous, since the cofounders' relationship is the foundation
of the company. Then it moves on to the users, which is also
disastrous, because the sort of early adopters a successful startup
wants as its initial users are the hardest to fool. The best this
kind of founder can hope for is to keep the edifice of deception
tottering along until some acquirer can be tricked into buying it.
But that kind of acquisition is never very big.
[4]If professional billionaire scouts know that exploiting people is
not the skill to look for, why do some politicians think this is
the defining quality of billionaires?I think they start from the feeling that it's wrong that one person
could have so much more money than another. It's understandable
where that feeling comes from. It's in our DNA, and even in the DNA
of other species.If they limited themselves to saying that it made them feel bad
when one person had so much more money than other people, who would
disagree? It makes me feel bad too, and I think people who make a
lot of money have a moral obligation to use it for the common good.
The mistake they make is to jump from feeling bad that some people
are much richer than others to the conclusion that there's no
legitimate way to make a very large amount of money. Now we're
getting into statements that are not only falsifiable, but false.There are certainly some people who become rich by doing bad things.
But there are also plenty of people who behave badly and don't make
that much from it. There is no correlation � in fact, probably an
inverse correlation � between how badly you behave and how much
money you make.The greatest danger of this nonsense may not even be that it sends
policy astray, but that it misleads ambitious people. Can you imagine
a better way to destroy social mobility than by telling poor kids
that the way to get rich is by exploiting people, while the rich
kids know, from having watched the preceding generation do it, how
it's really done?I'll tell you how it's really done, so you can at least tell your
own kids the truth. It's all about users. The most reliable way to
become a billionaire is to start a company that
grows fast, and the
way to grow fast is to make what users want. Newly started startups
have no choice but to delight users, or they'll never even get
rolling. But this never stops being the lodestar, and bigger companies
take their eye off it at their peril. Stop delighting users, and
eventually someone else will.Users are what the partners want to
know about in YC interviews, and what I want to know about when I
talk to founders that we funded ten years ago and who are billionaires
now. What do users want? What new things could you build for them?
Founders who've become billionaires are always eager to talk about
that topic. That's how they became billionaires.Notes[1]
The YC partners have so much practice doing this that they
sometimes see paths that the founders themselves haven't seen yet.
The partners don't try to seem skeptical, as buyers in transactions
often do to increase their leverage. Although the founders feel
their job is to convince the partners of the potential of their
idea, these roles are not infrequently reversed, and the founders
leave the interview feeling their idea has more potential than they
realized.[2]
In practice, 7 minutes would be enough. You rarely change your
mind at minute 8. But 10 minutes is socially convenient.[3]
I myself took the first sufficiently large acquisition offer
in my first startup, so I don't blame founders for doing this.
There's nothing wrong with starting a startup to make money. You
need to make money somehow, and for some people startups are the
most efficient way to do it. I'm just saying that these are not the
startups that get really big.[4]
Not these days, anyway. There were some big ones during the
Internet Bubble, and indeed some big IPOs.Thanks to <NAME>, <NAME>, <NAME>, <NAME>, and
<NAME> for reading drafts of this.
|
|
https://github.com/metamuffin/typst | https://raw.githubusercontent.com/metamuffin/typst/main/tests/typ/compute/construct.typ | typst | Apache License 2.0 | // Test creation and conversion functions.
// Ref: false
---
// Compare both ways.
#test(rgb(0%, 30%, 70%), rgb("004db3"))
// Alpha channel.
#test(rgb(255, 0, 0, 50%), rgb("ff000080"))
// Test color modification methods.
#test(rgb(25, 35, 45).lighten(10%), rgb(48, 57, 66))
#test(rgb(40, 30, 20).darken(10%), rgb(36, 27, 18))
#test(rgb("#133337").negate(), rgb(236, 204, 200))
#test(white.lighten(100%), white)
---
// Test gray color conversion.
// Ref: true
#stack(dir: ltr, rect(fill: luma(0)), rect(fill: luma(80%)))
---
// Error for values that are out of range.
// Error: 11-14 number must be between 0 and 255
#test(rgb(-30, 15, 50))
---
// Error: 6-11 color string contains non-hexadecimal letters
#rgb("lol")
---
// Error: 5-7 missing argument: red component
#rgb()
---
// Error: 5-11 missing argument: blue component
#rgb(0, 1)
---
// Error: 21-26 expected integer or ratio, found boolean
#rgb(10%, 20%, 30%, false)
---
// Ref: true
#let envelope = symbol(
"🖂",
("stamped", "🖃"),
("stamped.pen", "🖆"),
("lightning", "🖄"),
("fly", "🖅"),
)
#envelope
#envelope.stamped
#envelope.pen
#envelope.stamped.pen
#envelope.lightning
#envelope.fly
---
// Error: 8-10 expected at least one variant
#symbol()
---
// Test conversion to string.
#test(str(123), "123")
#test(str(123, base: 3), "11120")
#test(str(-123, base: 16), "-7b")
#test(str(9223372036854775807, base: 36), "1y2p0ij32e8e7")
#test(str(50.14), "50.14")
#test(str(10 / 3).len() > 10, true)
---
// Error: 6-8 expected integer, float, label, or string, found content
#str([])
---
// Error: 17-19 base must be between 2 and 36
#str(123, base: 99)
---
// Error: 18-19 base is only supported for integers
#str(1.23, base: 2)
---
// Test the unicode function.
#test(str.from-unicode(97), "a")
#test(str.to-unicode("a"), 97)
---
// Error: 19-22 expected integer, found content
#str.from-unicode([a])
---
// Error: 17-21 expected exactly one character
#str.to-unicode("ab")
---
// Error: 19-21 0xffffffffffffffff is not a valid codepoint
#str.from-unicode(-1) // negative values are not valid
---
// Error: 19-27 0x110000 is not a valid codepoint
#str.from-unicode(0x110000) // 0x10ffff is the highest valid code point
---
#assert(range(2, 5) == (2, 3, 4))
---
// Test displaying of dates.
#test(datetime(year: 2023, month: 4, day: 29).display(), "2023-04-29")
#test(datetime(year: 2023, month: 4, day: 29).display("[year]"), "2023")
#test(
datetime(year: 2023, month: 4, day: 29)
.display("[year repr:last_two]"),
"23",
)
#test(
datetime(year: 2023, month: 4, day: 29)
.display("[year] [month repr:long] [day] [week_number] [weekday]"),
"2023 April 29 17 Saturday",
)
// Test displaying of times
#test(datetime(hour: 14, minute: 26, second: 50).display(), "14:26:50")
#test(datetime(hour: 14, minute: 26, second: 50).display("[hour]"), "14")
#test(
datetime(hour: 14, minute: 26, second: 50)
.display("[hour repr:12 padding:none]"),
"2",
)
#test(
datetime(hour: 14, minute: 26, second: 50)
.display("[hour], [minute], [second]"), "14, 26, 50",
)
// Test displaying of datetimes
#test(
datetime(year: 2023, month: 4, day: 29, hour: 14, minute: 26, second: 50).display(),
"2023-04-29 14:26:50",
)
// Test getting the year/month/day etc. of a datetime
#let d = datetime(year: 2023, month: 4, day: 29, hour: 14, minute: 26, second: 50)
#test(d.year(), 2023)
#test(d.month(), 4)
#test(d.weekday(), 6)
#test(d.day(), 29)
#test(d.hour(), 14)
#test(d.minute(), 26)
#test(d.second(), 50)
#let e = datetime(year: 2023, month: 4, day: 29)
#test(e.hour(), none)
#test(e.minute(), none)
#test(e.second(), none)
// Test today
#test(datetime.today().display(), "1970-01-01")
#test(datetime.today(offset: auto).display(), "1970-01-01")
#test(datetime.today(offset: 2).display(), "1970-01-01")
---
// Error: 10-12 at least one of date or time must be fully specified
#datetime()
---
// Error: 10-42 time is invalid
#datetime(hour: 25, minute: 0, second: 0)
---
// Error: 10-41 date is invalid
#datetime(year: 2000, month: 2, day: 30)
---
// Error: 26-35 missing closing bracket for bracket at index 0
#datetime.today().display("[year")
---
// Error: 26-39 invalid component name 'nothing' at index 1
#datetime.today().display("[nothing]")
---
// Error: 26-51 invalid modifier 'wrong' at index 6
#datetime.today().display("[year wrong:last_two]")
---
// Error: 26-34 expected component name at index 2
#datetime.today().display(" []")
---
// Error: 26-36 failed to format datetime in the requested format
#datetime.today().display("[hour]")
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.