System Macros/Mnemonics and Aliases

From Wiki
Jump to navigation Jump to search

< Prev: Fundamentals | Top: System Macros | Next: Scratch Variables >

Mnemonics and aliases

Category codes

ConTeXt sometimes manipulates the <catcodes> of certain characters. Catcode values have predefined meanings, but TeX expects them to be given as bare numbers, and the precise mapping of functionality to numbers is hard to remember. Therefore, ConTeXt introduces some symbolic names. This makes it easier to key in things like this:

\catcode'\@=\@@letter

The mnemonics that are defined are

\chardef\@@escape      =  0
\chardef\@@begingroup  =  1
\chardef\@@endgroup    =  2
\chardef\@@mathshift   =  3
\chardef\@@alignment   =  4
\chardef\@@endofline   =  5
\chardef\@@parameter   =  6
\chardef\@@superscript =  7
\chardef\@@subscript   =  8
\chardef\@@ignore      =  9
\chardef\@@space       = 10
\chardef\@@letter      = 11
\chardef\@@other       = 12   \chardef\other  = 12
\chardef\@@active      = 13   \chardef\active = 13
\chardef\@@comment     = 14

If you don't understand the names of the macros, you can look them up in the TeXbook.

Two of these symbolic names are actually used so often that they even have non-protected aliases: \other and \active.


NOTE: Beware: if you want to have access to @, !, and ? in macronames, use
\unprotect
\def\My@@MAcro{..}
\protect

instead of manipulating the catcode of @ directly. The protection macros handle nested usage.


Stored primitives and macros

ConTeXt often needs to use or redefine commands that are explained in the TeXbook (be they primitives, or macros from the plain format). ConTeXt sometimes defines commands with those names itself, and sometimes it cannot be sure that such commands are not redefined by a user, so it saves quite a large number of these commands internally under a different name. For this, it uses their canonical name, prefixed with normal.

An example: a command that is often needed is a space macro as defined in Plain TeX. Because ConTeXt cannot be sure that \space is not redefined, it uses the alias \normalspace. When dealing with ConTeXt, please refrain from (re-)defining macros that start with \normal.... Weird, unexpected things can - and probably will - happen if you do.

The full list is too long to repeat here, but it includes at least: all of the \if-related statements, all of the kerning and glue related commands, all of the box typesetting commands, all of the font definition commands, and quite a few math commands like \left and \right, \over, and \in.

Numerical constants

Because using a single command is sometimes easier to handle in a macro than the actual digits of a number, there are a few constants predefined (some of which are inherited from the plain format):

\minusone        =    -1
\zerocount       =     0
\plusone         =     1 \@ne             =     1
\plustwo         =     2 \tw@             =     2
\plusthree       =     3 \thr@@           =     3
\plusfour        =     4 \@iv             =     4
\plusfive        =     5
\plusten         =    10
\sixt@@n         =    16
\@cclv           =   255 
\@cclvi          =   256
\@xc             =    90
\plushundred     =   100
\@clxx           =   180
\plusthousand    =  1000 \@m              =  1000
\plustenthousand = 10000 \@M              = 10000
\@MM             = 20000

In cases where there is both a user command and an internal command, like in \plusone versus \@ne, use of the user command is prefered.

< Prev: Fundamentals | Top: System Macros | Next: Scratch Variables >