Temml for .NET

TeX in.
MathML out.

Temml converts TeX math to MathML, which browsers display on their own. Render on the server in C# and ship pages that need a stylesheet and a small font, but no math script.

Unofficial community port of Temml by Ron Kok. Not an official Temml product.

dotnet add package Temml

It targets net10.0 and netstandard2.0. Temml on NuGet.

C#Display modeExample source
using Temml;

var display = TemmlRenderer.RenderToString(
    @"\sum_{k=1}^{n} k = \frac{n(n+1)}{2}",
    new TemmlOptions { DisplayMode = true }
);
∑k=1nk=n(n+1)2
MathML rendered by upstream Temml 0.14.0, shown by your browser

Packages

Temml

and Temml.AngleSharp

Targets

net10.0

and netstandard2.0

Upstream

0.14.0

Ported from Temml

License

MIT

Same as upstream

Examples

Each card is the markup upstream Temml produces for the TeX under it, styled with the stylesheet the package embeds. Your browser and its fonts do the drawing.

Why Temml

Upstream Temml, in the C# you already write.

  • TeX to MathML

    TemmlRenderer returns a string, or a tree you can change before it becomes one.

    Quickstart
  • Macros and extensions

    Custom macros, preambles, and \gdef. mhchem, physics, and texvc are built in.

    Macros
  • Whole pages

    Temml.AngleSharp finds the math delimiters in a document, renders them, and resolves \ref.

    DOM and auto-render
  • Untrusted input

    Commands that load resources or set attributes are blocked by default, with limits on sizes and expansions.

    Security

Get started

From TeX to an equation on the page, in three steps.

Install the package, render an expression, then serve the stylesheet. Each step links to the page that has the rest.

Read the quickstart
  1. Install the package

    Add Temml to a project that targets net10.0 or netstandard2.0.

    dotnet add package Temml
    Quickstart
  2. Render and style

    Write the markup into your page, and serve one Temml stylesheet with Temml.woff2. Both are embedded in the package.

    var mathml = TemmlRenderer.RenderToString(tex);
    Styles and fonts
  3. Or render a whole page

    With Temml.AngleSharp, find the delimiters in an HTML document and render them in place.

    dotnet add package Temml.AngleSharp
    TemmlDom.RenderMathInElement(document.Body!);
    DOM and auto-render