Svelte Component to convert TeX to rendered SVG using MathJax or rendered MathML using Temml.
Svelte 5 Ready
- Convert TeX to SVG using MathJax
- Convert TeX to MathML using Temml
- Support MathJax options
- Support Temml options
npm install svelte-tex
MathML
is more recommended sinceMathSVG
bundle size is not small.
<script lang="ts">
import MathML from 'svelte-tex/package/MathML.svelte';
// use String.raw to escape `\`
const tex = String.raw`\frac{(n^2+n)(2n+1)}{6}`;
</script>
<MathML {tex} />
// or include Temml options
<MathML {tex} temmlOptions={{}} />
<script lang="ts">
import MathSVG from 'svelte-tex/package/MathSVG.svelte';
// use String.raw to escape `\`
const tex = String.raw`\frac{(n^2+n)(2n+1)}{6}`;
</script>
<MathSVG {tex} />
// or include MathJax options
<MathSVG {tex} texOptions={{}} svgOptions={{ fontCache: 'local' }} />
⚠️ MathSVG is not small for bundle size.
MathJax is not supports TypeScript for options yet
check texOptions from https://docs.mathjax.org/en/latest/options/input/tex.html#tex-input-processor-options
check svgOptions from https://docs.mathjax.org/en/latest/options/output/svg.html#svg-options