# [NTG-context] TeX syntax -- a guide?

Thomas A. Schmitz thomas.schmitz at uni-bonn.de
Thu Feb 25 22:39:37 CET 2010

```On Feb 25, 2010, at 9:39 PM, James Fisher wrote:

> Hi,
>
>
> After a few days working in "do what the tutorials say" mode, I now want to understand TeX from a programmer's mindset.  I have not been able just by practise to work out what the syntactic rules of TeX are, and I am hoping that there is a sensible guide to this somewhere.  However, searches for things like "tex syntax" draw a blank.  Some of the things I want to understand, for example, are: (1) what is the distinction between square brackets and curly brackets after a command?  (2) Why are there sometimes lists of square-bracketed lists after a command, each with lists of seeming arguments inside them?  (2) What exactly are the "variables" in a TeX file? (I've seen variable-like things sometimes referred to just plainly, sometimes with preceding backslashes as if they were commands/macros).  (4) Why can't I end a square-bracketed section with a final square-bracket on a line of its own, as I may do in other programming languages?  (5) How are things like \subsection, \subsubsection, \subsubsubsection, ... implemented?  I am used to languages in which there is only a finite set of commands; why is the logic here not more like \section[level=1], \section[level=2], ... ?  (6) Perhaps I'm misunderstanding things and all this isn't actually the fundamental syntax of TeX but just adhoc syntax defined by various macros doing different things -- is this the case; to what degree can macros define syntax?
>
> Obviously I don't expect answers to all these here, but can someone point me to somewhere on the 'net that could answer them? The only other possibilities I can see are buying an expensive copy of the TeXbook, etc.
>
First, you're confusing two things: TeX syntax and ConTeXt syntax. Most of what you're asking here has to do with the way ConTeXt implements things. For starters, I would recommend http://wiki.contextgarden.net/Inside_ConTeXt, especially the overview about System Macros.