Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a TeX engine that converts a TeX document to MathML or XML directly the way PDFTeX converts text input to PDF?

I am familiar with some converters that transform a subset of TeX into something that can be viewed on a browser, but they all leave out many of the packages I used, particularly hyperref and xypic. I want a converter that passes Knuth's test for genuine TeX.

share|improve this question
    
As far as I know, it doesn't exist. tex4ht does a good job in many cases, though, with hand-written support for many packages. –  Bruno Le Floch May 24 '11 at 0:11
1  
ConTeXt supports an xml backend (that can be used to export to xhtml or epub as well). But, I guess, that you are interested in a LaTeX to XML. –  Aditya May 24 '11 at 0:31
1  
@Aditya: true, I keep forgetting that you ConTeXt guys are much further along on this than LaTeX. I think that SixWingedSeraph's question is about TeX itself, though. –  Bruno Le Floch May 24 '11 at 2:56
    
@Bruno: Although ConTeXt is able to process plain TeX input, I really doubt that it will generate any useful XML from that. To generate XML, all ConTeXt commands are use "tags" that are then translated into XML. (The standard ConTeXt command for defining new macros, \define and \definestartstop automatically insert these tags). Unless the macros used by plain TeX are redefined in terms of these tags, ConTeXt won't be able to give useful XML output. –  Aditya May 24 '11 at 4:57
1  
I doubt very much that you will ever get a genuine TeX to XML converter because TeX can do things with its output that XML can't - in particular, it can measure the size of various bits of its output and take action accordingly. Since an XML document doesn't know how it will be rendered, this would be extremely difficult to implement. That's why the converters in existence tend to work on a subset and build outwards. –  Andrew Stacey May 24 '11 at 7:17
show 8 more comments

7 Answers

tex4ht can convert to XHTML and MathML. See my answer to this question.

share|improve this answer
add comment

There's plasTeX and LaTeXML, written in Python and Perl respectively.

The KWARC group are a major user of LaTeXML.

share|improve this answer
add comment

TeX4h. It is a part of MiKTeX bundle and, perhaps, TeX Live.

share|improve this answer
add comment

You could give a try to Illumino. It can manage LaTeX files and output several output formats as:

  • Custom XML
  • Native PDF
  • PS
  • Custom HTML
  • others
share|improve this answer
add comment

I'm not sure if this TeX/LaTeX to MathML Online Translator is part of what you're looking for. It generates clunky but acceptable MathML from (La)TeX input.

share|improve this answer
add comment

As XML is just a syntax it is trivial to convert any LaTeX into XML just by creatimg a file of the form <latex>... text of latex document with < & and > replaced by &lt; &amp; &gt; ....</latex> The result is XML but perhaps not what you meant. This isn't just a silly example though, people do such translations to store blobs of TeX in XML databases.

Another conversion to XML can be got by running latex to get dvi then using dvisvgm to convert the result to SVG. Again this is XML but perhaps not the kind of XML you intended as it is positioning every character by fixed coordinate positions. It does however cope with a very wide range of TeX inputs.

If you need a conversion to something not unlike HTML. Say, XHTML for text, MathML for maths and SVG for any vector images included, then the issues relate to the nature of the HTML format: that it is expected to reflow in the client and use reader- rather than author-specified fonts in many cases, and that the rendering environment (even with javascript enabled) isn't as tightly bound to the programming structures as happens in TeX. The fact that that system uses an XML (or HTML) syntax rather than a backslash-and-brace syntax is the least of the issues involved in a translation.

If you do want to translate to XHTML+MathML, then LaTeXML is a good place to start,

share|improve this answer
add comment

With Tex4ht supplied in MikTeX, you can use mzlatex filname (without extension) for creating the xml extension file. You can clean with some scripts according to your requirements.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.