-
Notifications
You must be signed in to change notification settings - Fork 13
/
manual_examples.typ
206 lines (158 loc) · 4.22 KB
/
manual_examples.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#import "manual_template.typ": *
#import "theorems.typ": *
#show: thmrules
#show: project.with(
title: "typst-theorems",
authors: (
"sahasatvik",
),
url: "https://github.com/sahasatvik/typst-theorems"
)
= Introduction
This document only includes the examples given in the manual; each one of
these has been explained in full detail there.
= Feature demonstration
#let theorem = thmbox(
"theorem",
"Theorem",
fill: rgb("#e8e8f8")
)
#theorem("Euclid")[
There are infinitely many primes.
] <euclid>
#let lemma = thmbox(
"theorem",
"Lemma",
fill: rgb("#efe6ff")
)
#lemma[
If $n$ divides both $x$ and $y$, it also divides $x - y$.
]
#let corollary = thmbox(
"corollary",
"Corollary",
base: "theorem",
fill: rgb("#f8e8e8")
)
#corollary(numbering: "1.1")[
If $n$ divides two consecutive natural numbers, then $n = 1$.
]
== Proofs
#let proof = thmproof("proof", "Proof")
#proof([of @euclid])[
Suppose to the contrary that $p_1, p_2, dots, p_n$ is a finite enumeration
of all primes. Set $P = p_1 p_2 dots p_n$. Since $P + 1$ is not in our list,
it cannot be prime. Thus, some prime factor $p_j$ divides $P + 1$. Since
$p_j$ also divides $P$, it must divide the difference $(P + 1) - P = 1$, a
contradiction.
]
#theorem[
There are arbitrarily long stretches of composite numbers.
]
#proof[
For any $n > 2$, consider $
n! + 2, quad n! + 3, quad ..., quad n! + n #qedhere
$
]
== Suppressing numbering
#let example = thmplain(
"example",
"Example"
).with(numbering: none)
#example[
The numbers $2$, $3$, and $17$ are prime.
]
#lemma(numbering: none)[
The square of any even number is divisible by $4$.
]
#lemma[
The square of any odd number is one more than a multiple of $4$.
]
#lemma(number: "42")[
The square of any natural number cannot be two more than a multiple of 4.
]
== Limiting depth
#let definition = thmbox(
"definition",
"Definition",
base_level: 1,
stroke: rgb("#68ff68") + 1pt
)
#definition("Prime numbers")[
A natural number is called a _prime number_ if it is greater than $1$ and
cannot be written as the product of two smaller natural numbers. <prime>
]
#definition("Composite numbers")[
A natural number is called a _composite number_ if it is greater than $1$
and not prime.
]
#example(base_level: 4, numbering: "1.1")[
The numbers $4$, $6$, and $42$ are composite.
]
== Custom formatting
#let proof-custom = thmplain(
"proof",
"Proof",
base: "theorem",
titlefmt: smallcaps,
bodyfmt: body => [
#body #h(1fr) $square$
]
).with(numbering: none)
#lemma[
All even natural numbers greater than 2 are composite.
]
#proof-custom[
Every even natural number $n$ can be written as the product of the natural
numbers $2$ and $n\/2$. When $n > 2$, both of these are smaller than $2$
itself.
]
#let notation = thmenv(
"notation", // identifier
none, // base - do not attach, count globally
none, // base_level - use the base as-is
(name, number, body, color: black) => [
// fmt - format content using the environment name, number, body, and an optional color
#text(color)[#h(1.2em) *Notation (#number) #name*]:
#h(0.2em)
#body
#v(0.5em)
]
).with(numbering: "I") // use Roman numerals
#notation[
The variable $p$ is reserved for prime numbers.
]
#notation("for Reals", color: green)[
The variable $x$ is reserved for real numbers.
]
#lemma(title: "Lem.", stroke: 1pt)[
All multiples of 3 greater than 3 are composite.
]
== Labels and references <references>
#pad(
left: 1.2em,
[
Recall that there are infinitely many prime numbers via @euclid.
]
)
#pad(
left: 1.2em,
[
You can reference future environments too, like @oddprime[Cor.].
]
)
#lemma(supplement: "Lem.", refnumbering: "(1.1)")[
All primes apart from $2$ and $3$ are of the form $6k plus.minus 1$.
] <primeform>
You can modify the supplement and numbering to be used in references, like @primeform.
== Overriding `base`
#let remark = thmplain("remark", "Remark", base: "heading")
#remark[
There are infinitely many composite numbers.
]
#corollary[
All primes greater than $2$ are odd.
] <oddprime>
#remark(base: "corollary")[
Two is a _lone prime_.
]