12

I have a very simple application that is generating equations, very simple ones, like

  • 4 + 5 = x
  • x + 4 = 12
  • 15 / x = 3
  • x^2 = 4
  • sqrt(6) = x

When I display it to myself equations like x + 4 = 12 is fine, I can read it pretty well but it would be nice if x^2 = 4 would be displayed as it x2 = 4. It does not have to be as image, it could be anything else, but it should be so user can understand the equation.

Is there is some library that can help me with that?

Mike Nakis
  • 56,297
  • 11
  • 110
  • 142
Stan
  • 25,744
  • 53
  • 164
  • 242
  • 1
    A couple similar questions that may help you: http://stackoverflow.com/questions/775168/math-equations-on-the-web and http://stackoverflow.com/questions/4877638/pretty-printing-math-in-c-sharp-desktop-application – Jason Down Jan 08 '12 at 14:45
  • Can you just to a string replace for `^2` into `²` and the rest? – John Alexiou Jan 08 '12 at 15:53

3 Answers3

6

You could add a MathML library to your application. This is a general math formatting library. MathML in C# The examples also include non-xml defined equations.

Another library you could be looking for should be LaTeX for C#, although, I'm not sure if this has been written yet.

  • 1
    I looked at the link that you provided and it appears that it is not a MathML renderer: it simply takes equations which have been expressed in MathML and it converts them into C# code which implements (computes) the equations. The author does not want to compute the equations, he wants to render the equations to look nice. – Mike Nakis Jan 08 '12 at 15:03
2

The second link provided by Jason Down Pretty printing math in C# desktop application will probably do what you want, although you should be prepared to get your hands dirty with P/Invoke.

Another alternative for you would be to express your equations in MathML, find a web browser which supports MathML, render them in there, and then print them from within the browser or take screenshots of them.

Community
  • 1
  • 1
Mike Nakis
  • 56,297
  • 11
  • 110
  • 142
0

You may want to look into the Unicode character set to display things like power of two or square root. It would be limited to existing characters but otherwise pretty simple. You would need to take care that the font displays the characters in question (Arial Unicode MS displays the complete set and comes with Windows 7).

ILoveFortran
  • 3,441
  • 1
  • 21
  • 19