Skip to content

Commit e9c4920

Browse files
committed
feat: syntax highligh
1 parent 9a31dd6 commit e9c4920

1 file changed

Lines changed: 23 additions & 20 deletions

File tree

undergradmath.typ

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,11 @@
8484
it.body + h(0.67em),
8585
)
8686

87-
// Black raw code
88-
#show raw.where(block: false): it => { it.text }
87+
#set raw(lang: "typm")
88+
#let monospace = text.with(
89+
font: "DejaVu Sans Mono",
90+
size: 0.8em
91+
)
8992

9093
// Two-column layout
9194
#show: rest => columns(2, rest)
@@ -130,14 +133,14 @@ The original version is available at #link("https://gitlab.com/jim.hefferon/unde
130133

131134
= Rule One
132135
Any mathematics at all, even a single character, gets a mathematical setting.
133-
Thus, for "the value of #eqn(alt: "x", $x$) is #eqn(alt: "7", $7$)" enter `the value of $x$ is $7$`.
136+
Thus, for "the value of #eqn(alt: "x", $x$) is #eqn(alt: "7", $7$)" enter ```typ the value of $x$ is $7$```.
134137

135138
= Template
136139
Your document should contain at least this.
137140

138141
#grid(
139142
"",
140-
```
143+
```typ
141144
-- document body here --
142145
```,
143146
)
@@ -163,7 +166,7 @@ Your document should contain at least this.
163166
)
164167

165168
= Calligraphic letters
166-
Use as in `$cal(A)$`.
169+
Use as in ```typ $cal(A)$```.
167170

168171
#eqn(
169172
alt: "calligraphic uppercase letters A through Z",
@@ -173,7 +176,7 @@ Use as in `$cal(A)$`.
173176

174177
// #show math.equation: set text(stylistic-set: 1)
175178
// Get script letters, such as $cal(P)$ from `$cal(P)$`, by changing the `stylistic-set` parameter of `text()` to the corresponding set.
176-
Get script letters by using `scr`, such as #eqn(alt: "script capital P", $scr(P)$) from `$scr(P)$`.
179+
Get script letters by using `scr`, such as #eqn(alt: "script capital P", $scr(P)$) from ```typ $scr(P)$```.
177180
See #link("https://typst.app/docs/reference/math/variants/#functions-scr")[`scr`] for more information.
178181

179182
= Greek
@@ -349,10 +352,10 @@ Get the set complement #eqn(alt: "complement of A", $A^(sans(c))$) with `A^(sans
349352
// The Math fonts provide the character \varnothing (⌀, U+2300), as an alternative to \emptyset (a slashed zero), through Character Variant cv01.
350353
// The fontsetup package provides the option ‘varnothing’ to easily switch to the alternative character.
351354

352-
/ Remark: Using `diameter` for `\varnothing` may cause some confusion.
353-
However, in #LaTeX, the `\varnothing` provided through Character Variant `cv01` is also `diameter`
355+
/ Remark: Using `diameter` for ```tex \varnothing``` may cause some confusion.
356+
However, in #LaTeX, the ```tex \varnothing``` provided through Character Variant #monospace[cv01] is also `diameter`
354357
(see #link("http://mirrors.ctan.org/fonts/newcomputermodern/doc/newcm-doc.pdf")[newcm #{ sym.section }14.5]).
355-
So a simple solution with the default math font _New Computer Modern Math_ is to define a new symbol `varnothing` with `#let varnothing = math.diameter`.
358+
So a simple solution with the default math font _New Computer Modern Math_ is to define a new symbol `varnothing` with ```typ #let varnothing = math.diameter```.
356359
Other solutions can be found in #link("https://sitandr.github.io/typst-examples-book/book/basics/math/symbols.html#empty-set")[Typst Examples Book].
357360

358361
= Decorations
@@ -497,9 +500,9 @@ Just type them!
497500

498501
#let cosec = math.op("cosec")
499502

500-
If an operator you wish to use does not exist, you can create one using `math.op`. For example, to create the #eqn(alt: "cosecant", $cosec$) operator:
503+
If an operator you wish to use does not exist, you can create one using ```typc math.op```. For example, to create the #eqn(alt: "cosecant", $cosec$) operator:
501504

502-
```
505+
```typ
503506
#let cosec = math.op("cosec")
504507
$ cosec x = 1/(sin x) $
505508
```
@@ -635,7 +638,7 @@ $ cosec x = 1/(sin x) $
635638
Use `a divides b` for the divides relation, #eqn(alt: "a divides b", $a divides b$), and `a divides.not b` for the negation, #eqn(alt: "a does not divide b", $a divides.not b$).
636639
Use `|` to get set builder notation #eqn(alt: "the set of all a in S such that a is odd", ${a in S | a "is odd"}$) with `{a in S | a "is odd"}`.
637640

638-
= Arrows
641+
#block(sticky: true)[= Arrows]
639642
#align(
640643
center,
641644
table(
@@ -847,15 +850,15 @@ Get a matrix with the `mat` function. You can pass an array to it.
847850
$ mat(a, b; c, d) $,
848851
),
849852
[
850-
```
853+
```typ
851854
$ mat(a, b; c, d) $
852855
```
853856
],
854857
),
855858
)
856859

