Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LaTeX renderer for .NET?

I'm curious as to whether a native .NET renderer for TeX/LaTeX exists. The closest match I have been able to find is a Java implementation, JMathTeX. I am tempted to port this to C#, but before I do so, I would simply like to check whether anyone is aware of a .NET implementation out there.

My current thoughts are to use MiKTeX along with dvipng to compile the TeX source and render the generated DVI as a PNG, but I'm still worrying this may incur an unacceptable amount of overhead, not to mention the need to bundle MiKTeX with the given program.

like image 954
Noldorin Avatar asked Oct 01 '09 00:10

Noldorin


3 Answers

A pure C# implementation of Latex by verybadcat.

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

It is now working in most cases. Some examples are below. Ironically enough, the first front end is iOS. However, if you want to add a front end, such as Xamarin.Forms or a Windows environment, it should be possible. 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. Hopefully, you would not need to touch the core typesetting engine. (If you do, I would consider that a bug.)

CSharpMath example

like image 151
zwcloud Avatar answered Oct 21 '22 17:10

zwcloud


This is very overdue, but I thought I'd post a link to a revived and expanded port of the WPF-Math project, which I started not too long after this original question, and still help maintain in a minor capacity. It was originally a port of JMathTex, but has since expanded to include a lot more. At the moment, it's in the process of gaining renderers other than WPF.

like image 39
Noldorin Avatar answered Oct 21 '22 17:10

Noldorin


If I'm not mistaken, TeX is written in a dialect of Pascal, and when compiled today it's generally first compiled into standard C, then compiled with a C compiler to produce the final binary. It might be feasible to instead compile the original Pascal code into C# and perhaps write a wrapper around it in C# to be able to use it as a library.

Of course this is a rather large project to take on and is probably overkill for your problem at hand.

like image 2
nielsm Avatar answered Oct 21 '22 17:10

nielsm