0

I want my program to read a mathematical expression from standard input and print a bitmap with the expression formatted similarly to how Latex does this. Input is limited to simple expressions, that is, consisting of arithmetic operators, subscripts, superscripts and fraction bars.

For now, the program can interpret an expression and store it as a tree. The only problem I do not know how to solve is how to divide a plane into sections/boxes in order to print the expression on a bitmap properly. The biggest problem is with subscripts, superscripts (downscaling and placing symbols higher or lower), fraction bars and the fact that it has to work well recursively for example abcd

I would be grateful for an answer. I have tried to find a similar problem on the web, but nobody seems to have asked a question like this before.

TGR
  • 3
  • 2
  • This is too broad a question for Stack Overflow. For part of a simple approach, consider a function that draws an expression in a given rectangle of a bitmap. For expressions with subexpressions, such as fractions and superscripts, it would call itself recursively to draw the subexpressions in appropriate rectangles within the rectangle it was given. – Eric Postpischil Jan 21 '19 at 00:49
  • I'd consider a function to convert your equation parse tree to TeX and then use tex2png. Or to a troff style eqn file, mathml, etc. – Shawn Jan 21 '19 at 01:12

0 Answers0