[Tex/LaTex] \@ne \tw@ \thr@@

macrostex-core

The LaTeX (2e) source code is quiet hard to read. There are a lot of macros with @ symbol. I understand those are "latex macros".

There is, in particular, a series of macros called \@ne, \tw@, \thr@@ (and maybe more). Their \meaning is \char"1, \char"2, \char"3. I wonder (1.) how and where those are defined?

Further interests:
They seem to be used mainly to identify internal registers. "The Texbook" mentions that there are 256 internal registers of each type, e.g. \box0\box256. So which register does \box\@ne denote?

After reading Martin's answer I reached to the texbook, page 121:

Besides
\newcount, plain TEX provides
\newdimen, \newskip, \newmuskip, and
\newbox; there also are \newtoks,
\newread, \newwrite, \newfam, and
\newinsert, for features we haven’t
discussed yet. Appendices B and E
contain several examples of the
proper use of allocation. In the cases
of \newbox, \newread, etc., the
allocated number is defined by
\chardef. For example, if the command
"\newbox\abstract" is used to define a
box register that will contain an
abstract, and if the \newbox operation
decides to allocate \box45 for this
purpose, then it defines the meaning of
\abstract by saying
"\chardef\abstract=45". TEX allows
\chardef’d quantities to be used as
integers, so that you can say
\box\abstract and \copy\abstract, etc.
(There is no \boxdef command.)

… so \box\@ne is equal to \box1 ?

Best Answer

They are defined in latex.ltx starting from line 293:

\chardef\@ne=1
\chardef\tw@=2
\chardef\thr@@=3
\chardef\sixt@@n=16
\chardef\@cclv=255

And then on line 316:

\countdef\m@ne=22 \m@ne=-1

They are defined to reduce the numbers of tokens in the source code.

Edit:

To answer your 2nd, later added question "... so \box\@ne is equal to \box1?"

Yes!

Supplement:

There are also the very useful \p@ and \z@, also defined in latex.ltx lines 353 and 354 (with original comments):

\newdimen\p@ \p@=1pt % this saves macro space and time
\newdimen\z@ \z@=0pt % can be used both for 0pt and 0

Example: I encountered recently the expression \wd\z@\z@ which at first confused me quite a bit. It means: "set the width of box 0 (\z@ taken as integer) to 0pt (\z@ used as dimension as normal). The longer form would be \wd0=0pt (6 tokens instead of 3).

Also \p@ is very often used to add the 'pt' after a floating point number: 1.2345\p@ is 1.2345pt (actually 1.2345 x 1pt).

See also:

In the meantime I compiled a list of these and more macros.