The iOS front end for CSharpMath.

math, mathematical, formula, mathematics, equations, equation, expression, tex, latex, render, display, rendering, xamarin, ios, dotnet
Install-Package CSharpMath.Ios -Version 0.3.0-beta2


Ever wanted to display LaTeX math formulae in C# but cannot find any tool to help you? Here is what you may be looking for.


CSharpMath is a C# port of the wonderful iosMath LaTeX engine.

The icon's text and numbers are generated with this library itself.

Current release Current pre-release Commits since last version Number of contributors
NuGet: NuGet Release shield
GitHub: GitHub Releases shield
Date: GitHub Release date shield
NuGet: NuGet pre-release shield
GitHub: GitHub Pre-releases shield
Date: GitHub Pre-release date shield
GitHub commits since last version shield GitHub Contributors shield

Ironically enough, the first front end was iOS (CSharpMath.Ios). As development continued, Xamarin.Forms (CSharpMath.Forms) is now supported via SkiaSharp (CSharpMath.SkiaSharp) as of 0.1.0.

Usage and Examples

To get started, do something like this:

1. CSharpMath.Ios

var latexView = IosMathLabels.MathView(@"x = -b \pm \frac{\sqrt{b^2-4ac}}{2a}", 15);
latexView.ContentInsets = new UIEdgeInsets(10, 10, 10, 10);
var size = latexView.SizeThatFits(new CoreGraphics.CGSize(370, 180));
latexView.Frame = new CoreGraphics.CGRect(0, 20, size.Width, size.Height);

See an example project

Quadratic Formula Power Series
Matrix Product Continued Fraction

2. CSharpMath.Forms

<ContentPage xmlns=""
    <math:FormsMathView x:Name="View" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">

or you can use the prehistoric way:

var view = new FormsMathView();
view.HorizontalOptions = view.VerticalOptions = LayoutOptions.FillAndExpand;
view.LaTeX = @"\frac\sqrt23";

See an example project

iOS Android Windows UWP
1/2 1+1 Panning a view Colors!


Extending to more platforms

There are a few ways to extend this to more platforms: (Hopefully, you would not need to touch the core typesetting engine. If you do, we would consider that a bug.)

1. Branching off from CSharpMath (the project)

This path would require the most effort to implement, but allows you to plug in any font library and graphics library.

You would have to define your own TypesettingContext and write an implementation of IGraphicsContext.

The TypesettingContext in turn has several components, including choosing a font.

2. Forking from CSharpMath.Rendering

As CSharpMath.Rendering provides font lookup through the Typography library, you would only need to write adapter classes to connect this library to your chosen graphics library.

You would have to implement ICanvas and feed it into the Draw method of MathPainter.

3. Referencing CSharpMath.SkiaSharp

You can extend this library to other SkiaSharp-supported platforms by feeding the SKCanvas given in the OnPaintSurface override of a SkiaSharp view into the Draw method of SkiaMathPainter.

4. Building on top of CSharpMath.Apple

You can use this library on other appleOSes by making use of AppleMathView.

Project needs

We need more contributors! Maybe you can contribute something to this repository. Whether they are bug reports, feature proposals or pull requests, you are welcome to send them to us. We are sure that we will take a look at them!

Here is an idea list if you cannot think of anything right now:

  • A new example for the Example projects (please open pull requests straight away)
  • A new LaTeX command (please link documentation of it)
  • A new front end (please describe what it is and why should it be supported)
  • A new math syntax (please describe what it is and why should it be supported)


CSharpMath is licensed by the MIT license.

Dependency Used by License
Typography project CSharpMath.Rendering MIT
latin-modern-math font CSharpMath.Ios, CSharpMath.Rendering GUST Font License
AMS-Capital-Blackboard-Bold font (extracted by @Happypig375 from the amsfonts package) CSharpMath.Rendering SIL Open Font License






Thanks for reading.