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.


  • 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

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.

  • thanks, could you link to some actual doc ? what is this catcode code table ? – user2485710 Dec 23 '13 at 1:02
  • 1
    @user2485710 You can find out more about catcodes in ch.7 of the TeXbook. – jub0bs Dec 23 '13 at 1:06
  • 1
    @user2485710 See tex.stackexchange.com/questions/100060/… for more details on the different editions of the TeXbook. – jub0bs Dec 23 '13 at 1:25
  • 9
    @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
  • 2
    @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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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