-
Notifications
You must be signed in to change notification settings - Fork 4
/
guide.typ
158 lines (115 loc) · 4.88 KB
/
guide.typ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#import "@preview/typographix-polytechnique-reports:0.1.6" as template
#show: template.apply
// Specific rules for the guide
#show link: set text(blue)
#let source = s => {
block(width: 100%)[#{
set align(left)
text(font: "New Computer Modern Sans", weight: "bold")[Source code :]
v(-0.5em)
pad(left: 5%)[#block(fill: rgb("f5f5f5"), width: 100%, inset: 10pt)[#raw(s, lang: "typ")]]
set align(center)
v(0.2em)
line(length: 50%, stroke: 0.8pt + rgb("d0d0d0"))
v(0.5em)
}]
}
#let typst-rendering(d) = {
block[#text(font: "New Computer Modern Sans", weight: "bold")[Typst rendering :]]
pad(left: 5%)[#block(fill: rgb("f5f5f5"), inset: 10pt, width: 100%)[#eval(d, mode: "markup")]]
source(d)
}
// Defining variables for the cover page and PDF metadata
#let title = [Guide for Typst #linebreak() Polytechnique package]
#let subtitle = "A modern alternative to LaTeX"
#let logo = image("assets/logo-x.svg")
#let short_title = "package guide"
#let authors = ("Rémi Germe")
#let date_start = datetime(year: 2024, month: 07, day: 05)
#let date_end = datetime(year: 2024, month: 08, day: 05)
#set text(lang: "en")
// Beginning of the content
#template.cover.cover(title, authors, date_start, date_end, subtitle: subtitle, logo: logo)
#pagebreak()
#outline(title: [Guide content], indent: 1em, depth: 2)
#pagebreak()
= Discovering Typst and the template
#typst-rendering(
"Typst is a user-friendlier alternative to LaTeX. Check out #link(\"https://github.com/remigerme/typst-polytechnique/blob/main/guide.typ\")[this pdf source] to see how it was generated."
)
== Headings
#typst-rendering("=== Level 3 heading")
Use only one (resp. two) `=` for level 1 (resp. 2) heading (and so on).
#typst-rendering(
"#heading(level: 3, numbering: none)[Level 3 heading without numbering]
==== Level 4 heading"
)
== Cover page
```typc
// Defining variables for the cover page and PDF metadata
// Main title on cover page
#let title = [Guide for Typst #linebreak() Polytechnique package]
// Subtitle on cover page
#let subtitle = "A modern alternative to LaTeX"
// Logo on cover page
#let logo = none // instead of none set to image("path/to/my-logo.png")
#let logo-horizontal = true // set to true if the logo is squared or horizontal, set to false if not
// Short title on headers
#let short-title = "package guide"
#let author = "Rémi Germe"
#let date-start = datetime(year: 2024, month: 06, day: 05)
#let date-end = datetime(year: 2024, month: 09, day: 05)
// Set to true for bigger margins and so on (good luck with your report)
#let despair-mode = false
#set text(lang: "en")
// Set document metadata
#set document(title: title, author: author, date: datetime.today())
#show: template.apply.with(despair-mode: despair-mode)
// Cover page
#template.cover.cover(title, author, date-start, date-end, subtitle: subtitle, logo: logo, logo-horizontal: logo-horizontal)
#pagebreak()
```
Set text lang to `fr` if you want the months in French. \
You can also specify `short-month: true` in the call to cover to get month abbreviations.
== Doing some math
#typst-rendering(
"Inline : $P V = n R T$ and $f : x -> 1/18 x^4$, $forall x in RR, f(x) >= 0$."
)
#typst-rendering(
"Block (note space after opening \$ and before closing \$) : $ f(b) = sum_(k=0)^n (b-a)^k / k! f^((k))(a) + integral_a^b (b-t)^n / n! f^((n+1))(t) dif t $"
)
== Table of contents
You can generate a table of contents using `#outline()`. Here are useful parameters you can specify :
- `indent`
- `depth`
- `title` (put the title inside brackets : [title])
For example, the previous table of contents was generated using :
```typc
#outline(title: [Guide content], indent: 1em, depth: 2)
```
== Cite an article
#typst-rendering(
"You can cite an article, a book or something like @example-turing. Just see the `#bibliography` command below - you need a `.bib` file containing the bibliography."
)
== Numbering pages
Useful commands to number pages (learn about #link("https://typst.app/docs/reference/model/numbering/")[numbering patterns]) :
```typc
#set page(numbering: none) // to disable page numbering
#set page(numbering: "1 / 1") // or another numbering pattern
#counter(page).update(1) // to reset the page counter to 1
```
*Warning* : put these instructions at the very beginning of a page, otherwise it will cause a pagebreak.
#typst-rendering("#lorem(25)")
== Dummy text with lorem
You can generate dummy text with the `#lorem(n)` command. For example : #lower(lorem(10))
#pagebreak()
= Modify the template
== Contribute
Contributions are welcomed ! Check out the #link("https://github.com/remigerme/typst-polytechnique")[source repository].
You can also learn more about #link("https://github.com/typst/packages")[Typst packages] release pipeline.
#pagebreak()
#bibliography("assets/example.bib")
#pagebreak()
#show: template.heading.appendix.with(title: "Appendix")
= Some details about something
You can also use appendix if needed.