Skip to content

Commit ec79cbe

Browse files
committed
experiments with typst
Signed-off-by: lucasew <[email protected]>
1 parent 5305cb8 commit ec79cbe

File tree

4 files changed

+175
-0
lines changed

4 files changed

+175
-0
lines changed

typst/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
out.pdf

typst/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# command to build
2+
nix run github:typst/typst -- input.typ -w out.pdf

typst/demo.typ

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#set par(justify: true, leading: 0.52em)
2+
#set text(font: "Linux Libertine", size: 12pt)
3+
4+
#let footnote_state = state("footnote", ())
5+
#let footnote_counter = counter("footnote")
6+
7+
#let footnote(text) = {
8+
locate(loc => {
9+
let counter = footnote_counter.at(loc)
10+
footnote_state.update(old => {
11+
old.push((
12+
index: counter.first(),
13+
text: text,
14+
page: loc.page()
15+
))
16+
old
17+
})
18+
[ #super[ [#counter.first()] ] ]
19+
})
20+
footnote_counter.step()
21+
}
22+
23+
24+
#set page(
25+
paper: "us-letter",
26+
header: align(right, [
27+
#lorem(5)
28+
]),
29+
footer: [
30+
#locate(loc => {
31+
let state = footnote_state.at(loc)
32+
for x in state.filter(x => x.page == loc.page()) {
33+
[ #x.index. #x.text #linebreak() ]
34+
}
35+
})
36+
37+
Opa #counter(page).display()
38+
],
39+
numbering: "1"
40+
)
41+
#set heading(numbering: "1.a")
42+
43+
44+
#show "ipsum": name => box[
45+
#box[
46+
#image("//home/lucasew/.icons/tixati.png", height: 0.7em)
47+
]
48+
#name
49+
]
50+
51+
52+
#show heading: it => [
53+
#set align(center)
54+
#set text(16pt, weight: "regular")
55+
#block(smallcaps(it.body))
56+
]
57+
58+
#let sum(x, y) = [A soma de #x e #y é #(x + y)]
59+
60+
= Teste
61+
#sum(6, 9)
62+
63+
#footnote("Teste")
64+
#footnote("Teste")
65+
#footnote("Teste")
66+
67+
Tixati é um programa. Teste tixati.
68+
69+
#lorem(20)
70+
71+
#columns(2, [
72+
== Teste
73+
74+
#lorem(20)
75+
76+
#figure(
77+
image("//home/lucasew/.icons/tixati.png", width: 50%),
78+
) <favicon>
79+
])
80+
81+
#pagebreak()
82+
83+
#footnote("Teste")
84+
85+
== Eoq
86+
87+
#counter(page).display()
88+
89+
$x^2$
90+
91+
#lorem(20)
92+
93+
#lorem(20)
94+
95+
```python
96+
import os
97+
from sys import stdout
98+
```
99+
100+
```nix
101+
pkgs = import <nixpkgs> {};
102+
```
103+
104+
```json
105+
{
106+
"name": "Lucas",
107+
}
108+
```

typst/input.typ

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#let footnote_state = state("footnote", ())
2+
#let footnote_counter = counter("footnote")
3+
4+
#let footnote(text) = {
5+
locate(loc => {
6+
let counter = footnote_counter.at(loc)
7+
footnote_state.update(old => {
8+
old.push((
9+
index: counter.first(),
10+
text: text,
11+
page: loc.page()
12+
))
13+
old
14+
})
15+
[ #super[ [#counter.first()] ] ]
16+
})
17+
footnote_counter.step()
18+
}
19+
20+
21+
#set page(
22+
paper: "a4",
23+
header: align(right, [
24+
#lorem(5)
25+
]),
26+
footer: [
27+
/* Footnotes of this page */
28+
#locate(loc => {
29+
let state = footnote_state.at(loc)
30+
for x in state.filter(x => x.page == loc.page()) {
31+
[ #x.index. #x.text #linebreak() ]
32+
}
33+
})
34+
35+
#counter(page).display()
36+
],
37+
numbering: "1"
38+
)
39+
40+
#let sum(x, y) = [A soma de #x e #y é #(x + y)]
41+
42+
= Teste
43+
#sum(6, 9)
44+
45+
#lorem(50)
46+
#footnote("Teste")
47+
#lorem(100)
48+
#footnote("Teste")
49+
#lorem(50)
50+
51+
#pagebreak()
52+
53+
#lorem(100)
54+
#footnote("Teste")
55+
#lorem(100)
56+
57+
```python
58+
import os
59+
from sys import stdout
60+
```
61+
62+
```nix
63+
pkgs = import <nixpkgs> {};
64+
```

0 commit comments

Comments
 (0)