# \@ne \tw@ \thr@@

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?

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 deﬁned by \chardef. For example, if the command "\newbox\abstract" is used to deﬁne a box register that will contain an abstract, and if the \newbox operation decides to allocate \box45 for this purpose, then it deﬁnes 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 ?

-
It's \@ne not \@one. There is also \m@ne for -1. Edit: You have it correct in the text but not in the headline. – Martin Scharrer Jan 27 '11 at 11:00
Welcome to Tex.se, and good question! I took the liberty of formatting your post a bit. Take a look at the Editing Help page for tips. – Matthew Leingang Jan 27 '11 at 11:47
BTW, the @ macros are in plain TeX as well. Just open your TeXBook to Appendix B. – Matthew Leingang Jan 27 '11 at 11:48
See also this tex.stackexchange.com/questions/6460/… – Yiannis Lazarides Jan 27 '11 at 11:49
o-o ... lots to read still ... thanks @Matthew for the hint to Appendix B – Patrick2000 Jan 27 '11 at 11:53

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).

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

-
which speeds up compilation time – Herbert Jan 27 '11 at 11:14
and makes it possible to use them as macro arguments without braces. I forget to mention that as well. – Martin Scharrer Jan 27 '11 at 11:16
ok, thanks a lot to martin and herbert! i don't yet see how replacing "1" by "\@ne" either reduces the number of tokens (1 and 1 ?) or enables macro arguments without braces though. "1" is one token, so how do "\box1bla", "\box\@ne bla" and "\box{1}" (which i think will not work anyway) differ ? – Patrick2000 Jan 27 '11 at 11:25
@Patrick: From Appendix B: "(Notice that the long form of \@ne is ‘1 ’ including a space, because TeX looks for and removes a space following a constant.)" – Hendrik Vogt Jan 27 '11 at 13:47
I looked into this a little more and figured that all macros defined using \chardef are not expandable (the act like primitives). If used in an context where TeX scans for a number (e.g. \ifnum, assignments) it successfully terminates the scanning process, so that no other macro behind it are expanded. Like Hendrik said it acts like '1 ', but still is different as \def\@ne{1 } because of the unexpandability. – Martin Scharrer Jan 29 '11 at 22:23

One thing that I like about ConTeXt is that such internal macros are named in a more readable manner. For example, the corresponding definitions in ConTeXt are:

\countdef   \zerocount              =   120 \zerocount              =  0
\countdef   \plusone                =   121 \plusone                =  1
\countdef   \minusone               =   122 \minusone               = -1


and

\chardef    \plustwo            =     2
\chardef    \plusthree          =     3
\chardef    \plusfour           =     4
\chardef    \plusfive           =     5
\chardef    \plussix            =     6
\chardef    \plusseven          =     7
\chardef    \pluseight          =     8
\chardef    \plusnine           =     9
\chardef    \plusten            =    10
\chardef    \plussixteen        =    16
\chardef    \plushundred        =   100
\chardef    \pluscxxvii         =   127
\chardef    \pluscxxviii        =   128
\chardef    \pluscclv           =   255


These are not "protected", so the user can redefine them. So, ConTeXt does not prevent you from shooting yourself in the foot. There is a protected version of some of the these (defined as macros rather than counters; I don't know the implication on efficiency):

\def\!!zerocount {0} % alongside \zerocount
\def\!!minusone {-1} % alongside \minusone
\def\!!plusone   {1} % alongside \plusone
\def\!!plustwo   {2} % alongside \plustwo
\def\!!plusthree {3} % alongside \plusthree


These are much easier to read than the corresponding plain TeX definitions (that are more or less copied in LaTeX).

-
As macros, I think they're going to be slower since it has to expand the macro, see the number and then keep expanding macros looking for more numbers or the optional space. I guess you could use \!!plusthree\!!plusone to get 31, but that seems sort of silly. – TH. Jan 27 '11 at 21:23