857860
In Typst, #link("https://typst.app/docs/reference/foundations/array")[array] is a sequence of values,
858-
while in #LaTeX, array is a matrix without fences, which is `$mat(delim: #none, ..)$` in Typst.
861+
while in #LaTeX, array is a matrix without fences, which is ```typ $mat(delim: #none, ..)$``` in Typst.
859862

860863
For the determinant use `|A|`, text operator #eqn(alt: "determinant", $det$) `det` or `mat(delim: "|", ..)`.
861864

@@ -892,10 +895,10 @@ Improve #eqn(alt: "square root of two times x", $sqrt(2) x$) to #eqn(alt: "squar
892895
Slightly wider are `med` and `thick` (the three are in ratio #eqn(alt: "3 to 4 to 5", $3 : 4 : 5$)).
893896
Bigger space are: `quad` for #eqn(alt: "A right arrow, followed by a quad space, then a left arrow. The quad space is about the width of the capital letter 'M'.", box[$-> quad <-$]) and `wide` for #eqn(alt: "A right arrow, followed by a wide space, then a left arrow. The wide space is about twice the width of the capital letter 'M'.", $-> wide <-$), which are useful between parts of a display.
894897
Get arbitrary space with the `h` function.
895-
For example, use `#h(-0.1667em)` for `\!` in #LaTeX.
898+
For example, use `#h(-0.1667em)` for ```tex \!``` in #LaTeX.
896899

897900
= Displayed equations
898-
Display equations in a block level using `$ ... $` with at least one space separating the math content and the `$`.
901+
Display equations in a block level using ```typ $ ... $``` with at least one space separating the math content and the #monospace[\$].
899902

900903
#align(
901904
center,
@@ -908,7 +911,7 @@ Display equations in a block level using `$ ... $` with at least one space separ
908911
$ S = k dot lg W $,
909912
),
910913
[
911-
```
914+
```typ
912915
$ S = k dot lg W $
913916
```
914917
],
@@ -931,7 +934,7 @@ You can break into multiple lines.
931934
$,
932935
),
933936
[
934-
```
937+
```typ
935938
$ sin(x) = x - x^3 / 3! \
936939
+ x^5 / 5! - dots.h.c $
937940
```
@@ -954,15 +957,15 @@ Align equations using `&`
954957
nabla dot bold(B) & = 0
955958
$,
956959
),
957-
```
960+
```typ
958961
$ nabla dot bold(D) &= rho \
959962
nabla dot bold(B) &= 0 $
960963
```,
961964
),
962965
)
963966

964967
(the left or right side of an alignment can be empty).
965-
Get a numbered version by `#set math.equation(numbering: ..)`.
968+
Get a numbered version by ```typ #set math.equation(numbering: ..)```.
966969

967970
= Calculus examples
968971
The last three here are display style.

0 commit comments

Comments
 (0)