8

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.

13
  • 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. Commented May 24, 2011 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
    Commented May 24, 2011 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. Commented May 24, 2011 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
    Commented May 24, 2011 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. Commented May 24, 2011 at 7:17

8 Answers 8

7

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

4

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

The KWARC group are a major user of LaTeXML.

3

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
2

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

2

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.

2

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,

2

Please have a look at http://www.texfolio.org

TeXFolio is a web-based typesetting framework. It can output your TeX document which is structured according to the TeXFolio coding scheme to Elsevier DTD XML/MathML or JATS XML/MathML. It has lot of other features also.

1
  • Is this link still available? Kindly suggest.
    – MadyYuvi
    Commented Aug 12 at 11:13
-1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .