The title pretty much says it all. If it helps, I found myself asking this question when reading this post about \par vs. \\.
2 Answers
Not so short answer (too long for a comment), but not really long on the other hand.
TeX primitives are the elementary particles
of TeX Universe. They are not and can't be constructed of other command sequences. Those primitives are given already by the TeX engine and are not defined in plain.tex
(or in latex.ltx
for the LaTeX version). These days, the most commonly used TeX engines are pdftex, xetex, and luatex.
A macro, in contrast, is set up using TeX primitives (such as \def
) and/or other macros which, in turn, use still other primitives. You can find macros in the file plain.tex
(the Plain-TeX core), in latex.ltx
(the LaTeX kernel), as well as in various .cls
and .sty
package files and inline
in many documents.
Prominent primitives are \let
, \par
, \box
, \hskip
, \vskip
, \def
(and its variants \edef
etc.), \expandafter
etc. The list is too long to name all here.
It is, in principle, possible to redefine \par
via \def\par{...}
, for example. However, this is not advisable in most cases. Use \let\oldpar\par
to save the meaning of \par
before doing something weird to the TeX system ;-)
Common to both primitives and macros is that they are command sequences which sometimes have arguments.
TeX is a macro-expansion language. That means that what we can define as programmers is a series of macros which get replaced at point-of use by their definition. Thus with
\def\foo{\baz ab}
when I use \foo
TeX replaces it with \baz ab
then looks a \baz
to find what it is defined as. That might be another macro, it might be some literal text (such as the ab
) or it might be a primitive. That's a command that is built-in to TeX and so is executed rather than expanded. Thus for example the \par
primitive is an instruction to TeX to do some typesetting.
There are a few provisos to the above. First, we can define names that are the same as primitives
\let\oldfpar\par
\def\par{...
which can be used for various effects. That is an important technique, but notice I've saved the original form so I can still get at the primitive.
Secondly, whilst I've said that primitives are executed, some of them are 'expandable' and so do get replaced in some way by a 'result'. The \par
primitive isn't one of those (typesetting can't be thought of as 'providing a replacement text), but for example all of the conditionals (\if...
) are.
Thirdly, we can create control sequences ('commands') which are not macros. We've already seen \let
, which copies a control sequence meaning to a new name so can be used for primitives as well as macros. We can also do things like \chardef
, which makes a control sequence equal to a character or rather to a character number.
You can see what the current definition of something is using \show
. So with
\show\par
\let\oldpar\par
\def\par{\oldpar}
\show\par
I get
> \par=\par.
l.1 \show\par
?
> \par=macro:
->\oldpar .
l.4 \show\par
Notice in the first case I have the control sequence \par
equal to the primitive \par
, whilst in the second case it's a macro. That can lead to some odd effects:
\let\savedshow\show
\let\show\par
\let\par\savedshow
\par\show
\par\par
yields
> \show=\par.
l.4 \par\show
?
> \par=\show.
l.5 \par\par
?
The key point here is that the 'internal' name of the primitive (the name TeX uses for the action it means) never changes.