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.

I'm a programmer, I would like to take a look at a more technical and specific definition of what is referred to as LaTeX or TeX.

My interest in on syntax, semantics, and the grammar of this language in general, I also would like a word about the packages which I assume are part of some kind of plugin-like extensible-system and I would also like to know how this interaction is defined.


share|improve this question
The complete source code of tex, with extensive documentation to say the least, is available via the shell command texdoc tex. –  Sean Allred Dec 23 '13 at 2:01
Macro expansion, basically. And rules on when they happen. :) –  Paulo Cereda Dec 23 '13 at 13:20

1 Answer 1

up vote 24 down vote accepted

The grammar of each TeX command is more or less completely given in The TeXBook. Note, however, that unlike most programming languages the lexical analysis and tokenisation of the input cannot be separated from execution as the catcode table which controls tokenisation is dynamically changeable. Thus parsing TeX tends to defeat most parser generation tools.

LaTeX is a set of macros written in TeX so is defined by its implementation, although there is fairly extensive documentation in The LaTeX Companion, the LaTeX book (LaTeX: A Document Preparation System), and elsewhere.

Packages are not really plugin-like which usually implies some sort of binary API. They are (mostly) source level inclusion of macro definitions so more like #include (if you know the C pre-processor macro system) than anything else.

share|improve this answer
thanks, could you link to some actual doc ? what is this catcode code table ? –  user2485710 Dec 23 '13 at 1:02
@user2485710 You can find out more about catcodes in ch.7 of the TeXbook. –  Jubobs Dec 23 '13 at 1:06
@user2485710 See tex.stackexchange.com/questions/100060/… for more details on the different editions of the TeXbook. –  Jubobs Dec 23 '13 at 1:25
@user2485710 The TeXBook has gone through several reprints fixing errata but is essentially unchanged since TeX3 came out in 1986 or so, it is very rare that anyone has to refer to a specific printing of the book, the errors tend to be very esoteric and the changes very minor. If you are buying it just buy whatever the publisher says is the latest reprint. If you are borrowing it, don't worry about it, chances are it doesn't matter which version you have. –  David Carlisle Dec 23 '13 at 1:43
@user2485710: This might be a good reference for you: tex.stackexchange.com/a/4205/3094 Beware, hic sunt leones. :) –  Paulo Cereda Dec 23 '13 at 13:58

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.