I started learning LaTeX and these words appear a lot in both questions and answers. Do they all mean the same thing or are they different concepts?
-
1You may want to start reading TeXbook/TeX by topic, the concepts are quite clearly explained there. // See also package writing - Where do I start LaTeX programming? - TeX - LaTeX Stack Exchange for other resources. – user202729 Oct 25 '22 at 13:46
-
2You can read a brief summary of TeX principles in "TeX in a Nutshell" http://petr.olsak.net/ftp/olsak/optex/tex-nutshell.pdf – wipet Oct 25 '22 at 13:58
-
besides TeX in a Nutshell, which is fairly terse, and TeX by Topic, which might be too verbose, you may read sections 4-10 from TeX for the Impatient, available at your local CTAN mirror. – jarnosc Oct 26 '22 at 14:55
1 Answers
A "primitive" is a command defined by the tex system. So for example \hbox if you ask tex how this is defined
\show\hbox
You get
> \hbox=\hbox.
l.1 \show\hbox
?
Note that the csname \hbox can be given a non-primitve definition. After \def\hbox{abc} the above would produce
> \hbox=macro:
->abc.
l.2 \show\hbox
?
Similarly the primitive functionality can be assigned to other names. After \let\qqqq\hbox then \show\qqqq would produce
> \qqqq=\hbox.
l.2 \show\qqqq
?
A register is a specific storage location, these are addressed by number, originally 256 of each type but etex extends this to 2^15 (over 32 thousand) and luatex extends this again.
So integer values can be stored in \count50, lengths (dimen(sions)) can be stored in \dimen222 etc. Usually a format such a latex provides allocation routines so that you do not deal with numbers directly eg \newdimen\textwidth makes \textwidth access a dimen register and the following \newdimen would access the next. \show\textwidth produces (in latex)
> \textwidth=\dimen116.
l.1 \show\textwidth
?
A macro is a command defined by \def which expands to it' replacement text. It is defined by TeX code not part of the tex program source. After \def\cmd{abc} \show\cmd produces
> \cmd=macro:
->abc.
l.2 \show\cmd
?
- 757,742