TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I google for parse tree and TeX. All I'm getting are how to draw parse trees in TeX.

I want to know if there are programs that can parse TeX, and output a parse tree that's easy to manipulate.

share|improve this question
There was once a Java project to implement the TeX parser, but AFAIK it got never finished. I'm sure the best place to look would be the book TeX: The Program. – Martin Scharrer Jun 29 '11 at 8:58
up vote 8 down vote accepted

TeX is not built along the classical compiler architecture of a scanner and a parser that builds a parse tree. (When TeX was invented these concepts where much less clear than they are today.) And since TeX does not use a parse tree internally you are unlikely to find a tool that represents TeX code accurately in such a way. If you are serious about manipulating TeX code I'd suggest you tell us what you want to achieve - maybe there is another way to do it. One tool I would consider looking at is Hevea.

share|improve this answer

Your Answer


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.