Mathematica-like (LaTeX) typesetting for own CAS application

1.4k views Asked by At

As I am using Mathematica a lot I got the idea to write a small and free CAS which just exposes a very small subset of necessary functions and packages to be used and I want to present the results in an appropriate way to the user like Mathematica does (ignore the Facebook logo in the background :D ):

Mathematica's Output

My first idea was to create LaTeX code in the background and to pdflatex the source and include the PDF then in the view... however this seems way to much overkill! I want to write this CAS either in C++ or C# and I want to know if there are any recommended solutions to output nice formula like that.

My first thought was a "real-time formula editing view" but it would be ok to have an input box to enter the commands and formulas and the upper view just to be uneditable output.

2

There are 2 answers

2
Yuji On BEST ANSWER

A few ways come to my mind.

  1. Use LaTeX behind the scenes to typeset equations, as you say. Again, Cadabra does this.
  2. Use TeXmacs as the front end. Cadabra does this.
  3. Use MathJax. This is a javascript framework which renders TeX equations to images or MathML. It's very easy to use it if you have a HTML view in your UI toolkit. MathJax is used in the sister site MathOverflow, for example.

I find the route 3 is the most attractive.

0
Paŭlo Ebermann On

For calling LaTeX in the background, don't use pdflatex, but use the non-PDF latex to produce a DVI file, and convert it then to PNG with dvipng.

Have a look at the preview package or the standalone class to get the output in the right size (i.e. only the formula, not a whole page).