Files
Snippets/LaTeX_Typst.md
T
2026-09-16 07:50:42 +02:00

443 lines
22 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# LaTeX -- Typst
## Griechische Buchstaben
### kleine griechische Buchstaben
| LaTeX | Vorschau | Typst |
|:------------- | ------------- | ---------------------- |
| `\alpha` | $\alpha$ | alpha |
| `\beta` | $\beta$ | beta |
| `\gamma` | $\gamma$ | gamma |
| `\delta` | $\delta$ | delta |
| `\epsilon` | $\epsilon$ | epsilon.alt |
| `\zeta` | $\zeta$ | zeta |
| `\eta` | $\eta$ | eta |
| `\theta` | $\theta$ | theta |
| `\iota` | $\iota$ | iota |
| `\kappa` | $\kappa$ | kappa |
| `\lambda` | $\lambda$ | lambda |
| `\mu` | $\mu$ | mu |
| `\nu` | $\nu$ | nu |
| `\xi` | $\xi$ | xi |
| `\omicron` | $\omicron$ | omnicron |
| `\pi` | $\pi$ | pi |
| `\rho` | $\rho$ | rho |
| `\sigma` | $\sigma$ | sigma |
| `\tau` | $\tau$ | tau |
| `\upsilon` | $\upsilon$ | upsilon <—- bis hier |
| `\phi` | $\phi$ | phi.alt |
| `\chi` | $\chi$ | chi |
| `\psi` | $\rho$ | rho |
| `\omega` | $\omega$ | omega |
| `\varepsilon` | $\varepsilon$ | epsilion |
| `\vartheta` | $\vartheta$ | theta.alt |
| `\varpi` | $\varpi$ | pi.alt |
| `\varrho` | $\varrho$ | rho.alt |
| `\varsigma` | $\varsigma$ | sigma.alt |
| `\varphi` | $\varphi$ | phi |
### Grosse griechische Buchstaben
| LaTeX | Vorschau | Typst |
| :--------- | ---------- | ------- |
| `\Gamma` | $\Gamma$ | Gamma |
| `\Delta` | $\Delta$ | Delta |
| `\Theta` | $\Theta$ | Theta |
| `\Lambda` | $\Lambda$ | Lambda |
| `\Xi` | $\Xi$ | Xi |
| `\Pi` | $\Pi$ | Pi |
| `\Sigma` | $\Sigma$ | Sigma |
| `\Upsilon` | $\Upsilon$ | Upsilon |
| `\Phi` | $\Phi$ | Phi |
| `\Psi` | $\Psi$ | Psi |
| `\Omega` | $\Omega$ | Omega |
### Integral
| LaTeX | Vorschau | Typst |
| :--------- | ---------- | ------- |
| `\int_a^b f(x) \mathrm{d} x` | $\int_a^b f(x) \mathrm{d} x$ | integral_a^b f(x) dif x |
| `\int` | $\int$ | integral |
| `\oint` | $\oint$ | integral.cont |
| `\iint` | $\iint$ | integral.double |
| `\oiint` | $\oiint$ | integral.surf |
| `\iiint` | $\iiint$ | integral.triple |
| `\oiiint` | $\oiiint$ | integral.vol |
### Fonts
| LaTeX | Vorschau | Typst |
| :--------------- | ---------------- | ------- |
| `\boldsymbol{A}` | $\boldsymbol{A}$ | bold(A) |
| `\mathbb{A}` | $\mathbb{A}$ | AA |
| `\mathbf{A}` | $\mathbf{A}$ | upright(bold(A)) |
| `\mathcal{A}` | $\mathcal{A}$ | cal(A) |
| `\mathscr{A}` | $\mathscr{A}$ | scr(A) |
| `\mathit{A}` | $\mathit{A}$ | italic(A) |
| `\mathfrak{A}` | $\mathfrak{A}$ | frak(A) |
| `\mathrm{A}` | $\mathrm{A}$ | upright(A) |
| `\mathsf{A}` | $\mathsf{A}$ | sans(A) |
| `\mathtt{A}` | $\mathtt{A}$ | mono(A) |
## Arrows
| LaTeX | Preview | Typst (Textual) | Typst (Shorthand) |
| --------------------- | --------------------- | --------------------- | ----------------- |
| `\leftarrow` | $\leftarrow$ | arrow.l | <- |
| `\gets` | $\gets$ | arrow.l | <- |
| `\rightarrow` | $\rightarrow$ | arrow.r | -> |
| `\to` | $\to$ | arrow.r | -> |
| `\leftrightarrow` | $\leftrightarrow$ | arrow.l.r | <-> |
| `\Leftarrow` | $\Leftarrow$ | arrow.l.double | |
| `\Rightarrow` | $\Rightarrow$ | arrow.r.double | => |
| `\Leftrightarrow` | $\Leftrightarrow$ | arrow.l.r.double | <=> |
| `\mapsto` | $\mapsto$ | arrow.r.bar | -> |
| `\hookleftarrow` | $\hookleftarrow$ | arrow.l.hook | |
| `\leftharpoonup` | $\leftharpoonup$ | harpoon.lt | |
| `\leftharpoondown` | $\leftharpoondown$ | harpoon.lb | |
| `\rightleftharpoons` | $\rightleftharpoons$ | harpoons.rtlb | |
| `\longleftarrow` | $\longleftarrow$ | arrow.l.long | <-- |
| `\longrightarrow` | $\longrightarrow$ | arrow.r.long | --> |
| `\longleftrightarrow` | $\longleftrightarrow$ | arrow.l.r.long | <--> |
| `\Longleftarrow` | $\Longleftarrow$ | arrow.l.double.long | <== |
| `\Longrightarrow` | $\Longrightarrow$ | arrow.r.double.long | ==> |
| `\Longleftrightarrow` | $\Longleftrightarrow$ | arrow.l.r.double.long | <==> |
| `\longmapsto` | $\longmapsto$ | arrow.r.long.bar | |
| `\hookrightarrow` | $\hookrightarrow$ | arrow.r.hook | |
| `\rightharpoonup` | $\rightharpoonup$ | harpoon.rt | |
| `\rightharpoondown` | $\rightharpoondown$ | harpoon.rb | |
| `\iff` | $\iff$ | arrow.l.r.double.long | <==> |
| `\implies` | $\implies$ | arrow.r.double.long | ==> |
| `\uparrow` | $\uparrow$ | arrow.t | |
| `\downarrow` | $\downarrow$ | arrow.b | |
| `\updownarrow` | $\updownarrow$ | arrow.t.b | |
| `\Uparrow` | $\Uparrow$ | arrow.t.double | |
| `\Downarrow` | $\Downarrow$ | arrow.b.double | |
| `\Updownarrow` | $\Updownarrow$ | arrow.t.b.double | |
| `\nearrow` | $\nearrow$ | arrow.tr | |
| `\searrow` | $\searrow$ | arrow.br | |
| `\swarrow` | $\swarrow$ | arrow.bl | |
| `\nwarrow` | $\nwarrow$ | arrow.tl | |
| `\leadsto` | $\leadsto$ | arrow.r.squiggly | ~> |
| `\leftleftarrows` | $\leftleftarrows$ | arrows.ll | |
| `\rightrightarrows` | $\rightleftarrows$ | arrows.rr | |
## Set and Elements
| LaTeX | Preview | Typst |
| ------------- | ------------- | --------- |
| `\in` | $\in$ | in |
| `\subset` | $\subset$ | subset |
| `\subseteq` | $\subseteq$ | subset.eq |
| `\supset` | $\supset$ | supset |
| `\supseteq` | $\supseteq$ | supset.eq |
| `\varnothing` | $\varnothing$ | diameter |
## Non-mathematical Symbols
| LaTeX | Preview | Typst |
| ------------ | ------------ | --------- |
| `\$` | $\$$ | \\$ |
| `\pounds` | $\pounds$ | pound |
| `\yen` | $\yen$ | yen |
| `\copyright` | $\copyright$ | copyright |
| `\S` | $\S$ | section |
| `\P` | $\P$ | pilcrow |
## Verschiedene Symbole
| LaTeX | Preview | Typst (Textual) | Typst (Shorthand) |
| -------- | -------- | --------------- | ----------------- |
| `\Cap` | $\Cap$ | inter.double | |
| `\Cup` | $\Cup$ | union.double | |
| `\Join` | $\Join$ | join | |
| `\aleph` | $\aleph$ | alef | |
| | | | |
# Temp
## Miscellaneous Symbols
| LaTeX | Preview | Typst (Textual) | Typst (Shorthand) |
| -------------------- | ------- | ------------------ | ----------------- |
| `\angle` | ∠ | `angle` | `` |
| `\approx` | ≈ | `approx` | `` |
| `\approxeq` | ≊ | `approx.eq` | `` |
| `\ast` | ∗ | `ast` | `` |
| `\bigcap` | ⋂ | `inter.big` | `` |
| `\bigcirc` | ◯ | `circle.big` | `` |
| `\bigcup` | ⋃ | `union.big` | `` |
| `\bigodot` | ⨀ | `dot.o.big` | `` |
| `\bigoplus` | ⨁ | `xor.big` | `` |
| `\bigotimes` | ⨂ | `times.o.big` | `` |
| `\bigsqcup` | ⨆ | `union.sq.big` | `` |
| `\bigtriangledown` | ▽ | `triangle.b` | `` |
| `\bigtriangleup` | △ | `triangle.t` | `` |
| `\biguplus` | ⨄ | `union.plus.big` | `` |
| `\bigvee` | ⋁ | `or.big` | `` |
| `\bigwedge` | ⋀ | `and.big` | `` |
| `\bullet` | ∙ | `bullet` | `` |
| `\cap` | ∩ | `inter` | `` |
| `\cdot` | ⋅ | `dot.op` | `` |
| `\cdots` | ⋯ | `dots.c` | `` |
| `\checkmark` | ✓ | `checkmark` | `` |
| `\circ` | ∘ | `circle.small` | `` |
| `\colon` | : | `colon` | `` |
| `\cong` | ≅ | `tilde.equiv` | `` |
| `\coprod` | ∐ | `product.co` | `` |
| `\cup` | ∪ | `union` | `` |
| `\curlyvee` | ⋎ | `or.curly` | `` |
| `\curlywedge` | ⋏ | `and.curly` | `` |
| `\dagger` | † | `dagger` | `` |
| `\dashv` | ⊣ | `tack.l` | `` |
| `\ddagger` | ‡ | `dagger.double` | `` |
| `\ddots` | ⋱ | `dots.down` | `` |
| `\diamond` | ⋄ | `diamond` | `` |
| `\div` | ÷ | `div` | `` |
| `\divideontimes` | ⋇ | `times.div` | `` |
| `\dotplus` | ∔ | `plus.dot` | `` |
| `\ell` | ℓ | `ell` | `` |
| `\emptyset` | ∅ | `nothing` | `` |
| `\equiv` | ≡ | `equiv` | `` |
| `\exists` | ∃ | `exists` | `` |
| `\forall` | ∀ | `forall` | `` |
| `\ge` | ≥ | `gt.eq` | `>=` |
| `\geq` | ≥ | `gt.eq` | `>=` |
| `\geqslant` | ⩾ | `gt.eq.slant` | `` |
| `\gg` | ≫ | `gt.double` | `>>` |
| `\hbar` | ℏ | `planck` | `` |
| `\imath` | ** | `dotless.i` | `` |
| `\infty` | ∞ | `infinity` | `oo` |
| `\intercal` | ⊺ | `top` | `` |
| `\jmath` | ** | `dotless.j` | `` |
| `\land` | ∧ | `and` | `` |
| `\langle` | ⟨ | `chevron.l` | `` |
| `\lbrace` | { | `brace.l` | `` |
| `\lbrack` | [ | `bracket.l` | `` |
| `\ldots` | … | `dots.l` | `` |
| `\le` | ≤ | `lt.eq` | `<=` |
| `\leftthreetimes` | ⋋ | `times.three.l` | `` |
| `\leq` | ≤ | `lt.eq` | `<=` |
| `\leqslant` | ⩽ | `lt.eq.slant` | `` |
| `\lhd` | ⊲ | `triangle.l` | `` |
| `\ll` | ≪ | `lt.double` | `<<` |
| `\ltimes` | ⋉ | `times.l` | `` |
| `\measuredangle` | ∡ | `angle.arc` | `` |
| `\mid` | ∣ | `divides` | `` |
| `\models` | ⊨ | `models` | `` |
| `\mp` | ∓ | `minus.plus` | `` |
| `\nRightarrow` | ⇏ | `arrow.double.not` | `` |
| `\nabla` | ∇ | `nabla` | `` |
| `\ncong` | ≆ | `tilde.nequiv` | `` |
| `\ne` | = | `eq.not` | `!=` |
| `\neg` | ¬ | `not` | `` |
| `\neq` | = | `eq.not` | `!=` |
| `\nexists` | ∄ | `exists.not` | `` |
| `\ngeq` | ≱ | `gt.eq.not` | `` |
| `\ni` | ∋ | `in.rev` | `` |
| `\nleftarrow` | ↚ | `arrow.l.not` | `` |
| `\nleq` | ≰ | `lt.eq.not` | `` |
| `\nparallel` | ∦ | `parallel.not` | `` |
| `\nmid` | ∤ | `divides.not` | `` |
| `\notin` | ∈/ | `in.not` | `` |
| `\nrightarrow` | ↛ | `arrow.not` | `` |
| `\nsim` | ≁ | `tilde.not` | `` |
| `\nsubseteq` | ⊈ | `subset.eq.not` | `` |
| `\ntriangleleft` | ⋪ | `lt.tri.not` | `` |
| `\ntriangleright` | ⋫ | `gt.tri.not` | `` |
| `\odot` | ⊙ | `dot.o` | `` |
| `\ominus` | ⊖ | `minus.o` | `` |
| `\oplus` | ⊕ | `xor` | `` |
| `\otimes` | ⊗ | `times.o` | `` |
| `\parallel` | ∥ | `parallel` | `` |
| `\partial` | ∂ | `partial` | `` |
| `\perp` | ⊥ | `perp` | `` |
| `\pm` | ± | `plus.minus` | `` |
| `\prec` | ≺ | `prec` | `` |
| `\preceq` | ⪯ | `prec.eq` | `` |
| `\prime` | ′ | `prime` | `` |
| `\prod` | ∏ | `product` | `` |
| `\propto` | ∝ | `prop` | `` |
| `\rangle` | ⟩ | `chevron.r` | `` |
| `\rbrace` | } | `brace.r` | `` |
| `\rbrack` | ] | `bracket.r` | `` |
| `\rhd` | ⊳ | `triangle` | `` |
| `\rightthreetimes` | ⋌ | `times.three.r` | `` |
| `\rtimes` | ⋊ | `times.r` | `` |
| `\setminus` | ∖ | `without` | `` |
| `\sim` | ∼ | `tilde` | `` |
| `\simeq` | ≃ | `tilde.eq` | `` |
| `\smallsetminus` | ∖ | `without` | `` |
| `\spadesuit` | ♠ | `suit.spade` | `` |
| `\sqcap` | ⊓ | `inter.sq` | `` |
| `\sqcup` | ⊔ | `union.sq` | `` |
| `\sqsubseteq` | ⊑ | `subset.eq.sq` | `` |
| `\sqsupseteq` | ⊒ | `supset.eq.sq` | `` |
| `\star` | ⋆ | `star` | `` |
| `\subsetneq` | ⊊ | `subset.neq` | `` |
| `\succ` | ≻ | `succ` | `` |
| `\succeq` | ⪰ | `succ.eq` | `` |
| `\sum` | ∑ | `sum` | `` |
| `\supsetneq` | ⊋ | `supset.neq` | `` |
| `\times` | × | `times` | `` |
| `\top` | ⊤ | `top` | `` |
| `\triangle` | △ | `triangle.t` | `` |
| `\triangledown` | ▽ | `triangle.b.small` | `` |
| `\triangleleft` | ◃ | `triangle.l.small` | `` |
| `\triangleright` | ▹ | `triangle.r.small` | `` |
| `\twoheadrightarrow` | ↠ | `arrow.r.twohead` | `->>` |
| `\upharpoonright` | ↾ | `harpoon.tr` | `` |
| `\uplus` | ⊎ | `union.plus` | `` |
| `\vdash` | ⊢ | `tack.r` | `` |
| `\vdots` | ⋮ | `dots.v` | `` |
| `\vee` | ∨ | `or` | `` |
| `\wedge` | ∧ | `and` | `` |
| `\wr` | ≀ | `wreath` | |
# Implementing LaTeX macros unsupported by Typst
## Background
There is not always a Typst equivalent for every LaTeX macro. This document provides a guide on how to implement unsupported LaTeX macros in Typst.
## The `\mathscr` macro
`scr` is natively supported in Typst since version 0.14.0! [[1\]](https://qwinsi.github.io/tex2typst-webapp/impl-in-typst.html#fn1)
## The `\LaTeX` and `\TeX` macro
LaTeX: `\LaTeX` and `\TeX`
Implementation in Typst [[2\]](https://qwinsi.github.io/tex2typst-webapp/impl-in-typst.html#fn2)
```
#let TeX = context {
set text(font: "New Computer Modern")
let e = measure("E")
let T = "T"
let E = text(1em, baseline: e.height * 0.31, "E")
let X = "X"
box(T + h(-0.15em) + E + h(-0.125em) + X)
}
#let LaTeX = context {
set text(font: "New Computer Modern")
let a-size = 0.66em
let l = measure("L")
let a = measure(text(a-size, "A"))
let L = "L"
let A = box(scale(x: 105%, text(a-size, baseline: a.height - l.height, "A")))
box(L + h(-a.width * 0.67) + A + h(-a.width * 0.25) + TeX)
}
```
Usage example:
```
You can use #LaTeX in text environments.
You can use $#LaTeX$ in math environments as well.
```
## Using the `op` function to define custom operators
For example, if you want to define a custom operator `\myopr`.
LaTeX: `\newcommand{\myopr}{\operatorname{myopr}}`
Equivalent in Typst:
```
#let myopr = op("myopr");
```
Usage example:
```
$
y = myopr x
$
```
## A vertical bar for evaluation
It's common to use a vertical bar to denote the evaluation of a function at a point. e.g.
➣ LaTeX:
```
f(x) \bigg\rvert_{x = x_0}
```
Where `\bigg\rvert` may be replaced with `\bigg\vert`, `\bigg|` etc.
➣ Walkaround in Typst:
```
f(x) lr(| vec(delim: #none, , , x = x_0))
```
Also it's common to use a vertical bar to denote the deference of function values at two points, especially when calculating definite integrals. e.g. [[3\]](https://qwinsi.github.io/tex2typst-webapp/impl-in-typst.html#fn3)
➣ LaTeX:
```
F(x) \bigg\rvert_{a}^{b}
```
Where `\bigg\rvert` may be replaced with `\bigg\vert` , `\bigg|` etc.
➣ Walkaround in Typst:
```
F(x) lr(| vec(delim: #none, b, , a))
```
## The `\cancelto` macro
`\cancelto{value}{expression}` is a LaTeX command provided by the `cancel` package. It is used to place an arrow through an expression and annotate it with a value to which the expression is be evaluated.
➣ LaTeX:
```
\cancelto{0}{\frac{\partial^2 Q}{\partial r^2}}
```
➣ Implementation in Typst (adapted from [[4\]](https://qwinsi.github.io/tex2typst-webapp/impl-in-typst.html#fn4) ):
```
#let cancelto(to, body) = {
let max(a, b) = if a > b { a } else { b };
context {
let m = measure(body)
let (w, h) = (m.width, m.height * 2)
let arrow = rotate(-55deg, math.stretch(sym.arrow.r, size: max(h*1.8, w*2.0)))
set place(center + horizon)
body
place(dx: -w * 0.5, dy: -h * 0.1, arrow)
place(dx: w * 0.3, dy: -h * 1.1, to)
}
}
```
➣ Usage example:
```
$
cancelto(0, (partial^2 Q)/(partial r^2))
$
```
https://qwinsi.github.io/tex2typst-webapp/cheat-sheet.html