Playground

Typst Plugin Playground

Interactive mathematical typesetting with Typst, LaTeX, and KaTeX

Typst Plugin Playground

This page demonstrates mathematical rendering capabilities using multiple engines: Typst, LaTeX, and KaTeX.

Typst Component Package (vitepress-typstex-vue)

The vitepress-typstex-vue package provides a Vue component <TypstMath> for rendering Typst or LaTeX-style expressions.

  • Primary: Typst WASM compiler (native Typst syntax)
  • Fallback: KaTeX or MathJax (for LaTeX syntax)
  • Automatic fallback when Typst fails

Inline Math Example

This is an inline formula: in the text.

Display Math Example

Mixed Formula (Typst Syntax)

Complex Expressions

Quadratic formula:

Matrix representation:

Summation and limits:

Rendering Engine Comparison

Let's compare the same formula rendered with three different engines.

Target formula:

\int_0^\infty e^{-x^2}\,dx = \frac{\sqrt{\pi}}{2}

1. Native Typst (Typst Syntax)

Using Typst's native syntax:

2. TypstMath Fallback (MathJax)

When configured with latexEngine: 'mathjax', LaTeX-style input falls back to MathJax:

Overriding the Engine per Component

The global plugin sets the default fallback engine, but you can override it for any <TypstMath> via the latex-engine prop:

<TypstMath
  src="\\int_0^\\infty e^{-x^2}\\,dx = \\frac{\\sqrt{\\pi}}{2}"
  :is-block="true"
  latex-engine="katex"
  :fontSize="18"
/>  <!-- Force KaTeX -->

<TypstMath
  src="\\int_0^\\infty e^{-x^2}\\,dx = \\frac{\\sqrt{\\pi}}{2}"
  :is-block="true"
  latex-engine="mathjax"
  :fontSize="18"
/>  <!-- Force MathJax -->

3. markdown-it-typstex Fallback (KaTeX)

The same LaTeX formula parsed by the markdown-it-typstex plugin, falling back to KaTeX when Typst fails:

0ex2dx=π2\int_0^\infty e^{-x^2}\,dx = \frac{\sqrt{\pi}}{2}

4. Pure Typst Syntax

Using Typst's mathematical syntax:

integral0infinitye(x2)dx=sqrt(π)/2integral_0^infinity e^(-x^2) d x = sqrt(π)/2

markdown-it-typstex Plugin

This plugin allows you to write math expressions directly in markdown.

Inline Math

Here's an inline formula: L=1/2rhov2SCLL = 1/2 rho v^2 S C_L for lift force.

The famous Euler's identity: e(ipi)+1=0e^(i pi) + 1 = 0.

Display Math (Double Dollar Signs)

Maxwell's equations:

gradientdotbold(E)=rho/epsilon0gradient dot bold(E) = rho / epsilon_0gradientdotbold(B)=0gradient dot bold(B) = 0gradienttimesbold(E)=(partialbold(B))/(partialt)gradient times bold(E) = -(partial bold(B))/(partial t)gradienttimesbold(B)=mu0bold(J)+mu0epsilon0(partialbold(E))/(partialt) gradient times bold(B) = mu_0 bold(J) + mu_0 epsilon_0 (partial bold(E))/(partial t)

Display Math (Math Code Block)

You can also use fenced code blocks with math language:

L=1/2rhov2SCLL = 1/2 rho v^2 S C_L F=G(m1m2)/r2F = G (m_1 m_2)/r^2

More Examples

Calculus

Derivative definition:

f(x)=lim(harrow0)(f(x+h)f(x))/hf'(x) = lim_(h arrow 0) (f(x+h) - f(x))/h

Taylor series:

f(x)=sum(n=0)infinity(f((n))(a))/(n!)(xa)nf(x) = sum_(n=0)^infinity (f^((n))(a))/(n!) (x-a)^n

Linear Algebra

Determinant:

detmat(a,b;c,d)=adbcdet mat(a, b; c, d) = a d - b c

Eigenvalue equation:

Abold(v)=lambdabold(v)A bold(v) = lambda bold(v)

Statistics

Normal distribution:

f(x)=1/(sigmasqrt(2pi))e((xmu)2/(2sigma2))f(x) = 1/(sigma sqrt(2pi)) e^(-(x-mu)^2/(2sigma^2))

Bayes' theorem:

P(AB)=(P(BA)P(A))/(P(B))P(A|B) = (P(B|A) P(A))/(P(B))

Physics

Schrödinger equation:

iplanck.reduce(partial)/(partialt)Psi=hat(H)Psii planck.reduce (partial)/(partial t) Psi = hat(H) Psi

Lorentz transformation:

t=gamma(t(vx)/c2),quadx=gamma(xvt)t' = gamma(t - (v x)/c^2), quad x' = gamma(x - v t)

where gamma=1/sqrt(1v2/c2)gamma = 1/sqrt(1-v^2/c^2).

LaTeX Compatibility

The plugin also supports traditional LaTeX syntax:

0ex2dx=π2\int_0^\infty e^{-x^2}\,dx = \frac{\sqrt{\pi}}{2}n=11n2=π26\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}limx0sinxx=1\lim_{x \to 0} \frac{\sin x}{x} = 1
  1. Typst WASM (primary): Fast, feature-rich, native Typst syntax
  2. MathJax (fallback): Comprehensive LaTeX support, larger bundle
  3. KaTeX (fallback): Fast LaTeX rendering, smaller bundle
  • Use Typst syntax for better performance and smaller bundle size
  • Use LaTeX syntax for compatibility with existing content
  • Test complex formulas with different engines for best results
Copyright © 2026