tex2typst 0.3.27-beta.1 → 0.3.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,89 @@
1
+ title: integration-tex2typst
2
+ cases:
3
+ - title: base of natural logarithm
4
+ tex: \mathrm{e} \overset{\text{def}}{=} \lim_{{n \to \infty}} \left(1 + \frac{1}{n}\right)^n
5
+ typst: upright(e) eq.def lim_(n -> infinity) (1 + 1/n)^n
6
+ - title: Euler's product formula
7
+ tex: \prod_{p} \frac{1}{1-p^{-s}} = \sum_{n=1}^{\infty} \frac{1}{n^s}
8
+ typst: product_p 1/(1 - p^(-s)) = sum_(n = 1)^infinity 1/(n^s)
9
+ - title: Fermat's little theorem
10
+ tex: a^{p-1} \equiv 1 \mod{p}
11
+ typst: a^(p - 1) equiv 1 mod p
12
+ - title: Maxwell's equations
13
+ tex: |-
14
+ \begin{aligned}
15
+ \nabla \times \boldsymbol{H} &= \boldsymbol{J} + \frac{\partial \boldsymbol{D}}{\partial t} \\
16
+ \nabla \times \boldsymbol{E} &= -\frac{\partial \boldsymbol{B}}{\partial t} \\
17
+ \nabla \cdot \boldsymbol{B} &= 0 \\
18
+ \nabla \cdot \boldsymbol{D} &= \rho
19
+ \end{aligned}
20
+ typst: |-
21
+ nabla times bold(H) &= bold(J) + (diff bold(D))/(diff t) \
22
+ nabla times bold(E) &= - (diff bold(B))/(diff t) \
23
+ nabla dot.op bold(B) &= 0 \
24
+ nabla dot.op bold(D) &= rho
25
+ - title: chemical equation example - bromoethane to ethanol
26
+ tex: \rm{CH_3CH_2Br} + \rm{OH}^- \longrightarrow \rm{CH_3CH_2OH} + \rm{Br}^-
27
+ typst: upright(C H_3 C H_2 B r) + upright(O H)^- --> upright(C H_3 C H_2 O H) + upright(B r)^-
28
+ - title: harmonic series
29
+ tex: \sum_{k=1}^n \frac{1}{k} = \ln n + \gamma + O\left(\frac{1}{n}\right)
30
+ typst: sum_(k = 1)^n 1/k = ln n + gamma + O(1/n)
31
+ - title: Euler's complex exponential formula
32
+ tex: \mathrm{e}^{\mathrm{i} x} = \cos x + \mathrm{i} \sin x
33
+ typst: upright(e)^(upright(i) x) = cos x + upright(i) sin x
34
+ - title: Gauss's divergence theorem
35
+ tex: \iiint_{\Omega} \operatorname{div}(\vec{F}) \mathrm{d}V = \oiint_{\partial \Omega} \vec{F} \cdot \mathrm{d}\vec{S}
36
+ typst: integral.triple_Omega op("div")(arrow(F)) dif V = integral.surf_(diff Omega) arrow(F) dot.op dif arrow(S)
37
+ - title: Stokes' theorem
38
+ tex: \iint_{\Sigma} \operatorname{curl}(\vec{F}) \cdot \mathrm{d}\vec{S} = \oint_{\partial \Sigma} \vec{F} \times \mathrm{d}\vec{l}
39
+ typst: integral.double_Sigma op("curl")(arrow(F)) dot.op dif arrow(S) = integral.cont_(diff Sigma) arrow(F) times dif arrow(l)
40
+ - title: Prime number theorem
41
+ tex: \pi(x) \sim \frac{x}{\log x}
42
+ typst: pi(x) ~ x/(log x)
43
+ - title: current-voltage characteristics of n-channel enhancement MOSFETs
44
+ tex: i_D = \mu_n C_\text{ox} \frac{W}{L} \left[ (v_\text{GS} - V_t)v_\text{DS} - \frac{1}{2} v_\text{DS}^2 \right]
45
+ typst: i_D = mu_n C_"ox" W/L [(v_"GS" - V_t) v_"DS" - 1/2 v_"DS"^2]
46
+ - title: Black-Scholes formula for option pricing
47
+ tex: |-
48
+ \begin{aligned}
49
+ C &= N(d_1) S_t - N(d_2) K e^{-rt} \\
50
+ d_1 &= \frac{\ln \frac{S_t}{K} + (r + \frac{\sigma^2}{2}) t}{\sigma \sqrt{t}} \\
51
+ d_2 &= d_1 - \sigma\sqrt{t}
52
+ \end{aligned}
53
+ typst: |-
54
+ C &= N(d_1) S_t - N(d_2) K e^(-r t) \
55
+ d_1 &= (ln (S_t)/K +(r + (sigma^2)/2) t)/(sigma sqrt(t)) \
56
+ d_2 &= d_1 - sigma sqrt(t)
57
+ - title: Cauchy's integral formula
58
+ tex: f(z_0) = \frac{1}{2\pi \mathrm{i}} \oint_{C} \frac{f(z)}{z-z_0}\, \mathrm{d} z
59
+ typst: f(z_0) = 1/(2 pi upright(i)) integral.cont_C (f(z))/(z - z_0) thin dif z
60
+ - title: determinant of a Vandermonde matrix
61
+ tex: |-
62
+ \begin{vmatrix}
63
+ 1 & 1 & \dots & 1 \\
64
+ x_1 & x_2 & \dots & x_n \\
65
+ x_1^2 & x_2^2 & \dots & x_n^2 \\
66
+ \vdots & \vdots & \ddots & \vdots \\
67
+ x_1^{n-1} & x_2^{n-1} & \dots & x_n^{n-1}
68
+ \end{vmatrix}
69
+ = \prod_{1 \leq i < j \leq n} (x_j - x_i)
70
+ # TODO: There should no spaces after x_n and x_n^2
71
+ typst: |-
72
+ mat(delim: "|", 1, 1, ..., 1;
73
+ x_1, x_2, ..., x_n;
74
+ x_1^2, x_2^2, ..., x_n^2;
75
+ dots.v, dots.v, dots.down, dots.v;
76
+ x_1^(n - 1), x_2^(n - 1), ..., x_n^(n - 1))
77
+ = product_(1 <= i < j <= n) (x_j - x_i)
78
+ - title: ReLU function
79
+ tex: |-
80
+ \operatorname{ReLU}(x) = \begin{cases}
81
+ x & \text{if } x > 0 \\
82
+ 0 & \text{if } x \leq 0
83
+ \end{cases}
84
+ typst: |-
85
+ op("ReLU")(x) = cases(x & "if " x > 0,
86
+ 0 & "if " x <= 0)
87
+ - title: attention mechanism
88
+ tex: \operatorname{Attention}(Q, K, V) = \operatorname{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right) V
89
+ typst: op("Attention")(Q, K, V) = op("softmax")((Q K^T)/sqrt(d_k)) V
@@ -0,0 +1,179 @@
1
+ title: Bidirectional conversion of structures
2
+ cases:
3
+ - title: a complex structure as script
4
+ # This doesn't actually need the extra brackets, but it is clearer!
5
+ tex: 'e_{f(x)}'
6
+ typst: e_(f(x))
7
+ - title: Nested scripts
8
+ tex: 'r_{s^+}'
9
+ typst: 'r_(s^+)'
10
+ - title: Text Functions
11
+ tex: '\text{diag}'
12
+ typst: '"diag"'
13
+ - title: Single Char Text
14
+ tex: \text{a}
15
+ typst: '"a"'
16
+ - title: Aligned
17
+ tex: |-
18
+ \begin{aligned}
19
+ a &= b \\
20
+ c &= d
21
+ \end{aligned}
22
+ typst: |-
23
+ a &= b \
24
+ c &= d
25
+ - title: An align mark & is at the beginning of a line
26
+ tex: |-
27
+ \begin{aligned}
28
+ & a &= b \\
29
+ & c &= d
30
+ \end{aligned}
31
+ typst: |-
32
+ & a &= b \
33
+ & c &= d
34
+ - title: matrix
35
+ tex: |-
36
+ m = \begin{matrix}
37
+ a & b \\
38
+ c & d \\
39
+ e & f
40
+ \end{matrix}
41
+ typst: |-
42
+ m = mat(delim: #none, a, b;
43
+ c, d;
44
+ e, f)
45
+ - title: pmatrix
46
+ tex: |-
47
+ m = \begin{pmatrix}
48
+ a & b \\
49
+ c & d
50
+ \end{pmatrix}
51
+ typst: |-
52
+ m = mat(a, b;
53
+ c, d)
54
+ - title: bmatrix
55
+ tex: |-
56
+ m = \begin{bmatrix}
57
+ a & b \\
58
+ c & d
59
+ \end{bmatrix}
60
+ typst: |-
61
+ m = mat(delim: "[", a, b;
62
+ c, d)
63
+ - title: Bmatrix
64
+ tex: |-
65
+ m = \begin{Bmatrix}
66
+ a & b \\
67
+ c & d
68
+ \end{Bmatrix}
69
+ typst: |-
70
+ m = mat(delim: "{", a, b;
71
+ c, d)
72
+ - title: vmatrix
73
+ tex: |-
74
+ m = \begin{vmatrix}
75
+ a & b \\
76
+ c & d
77
+ \end{vmatrix}
78
+ typst: |-
79
+ m = mat(delim: "|", a, b;
80
+ c, d)
81
+ - title: Vmatrix
82
+ tex: |-
83
+ m = \begin{Vmatrix}
84
+ a & b \\
85
+ c & d
86
+ \end{Vmatrix}
87
+ typst: |-
88
+ m = mat(delim: bar.v.double, a, b;
89
+ c, d)
90
+ - title: accent, symbol over variable
91
+ tex: \bar{y} \vec{x} \dot{y} \ddot{y} \tilde{a} \hat{a}
92
+ typst: macron(y) arrow(x) dot(y) dot.double(y) tilde(a) hat(a)
93
+ - title: underline, overline
94
+ tex: \underline{a} \overline{a} \underline{a + 1} \overline{a + 1}
95
+ typst: underline(a) overline(a) underline(a + 1) overline(a + 1)
96
+ - title: comment
97
+ tex: a + b % comment
98
+ typst: a + b // comment
99
+ - title: comment2
100
+ tex: a + b % comment % comment2
101
+ typst: a + b // comment % comment2
102
+ - title: comment3
103
+ tex: |-
104
+ a + b % co
105
+ c + d
106
+ e + f % co
107
+ g + h
108
+ typst: |-
109
+ a + b // co
110
+ c + d
111
+ e + f // co
112
+ g + h
113
+ - title: mod
114
+ tex: a^{p - 1} \equiv 1 \mod p
115
+ typst: a^(p - 1) equiv 1 mod p
116
+ - title: overset
117
+ tex: \overset{a}{+}
118
+ typst: limits(+)^a
119
+ - title: underset
120
+ tex: \underset{a}{+}
121
+ typst: limits(+)_a
122
+ - title: overset, special case 1
123
+ tex: \overset{\text{def}}{=}
124
+ typst: eq.def
125
+ - title: newline
126
+ tex: |-
127
+ a + b \\
128
+ c + d
129
+ typst: |-
130
+ a + b \
131
+ c + d
132
+ - title: leading sign
133
+ tex: -a
134
+ typst: -a
135
+ - title: Mathrm
136
+ tex: 'p_e = 1 - \mathrm{e}^{-t \lambda}'
137
+ typst: p_e = 1 - upright(e)^(-t lambda)
138
+ - title: decimals
139
+ tex: "3.14"
140
+ typst: "3.14"
141
+ - title: Cube root
142
+ tex: '\sqrt[3]{x}'
143
+ typst: root(3, x)
144
+ - title: floor and ceil
145
+ tex: \lfloor 1.2 \rfloor + \lceil 1.2 \rceil
146
+ typst: floor(1.2) + ceil(1.2)
147
+ - title: floor and ceil with overHigh
148
+ tex: \left \lfloor \frac{1}{2} \right \rfloor + \left \lceil \frac{1}{2} \right \rceil
149
+ typst: floor(1/2) + ceil(1/2)
150
+ # - title: norm
151
+ # tex: \|a \|^2
152
+ # typst: norm(a)^2
153
+ - title: norm with overHigh
154
+ tex: \left \|a + \frac{1}{3} \right \|^2
155
+ typst: norm(a + 1/3)^2
156
+ - title: left right angles
157
+ tex: \left\langle \frac{1}{2} \right\rangle
158
+ typst: lr(angle.l 1/2 angle.r)
159
+ - title: fractions as function argument
160
+ tex: g(\frac{1}{2})
161
+ typst: g(1/2)
162
+ - title: multiple arguments should join with a comma
163
+ tex: A(B(x, y))
164
+ typst: A(B(x, y))
165
+ - title: mathbb
166
+ tex: \mathbb{A} \mathbb{B} \mathbb{C} \mathbb{D} \mathbb{E} \mathbb{F} \mathbb{G} \mathbb{H} \mathbb{I} \mathbb{J} \mathbb{K} \mathbb{L} \mathbb{M} \mathbb{N} \mathbb{O} \mathbb{P} \mathbb{Q} \mathbb{R} \mathbb{S} \mathbb{T} \mathbb{U} \mathbb{V} \mathbb{W} \mathbb{X} \mathbb{Y} \mathbb{Z}
167
+ typst: AA BB CC DD EE FF GG HH II JJ KK LL MM NN OO PP QQ RR SS TT UU VV WW XX YY ZZ
168
+ - title: hspace
169
+ tex: \hspace{1cm}
170
+ typst: "#h(1cm)"
171
+ - title: leftright ()
172
+ tex: \left(a + \frac{1}{3} \right)
173
+ typst: (a + 1/3)
174
+ # - title: leftright {}
175
+ # tex: \left\{a + \frac{1}{3} \right\}
176
+ # typst: "{a + 1/3}"
177
+ - title: textcolor
178
+ tex: x = \textcolor{red}{a + y}
179
+ typst: "x = #text(fill: red)[$a + y$]"
@@ -0,0 +1,443 @@
1
+ # Some test cases are from https://github.com/curvenote/tex-to-typst/blob/1d0b121d162911f1c99b47171939e30656f49270/tests/math.yml (MIT License)
2
+ title: struct-tex2typst
3
+ cases:
4
+ - title: redundant spaces should be ignored
5
+ tex: 'p ( x ) = \frac{e^{-\lambda}\lambda^{x}}{ x ! }'
6
+ typst: p(x) = (e^(-lambda) lambda^x)/(x!)
7
+ - title: Simplified brackets
8
+ tex: 'e_f(x)'
9
+ typst: e_f (x)
10
+ - title: Comma inside function
11
+ tex: '\boldsymbol{j_x, j_y}'
12
+ typst: 'bold(j_x comma j_y)'
13
+
14
+ - title: Nested functions
15
+ tex: '\boldsymbol{m}_\text{ref}'
16
+ typst: 'bold(m)_"ref"'
17
+ - title: left and right brackets, not overHigh
18
+ tex: '\left[\boldsymbol{A} \right) \left\{b \right)'
19
+ typst: 'lr([bold(A))) lr({b))'
20
+ - title: dot as right bracket
21
+ tex: '\left\{ \frac{a}{b} \right.'
22
+ typst: 'lr(\{ a/b)'
23
+ - title: dot as left bracket
24
+ tex: '\left. \frac{a}{b} \right\}'
25
+ typst: 'lr(a/b })'
26
+ - title: left. and right.
27
+ tex: '\left. \frac{a}{b} \right.'
28
+ typst: 'lr(a/b)'
29
+ - title: lr
30
+ tex: \left|a + \frac{1}{3} \right|^2
31
+ typst: lr(|a + 1/3|)^2
32
+ - title: biglr
33
+ tex: \bigl|a + \frac{1}{3} \bigr|^2
34
+ typst: "|a + 1/3 |^2"
35
+ - title: bigm
36
+ tex: \dfrac{d}{dx}x^2\bigm{|}_{x=2}
37
+ typst: frac(d, d x) x^2 |_(x = 2)
38
+ - title: intop
39
+ tex: \intop_0^\infty x \text{d} x
40
+ typst: limits(integral)_0^infinity x "d" x
41
+ - title: bigglr
42
+ tex: \biggl|a + \frac{1}{3} \biggr|^2
43
+ typst: "|a + 1/3 |^2"
44
+ - title: symmetry left right
45
+ tex: \left\{ a \right\} \left( b \right) \left[ c \right]
46
+ typst: '{a}(b) [c]'
47
+ - title: symmetry bigl bigr
48
+ tex: \bigl\{ a \bigr\} \bigl( b \bigr) \bigl[ c \bigr]
49
+ typst: '{a}(b) [c]'
50
+ - title: symmetry biggl biggr
51
+ tex: \biggl\{ a \biggr\} \biggl( b \biggr) \biggl[ c \biggr]
52
+ typst: '{a}(b) [c]'
53
+ - title: symmetry Biggl Biggr
54
+ tex: \Biggl\{ a \Biggr\} \Biggl( b \Biggr) \Biggl[ c \Biggr]
55
+ typst: '{a}(b) [c]'
56
+ - title: paired delimiter commands
57
+ tex: \left(\bigl[\biggl\{a\biggr\}\bigr]\right)
58
+ typst: '([ {a}])'
59
+ - title: operatorname
60
+ tex: '\operatorname{diag} \text{diag}'
61
+ typst: 'op("diag") "diag"'
62
+ - title: operatorname1
63
+ tex: '\operatorname{a}'
64
+ typst: op("a")
65
+ - title: scripts
66
+ tex: '\boldsymbol{k}_{Av} \boldsymbol{k}^{Av}'
67
+ typst: 'bold(k)_(A v) bold(k)^(A v)'
68
+ - title: scripts
69
+ tex: |-
70
+ \boldsymbol{D}
71
+ \\
72
+ \boldsymbol{G}_{z}
73
+ typst: |-
74
+ bold(D)
75
+ \
76
+ bold(G)_z
77
+ - title: Complex equations with nested over/under braces
78
+ tex: |-
79
+ \begin{align*}
80
+ \overbrace{
81
+ \left[
82
+ \frac{1}{\Delta t}
83
+ \frac{\partial \boldsymbol{\theta}^{n+1}}{\partial\boldsymbol{\psi}^{n+1}}
84
+ -\boldsymbol{D}
85
+ \text{diag}\left( \boldsymbol{G} \boldsymbol{\psi}^{n+1} \right)
86
+ \frac{\partial \boldsymbol{k}_{Av}}{\partial\boldsymbol{\psi}^{n+1}}
87
+ -\boldsymbol{D}
88
+ \text{diag}\left( \boldsymbol{k}_{Av}(\boldsymbol{\psi}^{n+1},\boldsymbol{m}) \right)
89
+ \boldsymbol{G}
90
+ - \boldsymbol{G}_{z}
91
+ \frac{\partial \boldsymbol{k}_{Av}}{\partial\boldsymbol{\psi}^{n+1}}
92
+ \right]
93
+ }^{\boldsymbol{A}_0(\boldsymbol{\psi}^{n+1})}
94
+ \frac{\partial \boldsymbol{\psi}^{n+1}}{\partial\boldsymbol{m}}
95
+ \nonumber\\
96
+ +
97
+ \underbrace{
98
+ \left[
99
+ -\frac{1}{\Delta t}
100
+ \frac{\partial \boldsymbol{\theta}^n}{\partial\boldsymbol{\psi}^n}
101
+ \right]
102
+ }_{\boldsymbol{A}_{-1}(\boldsymbol{\psi}^n)}
103
+ \frac{\partial \boldsymbol{\psi}^n}{\partial\boldsymbol{m}}
104
+ =
105
+ \underbrace{
106
+ \left[
107
+ -\boldsymbol{D}
108
+ \text{diag}\left( \boldsymbol{G} \boldsymbol{\psi}^{n+1} \right)
109
+ \frac{\partial \boldsymbol{k}_{Av}}{\partial\boldsymbol{m}}
110
+ -\boldsymbol{G}_{z}
111
+ \frac{\partial \boldsymbol{k}_{Av}}{\partial\boldsymbol{m}}
112
+ \right]
113
+ }_{\boldsymbol{B}(\psi^{n+1})}&
114
+ \end{align*}
115
+ typst: |-
116
+ overbrace(
117
+ [
118
+ 1/(Delta t)
119
+ (diff bold(theta)^(n + 1))/(diff bold(psi)^(n + 1))
120
+ - bold(D)
121
+ "diag"(bold(G) bold(psi)^(n + 1))
122
+ (diff bold(k)_(A v))/(diff bold(psi)^(n + 1))
123
+ - bold(D)
124
+ "diag"(bold(k)_(A v) (bold(psi)^(n + 1) comma bold(m)))
125
+ bold(G)
126
+ - bold(G)_z
127
+ (diff bold(k)_(A v))/(diff bold(psi)^(n + 1))
128
+ ]
129
+ , bold(A)_0 (bold(psi)^(n + 1)))
130
+ (diff bold(psi)^(n + 1))/(diff bold(m))
131
+ \
132
+ +
133
+ underbrace(
134
+ [
135
+ - 1/(Delta t)
136
+ (diff bold(theta)^n)/(diff bold(psi)^n)
137
+ ]
138
+ , bold(A)_(-1) (bold(psi)^n))
139
+ (diff bold(psi)^n)/(diff bold(m))
140
+ =
141
+ underbrace(
142
+ [
143
+ -bold(D)
144
+ "diag"(bold(G) bold(psi)^(n + 1))
145
+ (diff bold(k)_(A v))/(diff bold(m))
146
+ - bold(G)_z
147
+ (diff bold(k)_(A v))/(diff bold(m))
148
+ ]
149
+ , bold(B)(psi^(n + 1))) &
150
+ - title: leading underscore
151
+ tex: _2
152
+ typst: '#none_2'
153
+ - title: leading power
154
+ tex: '^{\text{st}}'
155
+ typst: '#none^"st"'
156
+ - title: greater than
157
+ tex: 'a \ge b'
158
+ typst: a >= b
159
+ - title: greater than (preferShorthands=false)
160
+ tex: 'a \ge b'
161
+ typst: a gt.eq b
162
+ preferShorthands: false
163
+ - title: ddot
164
+ tex: 'q, \dot{q}, \ddot{q}'
165
+ typst: q, dot(q), dot.double(q)
166
+ - title: mat
167
+ tex: 'x(t) = \left[ \begin{array}{c} q(t) & x \\ \dot{q}(t) & x \end{array}\right]'
168
+ typst: 'x(t) = [mat(delim: #none, align: #center, q(t), x; dot(q)(t), x)]'
169
+ - title: brackets
170
+ tex: '\frac{1}{\tau(X_2)}'
171
+ typst: '1/(tau(X_2))'
172
+ - title: bar and nested bb
173
+ tex: '\mathbb{\bar{R}}'
174
+ typst: 'bb(macron(R))'
175
+ - title: Underscore with no content
176
+ tex: 'P_{}^{1}'
177
+ typst: 'P_()^1'
178
+ - title: Simple overbrace
179
+ tex: '\overbrace{a}^{b}'
180
+ typst: 'overbrace(a, b)'
181
+ - title: underbrace
182
+ tex: '\underbrace{a}_{b}'
183
+ typst: underbrace(a, b)
184
+ - title: Test
185
+ tex: a^{b^{n+1}}
186
+ typst: a^(b^(n + 1))
187
+ - title: Test2
188
+ tex: a+b^1 + \frac{2}{3} + \overbrace{123}^{b}
189
+ typst: a + b^1 + 2/3 + overbrace(123, b)
190
+ - title: Symbols
191
+ tex: '\alpha \nabla \partial'
192
+ typst: alpha nabla diff
193
+ - title: Align
194
+ tex: |-
195
+ \begin{align*}
196
+ a &= b \\
197
+ c &= d
198
+ \end{align*}
199
+ typst: |-
200
+ a &= b \
201
+ c &= d
202
+ - title: Matrix cells are groups
203
+ tex: |-
204
+ m = \begin{matrix}
205
+ a &= b \\
206
+ c &= d
207
+ \end{matrix}
208
+ typst: |-
209
+ m = mat(delim: #none, a, = b;
210
+ c, = d)
211
+ - title: An align mark & is at the beginning of a line
212
+ tex: |-
213
+ \begin{matrix}
214
+ &a &= b \\
215
+ &c &= d
216
+ \end{matrix}
217
+ typst: |-
218
+ mat(delim: #none, , a, = b;
219
+ , c, = d)
220
+ - title: Array
221
+ tex: |-
222
+ \begin{array}{cc}
223
+ a & b \\
224
+ c & d
225
+ \end{array}
226
+ typst: |-
227
+ mat(delim: #none, align: #center, a, b;
228
+ c, d)
229
+ - title: Array with vertical line
230
+ tex: |-
231
+ \begin{array}{c|c|c}
232
+ a & b & c \\
233
+ c & d & e
234
+ \end{array}
235
+ typst: |-
236
+ mat(delim: #none, augment: #(vline: (1, 2)), align: #center, a, b, c;
237
+ c, d, e)
238
+ - title: Array with single vertical line
239
+ tex: |-
240
+ \begin{array}{c|cc}
241
+ a & b & c \\
242
+ c & d & e
243
+ \end{array}
244
+ typst: |-
245
+ mat(delim: #none, augment: #1, align: #center, a, b, c;
246
+ c, d, e)
247
+ # should not mistakenly ignore `{x}` in `\begin{matrix} {x} ... \end{matrix}`
248
+ - title: should not parse arg if envName is not one of array, subarray
249
+ tex: \begin{matrix} {x} & {y} \\ {z} & {w} \end{matrix}
250
+ typst: "mat(delim: #none, x, y; z, w)"
251
+ - title: Test3
252
+ tex: \boldsymbol{x}
253
+ typst: bold(x)
254
+ - title: Test4
255
+ tex: a^2 + b^2 = c^2
256
+ typst: a^2 + b^2 = c^2
257
+ - title: Euler Complex Exponential
258
+ tex: e^{i\theta} = \cos \theta + i \sin \theta
259
+ typst: e^(i theta) = cos theta + i sin theta
260
+ - title: Euler Product
261
+ tex: \prod_{p} \frac{1}{1-p^{-s}}= \sum_{n=1}^{\infty} \frac{1}{n^s}
262
+ typst: product_p 1/(1 - p^(-s)) = sum_(n = 1)^infinity 1/(n^s)
263
+ - title: Test5
264
+ tex: "{a+b}^2"
265
+ typst: (a + b)^2
266
+ - title: Test6
267
+ tex: 1 + {a + b} + c
268
+ typst: 1 + a + b + c
269
+ - title: Test7
270
+ tex: (a + b)^2
271
+ typst: (a + b)^2
272
+ - title: leading minus sign
273
+ tex: a^{-s}
274
+ typst: a^(-s)
275
+ - title: Test8
276
+ tex: \sqrt{\frac{1}{x^2 + y^2}}
277
+ typst: sqrt(1/(x^2 + y^2))
278
+ - title: basic prime case
279
+ tex: y'
280
+ typst: y'
281
+ - title: has both prime and subscript
282
+ tex: y_1' + y'_2 + y_{a_1}' + {\theta}_1'
283
+ typst: y'_1 + y'_2 + y'_(a_1) + theta'_1
284
+
285
+ - title: space before or after script
286
+ tex: \lim _{x \to 0} \sum_{i=1} ^ n
287
+ typst: lim_(x -> 0) sum_(i = 1)^n
288
+ - title: spaces around text
289
+ tex: i_D = \mu_n C_\text{ox} \frac{W}{L} \left[ (v_\text{GS} - V_t)v_\text{DS} - \frac{1}{2} v_\text{DS}^2 \right]
290
+ typst: i_D = mu_n C_"ox" W/L [(v_"GS" - V_t) v_"DS" - 1/2 v_"DS"^2]
291
+ - title: base is group wrapped in brackets
292
+ tex: e = \lim_{{n \to \infty}} \left(1 + \frac{1}{n}\right)^n
293
+ typst: e = lim_(n -> infinity) (1 + 1/n)^n
294
+
295
+ - title: oo
296
+ tex: \infty
297
+ typst: oo
298
+ inftyToOo: true
299
+ - title: overrightarrow
300
+ tex: \overrightarrow{AB}
301
+ typst: arrow(A B)
302
+ - title: overleftarrow
303
+ tex: \overleftarrow{AB}
304
+ typst: accent(A B, <-)
305
+ - title: Horizontal space symbols
306
+ tex: "\\, \\: \\; \\quad \\!"
307
+ typst: "thin med thick quad #h(-math.thin.amount)"
308
+ - title: cases1
309
+ tex: |-
310
+ \begin{cases}
311
+ x^2, & \text{if } x \geq 0 \\
312
+ -x, & \text{if } x < 0
313
+ \end{cases}
314
+ typst: |-
315
+ cases(x^2 comma & "if " x >= 0,
316
+ - x comma & "if " x < 0)
317
+ - title: cases2
318
+ tex: |-
319
+ A_{ij} =
320
+ \begin{cases}
321
+ 1, & \text{if } i = j \\
322
+ 0, & \text{otherwise}
323
+ \end{cases}
324
+ typst: |-
325
+ A_(i j) =
326
+ cases(1 comma & "if " i = j,
327
+ 0 comma & "otherwise")
328
+ - title: cases3
329
+ tex: |-
330
+ P(X = x) =
331
+ \begin{cases}
332
+ \frac{1}{n}, & x \in \{1,2,\dots,n\} \\
333
+ 0, & \text{otherwise}
334
+ \end{cases}
335
+ typst: |-
336
+ P(X = x) =
337
+ cases(1/n comma & x in {1 comma 2 comma ... comma n},
338
+ 0 comma & "otherwise")
339
+ - title: cases4
340
+ tex: |-
341
+ f(x) =
342
+ \begin{cases}
343
+ x^2 + 1, & \text{if } x < -1 \\
344
+ \sin x + x^2, & \text{if } -1 \leq x \leq 1 \\
345
+ \sqrt{x}, & \text{if } x > 1
346
+ \end{cases}
347
+ typst: |-
348
+ f(x) =
349
+ cases(x^2 + 1 comma & "if " x < - 1,
350
+ sin x + x^2 comma & "if " - 1 <= x <= 1,
351
+ sqrt(x) comma & "if " x > 1)
352
+ - title: cases5
353
+ tex: |-
354
+ \begin{align*}
355
+ f(x) &=
356
+ \begin{cases}
357
+ x^2, & x \geq 0 \\
358
+ -x, & x < 0
359
+ \end{cases} \\
360
+ g(x) &=
361
+ \begin{cases}
362
+ \sin x, & x < \pi \\
363
+ 0, & x \geq \pi
364
+ \end{cases}
365
+ \end{align*}
366
+
367
+ typst: |-
368
+ f(x) &=
369
+ cases(x^2 comma & x >= 0,
370
+ - x comma & x < 0) \
371
+ g(x) &=
372
+ cases(sin x comma & x < pi,
373
+ 0 comma & x >= pi)
374
+ - title: frac1
375
+ tex: \frac ab
376
+ typst: a/b
377
+ - title: frac2
378
+ tex: \frac 12
379
+ typst: 1/2
380
+ - title: frac3
381
+ tex: \frac 12
382
+ typst: 1/2
383
+ - title: frac4
384
+ tex: \frac12
385
+ typst: 1/2
386
+ - title: frac5
387
+ tex: \frac{12}{34}
388
+ typst: 12/34
389
+ - title: frac6
390
+ tex: \frac123
391
+ typst: 1/2 3
392
+ - title: frac7
393
+ tex: \frac {12}3
394
+ typst: 12/3
395
+ # this test the lexer's regex. Old bad implementation translated it to "yen 2 0 00 \$ 3000"
396
+ - title: yen
397
+ tex: \yen 2000 > \$ 3000
398
+ typst: yen 2000 > \$ 3000
399
+ # this test the typst writer. Old bad implementation translated it to "X/Y/2"
400
+ - title: frac of frac
401
+ tex: \frac{X}{\frac{Y}{2}}
402
+ typst: X/(Y/2)
403
+ - title: Don't escape commas inside a lr()
404
+ tex: \left| f(a, b) \right|
405
+ typst: lr(|f(a, b)|)
406
+ - title: Backslash space
407
+ tex: a \ b
408
+ typst: a med b
409
+ - title: display style
410
+ tex: \displaystyle \lim_{x \to -\infty} F(x) = 0, \lim_{x \to +\infty} F(x) = 1
411
+ typst: display(lim_(x -> - infinity) F(x) = 0 comma lim_(x -> + infinity) F(x) = 1)
412
+ - title: display style 2
413
+ tex: \lim_{x \to -\infty} F(x) = 0, \displaystyle \lim_{x \to +\infty} F(x) = 1
414
+ typst: lim_(x -> - infinity) F(x) = 0, display(lim_(x -> + infinity) F(x) = 1)
415
+ # this test the typst formatter. Old bad implementation translated it to "C(x y)/z"
416
+ - title: parenthesis in fraction
417
+ tex: C \frac{xy}{z}
418
+ typst: C (x y)/z
419
+ # this test the typst formatter. Old bad implementation translated it to "1/3(x + y)"
420
+ - title: parenthesis after fraction
421
+ tex: \frac{1}{3} (x + y)
422
+ typst: 1/3 (x + y)
423
+ - title: substack
424
+ tex: \sum_{\substack{0 \leq i \leq m \\ 0 < j < n}} P(i, j)
425
+ typst: sum_(0 <= i <= m \ 0 < j < n) P(i, j)
426
+ - title: subarray-l
427
+ tex: \sum_{\begin{subarray}{l} 0 \leq i \leq m \\ 0 < j < n \end{subarray}} P(i, j)
428
+ typst: sum_(& 0 <= i <= m \ & 0 < j < n) P(i, j)
429
+ - title: subarray
430
+ tex: \sum_{\begin{subarray}{c} 0 \leq i \leq m \\ 0 < j < n \end{subarray}} P(i, j)
431
+ typst: sum_(0 <= i <= m \ 0 < j < n) P(i, j)
432
+ - title: subarray-r
433
+ tex: \sum_{\begin{subarray}{r} 0 \leq i \leq m \\ 0 < j < n \end{subarray}} P(i, j)
434
+ typst: sum_(0 <= i <= m & \ 0 < j < n &) P(i, j)
435
+ - title: subarray-with-rr &
436
+ tex: \sum_{\begin{subarray}{rr} a & b \\ c & d \end{subarray}} P(i, j)
437
+ typst: sum_(a & b \ c & d) P(i, j)
438
+ - title: command set
439
+ tex: \set{a, b, c}
440
+ typst: "{a, b, c}"
441
+ - title: command set, empty
442
+ tex: \set{}
443
+ typst: "{}"