why not use the mathml? I'd like to mention gtkmathview in this connection, by Luca Padovani. He carefully applies TeX math formatting rules (Appendix G) to MathML. http://tug.org/TUGboat/Articles/tb24-1/padovani.pdf (I haven't used the program, I just edited the paper.) k