Skip to content

LaTeX. in C#. (ported from the wonderful iosMath project).

License

Notifications You must be signed in to change notification settings

Gillibald/CSharpMath

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

icon

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

Current NuGet version Current stable version Commits since last version
NuGet release shield GitHub Releases shield GitHub commits since last version 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);
someSuperview.Add(latexView);

See an example project

Quadratic Formula

Power Series

Matrix Product

Continued Fraction

2. CSharpMath.Forms

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:math="clr-namespace:CSharpMath.Forms;assembly=CSharpMath.Forms"
             x:Class="Namespace.Class">
    <math:FormsMathView x:Name="View" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
        \frac\sqrt23
    </math:FormsMathView>
</ContentPage>

or you can use the prehistoric way:

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

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 Exmple 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)

License

CSharpMath is licensed by the MIT license.

Dependency Used by License
latin-modern-math font CSharpMath.Ios, CSharpMath.Rendering GUST Font License
Typography project CSharpMath.Rendering MIT

Authors

@verybadcat

@Happypig375

@charlesroddie

@FoggyFinder

Thanks for reading.








































































You can take a look at the code now.















































































































Really, there is nothing here.







































































































































































I bet you scrolled past and came back to read me.



































































































Will you stop scrolling?
































































































Ok, fine... I give up.

A sneak peek at the future?

Shhh... Don't tell anybody!

Future? 0.2.0: MathML? 0.3.0: AsciiMath? 0.4.0: Infix?

0.4.0: Math evaluation?? 0.5.0: Handwritten math recognition???

About

LaTeX. in C#. (ported from the wonderful iosMath project).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 99.9%
  • PowerShell 0.1%