I would like to know if there is some manual from which I can learn the bases of LaTeX programming language. I need something universal, not related to some specific package or class, that at the end allow me to have a look at various source files, to understand the code in them and even to modified some file or to create my own source files of packages or classes.

I am not a beginner user of LaTeX. I have written a lot of documents using LaTeX with some standard classes and packages and with more exotic ones. What I want is not a manual that tells me how to write a document with LaTeX but how LaTeX works at its bases.

For example what are macros and how to use them, how to use command like \def, \if, \ifx, \fi, \global, \let, \relax, the key @, \DeclareOption, \begingroup, etc... (I have only open the file article.cls and check for command that I don't know..)

  • 1
    Have a look at this question What is the best book to start learning LaTeX?
    – ach
    Jun 24 '13 at 14:41
  • @ach: I checked your link but there I find only manuals for "writing documents using LaTeX". Maybe my question is not so clear, I'll try to modify it
    – Red
    Jun 24 '13 at 14:50
  • 2
    In which case, look at source2e.pdf, describing the LaTeX source in detail (found on most *TeX installation via texdoc source2e).
    – ach
    Jun 24 '13 at 15:02
  • 7
    You're lucky: profs.sci.univr.it/~gregorio/introtex.pdf (in Italian) ;-)
    – egreg
    Jun 24 '13 at 15:02
  • You can read the source code of TeXBook that is available from CTAN here. Jun 24 '13 at 15:03

The LaTeX2e kernel and LaTeX2e packages are written in a mixture of TeX primitives and some plain TeX macros, LaTeX2e document-level commands, LaTeX2e package/class commands and 'internal' code. Documentation is therefore split up:

  • The TeXbook for TeX primitives and 'utility' plain TeX macros (TeX by Topic also highly recommended)
  • LaTeX: A Document Preparation System for document level commands
  • Class guide for package/class commands
  • Individual .dtx files for 'internal' commands (may have documentation, may just have code)

As such, there is no one document to read to understand programming LaTeX2e. One of the aims of the LaTeX3 Project is to provide a single programming layer for the future: expl3.


The LaTeX Wikibook has information about macros and plain TeX, although I don't know if they'll be detailed enough for your needs. But it might be worth a look, and you can always add something if necessary!

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.