MarkdownRenderX.Avalonia.KaTeX 12.1.3.8

dotnet add package MarkdownRenderX.Avalonia.KaTeX --version 12.1.3.8
                    
NuGet\Install-Package MarkdownRenderX.Avalonia.KaTeX -Version 12.1.3.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MarkdownRenderX.Avalonia.KaTeX" Version="12.1.3.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MarkdownRenderX.Avalonia.KaTeX" Version="12.1.3.8" />
                    
Directory.Packages.props
<PackageReference Include="MarkdownRenderX.Avalonia.KaTeX" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MarkdownRenderX.Avalonia.KaTeX --version 12.1.3.8
                    
#r "nuget: MarkdownRenderX.Avalonia.KaTeX, 12.1.3.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MarkdownRenderX.Avalonia.KaTeX@12.1.3.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MarkdownRenderX.Avalonia.KaTeX&version=12.1.3.8
                    
Install as a Cake Addin
#tool nuget:?package=MarkdownRenderX.Avalonia.KaTeX&version=12.1.3.8
                    
Install as a Cake Tool

MarkdownRenderX.Avalonia.KaTeX

English | 简体中文

KaTeX-style math rendering for MarkdownRenderX.Avalonia — native SkiaSharp layout, no WebView and no JavaScript runtime.

How it works

  1. The core package already enables Markdig's Mathematics extension, so $...$ and $$...$$ become MathInline / MathBlock nodes.
  2. This package registers an IMarkdownNodeRenderer (see MarkdownRendererRegistry) for those nodes.
  3. LaTeX is laid out by CSharpMath and drawn through Avalonia's Skia backend.
  4. Latin Modern Math is embedded in the package (GUST Font License), so no system math font is required on Windows, Linux or macOS.

Install

dotnet add package MarkdownRenderX.Avalonia.KaTeX

Quick start

1. Register once at startup (e.g. App.OnFrameworkInitializationCompleted or Program.Main):

using MarkdownRenderX.Avalonia.KaTeX;

KaTeXExtension.Register();

2. Include both style files in App.axaml:

<Application.Styles>
    <FluentTheme />
    <StyleInclude Source="avares://MarkdownRenderX.Avalonia/Index.axaml" />
    <StyleInclude Source="avares://MarkdownRenderX.Avalonia.KaTeX/Index.axaml" />
</Application.Styles>

3. Write math in your Markdown:

Inline math: $E=mc^2$ works inside a paragraph.

$$
\frac{1}{2} + \sqrt{x^2 + y^2} = \int_0^\infty e^{-t}\,dt
$$

That's it — existing MarkdownRender instances pick it up automatically. Since 12.1.3.6 this also works with the companion FluentAvalonia.MarkdownRender package: both renderers share one extension registry, so a single Register() call covers either (or both).

Syntax notes

Input Node Rendering
$ ... $ MathInline inline, 16px
$$ ... $$ on its own lines MathBlock centered, 18px
$$ ... $$ on a single line MathInline (Markdig behavior) still rendered at display size

Invalid LaTeX is reported in place by CSharpMath as red error text; it never breaks the rest of the document because the registry swallows renderer exceptions and falls back to the built-in path.

Customization

// Sizes apply to content rendered afterwards
KaTeXExtension.Instance.InlineFontSize = 15;
KaTeXExtension.Instance.DisplayFontSize = 20;
KaTeXExtension.Instance.DisplayMargin = 10;   // vertical gap around display formulas

Formula color follows the theme through the MdMathTextColor resource (a Color). Override it in your own theme dictionaries to change it:

<ResourceDictionary.ThemeDictionaries>
    <ResourceDictionary x:Key="Light">
        <Color x:Key="MdMathTextColor">#202030</Color>
    </ResourceDictionary>
    <ResourceDictionary x:Key="Dark">
        <Color x:Key="MdMathTextColor">#F0F0F5</Color>
    </ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

Limitations

  • CSharpMath implements the LaTeX math subset, not the whole KaTeX engine: matrices, fractions, roots, integrals, sums, limits, accents and Greek letters work; \begin{align}, \textcolor, custom macros and arbitrary CSS do not.
  • Output is native vector text, so spacing may differ slightly from KaTeX's HTML/CSS output.
  • If you need pixel-identical KaTeX output (full macro support, colors, \htmlClass), a WebView-based renderer is the usual alternative — deliberately not used here.

Development

dotnet run --project tools/MrxSmoke -c Release   # asserts inline + block formula rendering

License

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
12.1.3.8 53 11/7/2026
12.1.3.7 56 11/7/2026
12.1.3.6 55 11/6/2026
12.1.3.5 56 11/6/2026
12.1.3.4 68 10/31/2026

Math rendering extension for MarkdownRenderX.Avalonia: registers a node renderer for Markdig math nodes and lays out LaTeX with CSharpMath (SkiaSharp), shipping Latin Modern Math so no system math font is required.