List of Internal L TEX2e Macros Useful To Package Authors: Martin@scharrer-Online - de
List of Internal L TEX2e Macros Useful To Package Authors: Martin@scharrer-Online - de
Authors
Compiled by Martin Scharrer
[email protected]
Version 0.4 July 23rd 2011
Abstract
This document lists the internal macros defined by the LATEX2e base files which
can be also useful to package authors. The macros are hyper-linked to their description in source2e. For this to work both PDFs must be inside the same directory.
This document is not yet complete in content and format and may miss some
macros.
Contents
1 Constants
1.1 Number Constants .
1.2 Dimension Constants
1.3 String Constants . .
1.4 Token Constants . .
1.5 Other . . . . . . . .
.
.
.
.
.
2
2
2
3
3
3
2 Variables
2.1 Temporary Variables . . . .
2.2 Dimension Variables . . . .
2.3 String and Other Variables .
4
4
4
5
3 Macros
3.1 Macro Definition . . . . . .
3.2 Expanding/Gobbling Arguments . . . . . . . . . . . .
5
5
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3.3
3.4
3.5
3.6
3.7
3.8
3.9
3.10
3.11
3.12
3.13
3.14
3.15
3.16
3.17
3.18
Lists . . . . . . . . . . . . .
Loops . . . . . . . . . . . .
Colors . . . . . . . . . . . .
Auxiliary Macros . . . . . .
Catcodes . . . . . . . . . . .
Messages . . . . . . . . . . .
Dimensions, Length and Skips
Class and Package Options .
Files . . . . . . . . . . . . .
Saved plainTEX primitives .
Fonts . . . . . . . . . . . . .
Paragraph . . . . . . . . . .
Space Hack . . . . . . . . .
Boxes . . . . . . . . . . . .
Base Conversion . . . . . . .
Conditionals . . . . . . . . .
6
7
7
7
8
8
9
9
10
11
12
12
12
13
13
14
1
1.1
Constants
Number Constants
Some of the following integer values are defined using \countdef (for 1), \chardef (for
values between 0255) and \mathchardef (> 255). They are robust and do not expand
in an \edef context. When used on the right side of an assignment the act the same
way as a count register. The \m@ne is a real count register and can still be modified, but
doing so would certainly break various code. In the terms defined by The TeXbook, this
integer constants yield internal integers rather than integer denotations.
The other numbers are defined as normal macros, which will simply expand to the containing number. They were defined to be used to set font sizes, which explains the non-integer
numbers. Please note that if they are used for an assignment or other numeric context
(e.g. \ifnum) TeX will keep expanding the following tokens until a non-numeric token is
found.
1.2
Macro
Value
Defined using
Macro
Value
Defined using
\@ne
\tw@
\thr@@
\sixt@@n
\@xxxii
\@cclv
\@cclvi
\@m
\@M
\@Mi
\@Mii
\@Miii
\@Miv
\@MM
1
2
3
16
32
255
256
1000
10000
10001
10002
10003
10004
20000
chardef
chardef
chardef
chardef
chardef
chardef
mathchardef
mathchardef
mathchardef
mathchardef
mathchardef
mathchardef
mathchardef
mathchardef
\@vpt
\@vipt
\@viipt
\@viiipt
\@ixpt
\@xpt
\@xipt
\@xiipt
\@xivpt
\@xviipt
\@xxpt
\@xxvpt
5
6
7
8
9
10
10.95
12
14.4
17.28
20.74
24.88
def
def
def
def
def
def
def
def
def
def
def
def
\m@ne
countdef
Dimension Constants
The following dimension and skip constants are defined using registers. They must not
be changed.
Macro
\p@
Value
1pt
Defined using
Notes
newdimen
\z@
0pt newdimen
\maxdimen 16383.99999pt newdimen
Macro
Value
Defined using
\z@skip
0pt plust0pt minus0pt newskip
\hideskip
1000pt plus 1fill newskip
\@flushglue
0pt plus 1fil newskip
2
Notes
negative but can grow
1.3
String Constants
The following macros hold common strings and are fully expandable. Some special characters are defined here as their verbatim ASCII representation. This makes them useful
if such characters are to be written into an auxiliary file.
Macro
Value
Note
One space
An explicit space (catcode 10 space).
Four spaces
Contains 4\space.
Empty string Commonly used to define empty macros using
\let.
\@empty
Empty string Same as above. Used by the LATEX kernel commands.
\@backslashchar \
Backslash with catcode 12 (other), i.e. simple
ASCII backlash usable in e.g. \write.
\@percentchar
%
Percent character with catcode 12 (other), i.e. simple ASCII percent usable in e.g. \write.
\@charlb
{
Left brace with catcode 11 (letter).
\@charrb
}
Right brace with catcode 11 (letter).
\@clsextension
cls
Used for comparison with \@currext.
\@pkgextension
sty
Used for comparison with \@currext.
\@depth
depth
Used for box size declarations (\hb@xt@).
\@height
height
Used for box size declarations.
\@width
width
Used for box size declarations.
\@minus
minus
Used for skip declarations.
\@plus
plus
Used for skip declarations.
\space
\@spaces
\empty
1.4
Token Constants
The following macros are defined using \lethmacroi=htokeni and therefore equal to this
token. They are useful for \ifx comparisons with tokens read by \let or \futurelet.
Name
Token Catcode
\@sptoken Space
\bgroup
{
\egroup
}
1.5
10
1
2
Note
Should not be confused with \space
Begin of group
End of group
Other
Macro
Value
\voidb@x
(void)
\@undefined (undef)
Defined using
Notes
newbox
(undefined)
2
2.1
Variables
Temporary Variables
The following variables are defined and used by the LATEX kernel commands as scratch
registers and macros. They can be used with care, but should only be redefined inside
a local group to avoid interference with other code. Care must also be taken if they are
used together with external macros, which might use them as well maybe not yet but
in the next release.
Temp variable
Type
\count@
\@tempcnta
\@tempcntb
\dimen@
\dimen@i
\dimen@ii
\@tempdima
\@tempdimb
\@tempdimc
\@tempa
\@tempb
\@tempc
\@gtempa
\skip@
\@tempskipa
\@tempskipb
\toks@
\@temptokena
\if@tempswa
counter
counter
counter
dimension
dimension
Marked as global only
dimension
dimension
dimension
dimension
macro
macro
macro
macro
For temporary definitions which must be made global
skip
skip
skip
token register
token register
if switch
Comes with the usual setters \@tempswatrue and
\@tempswafalse
box register
let
Used by \@ifnextchar to temporary store the next
token using \futurelet. Can be used for similar purposes.
\@tempboxa
\@let@token
2.2
Note
Dimension Variables
Macro
Description
\@wholewidth This dimen register holds the half line width (thickness) in picture
environments.
\@halfwidth
This dimen register hold the full line width (thickness) in picture
environments.
2.3
Macro
Description
\@currext
\@currname
\@currenvir
\@currenvline
\@currentlabel
Macros
3.1
Macro Definition
\@namedef{hnamei}hparameter listi{hdefinitioni}
Defines macro \hnamei using \def. Can be prefixed with \long and \global.
\@nameuse{hnamei}
Expands to macro \hnamei.
\@ifnextcharhtokeni{hyesi}{hnoi}
Tests if next non-space token is equal to htokeni.
\@ifstar{hyesi}{hnoi}
Tests of next non-space token is *. Removes star for hyesi branch.
\@dblarg{hcmd i}{hargi}
Expands to hcmd i[hargi]{hargi}.
\@ifundefined{hnamei}{hyesi}{hnoi}
Tests if \hnamei is defined (and not equal to \relax).
\@ifdefinable\hnamei{hyesi}
Tests if \hnamei is undefined, hnamei not relax and doesnt start with end, and if
\endhnamei is not defined.
\@onlypreamblehmacroi
The given hmacroi is marked as only be valid in the preamble. It will be redefined as an
error message AtBeginDocument.
\@star@or@long
Tests for a following *, if found \l@ngrel@x will be let to \relax, but \long otherwise.
It can the be used before \def as an potential prefix.
\@testopt{h1 i}{h2 i}
Short for \@ifnextchar[{h1 i}{h1 i[{h2 i}]}, i.e. h2 i will be used as default argument if
non was given.
\@protected@testopt
Robust version of \@testopt?
\addto@hookhtoken register i{hcodei}
Appends code to the token register.
\g@addto@macrohmacroi{hcodei}
Appends hcodei to the definition of hmacroi.
3.2
Expanding/Gobbling Arguments
Macro
Description
\@gobble{hargi}
\@gobbletwo{harg 1 i}{harg 2 i}
\@gobblefour{h1 i}{h2 i}{h3 i}{h4 i}
\@gobblecr
\@firstofone{hargi}
\@iden{hargi}
\@firstoftwo{h1 i}{h2 i}
\@secondoftwo{h1 i}{h2 i}
\@thirdofthree{h1 i}{h2 i}{h3 i}
\@expandtwoargs\macro{h1 i}{h2 i}
3.3
Lists
\in@{h1 i}{h2 i}
Checks if first argument occurs in the second and sets the switch \ifin@ accordantly.
The arguments are not expanded. This must be done beforehand.
\@removeelement{helementi}{hlisti}{hcsi}
Removes an element from a comma-separated list and puts it into a control sequence.
3.4
Loops
Macro
Description
\@tforhmacroi:=hlisti\do{hbodyi}
\@break@tfor
NOTES:
1. These macros use no \@temp sequences.
2. These macros do not work if the body contains anything that looks syntactically
to TeX like an improperly balanced \if \else \fi.
3.5
Colors
The following macros are defined equal to \relax by LaTeX2e as placeholder for the real
code added by the color or xcolor package. They are needed to handle colors inside
saved boxes correctly. See the definitions of \sbox for an example.
Macro
\color@begingroup
\color@endgroup
\color@setgroup
\color@hbox
\color@vbox
\color@endbox
\begingroup
\endgroup
\begingroup\set@color
\hbox\bgroup\color@begingroup
\vbox\bgroup\color@begingroup
\color@endgroup\egroup
3.6
Auxiliary Macros
This auxiliary macros were originally defined to handle font changes but can be used for
other code as well.
Macro
Description
\ifnot@nil{h1 i}{h2 i}
Checks if h1 i is the token \@nil. If so gobbles h2 i otherwise uses \@firstofone to remove the braces around
h2 i.
\@nil
This macro is undefined on purpose and used as endmarker in loops and other macros which process token
lists.
\@nnil
Definition contains only \@nil and is used beside others
to test for the presents of \@nil in \ifnot@nil. Is also
used as endmarker.
\remove@to@nnil
Removes everything behind it until and including
\@nnil.
\remove@star
Removes everything behind it until and including *.
\zap@spacehtexti \@empty Removes all spaces from htexti. Expandable.
\strip@prefix
Removes everything up to and including to the next >.
3.7
Catcodes
Name
Description
3.8
Messages
\MessageBreak
Inside a message this macro create a new line followed by a continuation text. Outside
it is equal to \relax.
\GenericInfo{hcontinuationi}{hmessagei}
Prints hmessagei to a log file. An included \MessageBreak will cause a new line which
start with hcontinuationi.
\GenericError{hcontinuationi}{herror messagei}
{hwhere to go for further informationi}{hhelp texti}
Print error message to log file followed by the further information line. The help text is
displayed if the user presses h.
\wlog{hlog messagei}
Write on log file only.
3.9
Name
Description
\@settopointhregister i
Rounds register to whole number of points.
\rem@pthdimension valuei Awaits a value dimension value (hinti.hfracipt) as string
where the pt is removed. If hfraci is numerical equal to
0, then it and the decimal dot are removed as well.
\strip@pthdimensioni
Expands dimension using \the and strips the pt using
\rem@pt.
\@killglue
Removes (\unskips) the last and then all further skips
(\lastskip) till one with a size of zero is reached.
\@defaultunits
Used to provide a default unit for dimen or skip assignment.
Usage: \@defaultunits\dimen=#1pt\relax\@nnil. Other units can be used instead of
pt.
3.10
Macro
3.11
Files
Macro
Description
\if@filesw
\if@partsw
\@currdir
\input@path
10
\@obsoletefile{hnew i}{hobsoletei}
Prints warning message (only) that now a different file is used a input.
\@addtofilelist{hfilenamei}
Adds the given filename to the list of files. Only active if \listfiles is used in the
preamble.
\@ptionlist{hfilenamei}
Expands the option list of package, class or file given by full filename.
\@ifpackageloaded{hpackagei}{htruei}{hfalsei}
\@ifclassloaded{hclassi}{htruei}{hfalsei}
\@ifl@aded{hextensioni}{hfile basei}{htruei}{hfalsei}
Tests if given package/class/file has been loaded.
\@ifpackagewith{hnamei}{hoption-listi}{htruei}{hfalsei}
\@ifclasswith{hnamei}{hoption-listi}{htruei}{hfalsei}
\@if@ptions{hextensioni}{hnamei}{hoption-listi}{htruei}{hfalsei}
Tests if given package/class/file has been loaded with the given options.
\@ifpackagelater{hnamei}{hdate YYYY/MM/DDi}{htruei}{hfalsei}
\@ifclasslater{hnamei}{hdate YYYY/MM/DDi}{htruei}{hfalsei}
\@ifl@ter{hextensioni}{hfile basei}{hdate YYYY/MM/DDi}{htruei}{hfalsei}
Tests if given package/class/file has been loaded with a version more recent than hversioni.
3.12
The following plainTEX macros are redefined by LATEX and therefore saved away first:
LATEX Macro
\@@par
plainTEX original
\par
\@@input
\@@end
\@@underline
\frozen@everymath
\frozen@everydisplay
\input
\end
\underline
\everymath
\everydisplay
11
Description/Note
Some LATEX environments redefine \par
locally
Syntax: \input hfilenamei
3.13
Fonts
Macro
Description
\f@encoding
\f@family
\f@series
\f@shape
\f@size
\f@baselineskip
\f@linespread
\@currsize
\curr@math@size
\curr@fontshape
3.14
Paragraph
Macro
Description
\@@par
PlainTEX primitive \par.
\@setpar{hval i} Used to make environment-wide changes to \par. Sets both \par
and \@par to hval i.
\@restorepar
Defines \par to \@par.
3.15
Space Hack
Macro
Description
\@bsphack
\@esphack
Both of these macro ensure that the code between them does not insert
any spaces into the document. The code itself should not produce any
text and not change the mode (e.g. start or stop math mode).
\@Esphack
Variant of \@esphack which sets the @ignore switch to true which causes
an \ignorespaces after the \end of the environment.
\@vbsphack Variant of \@bsphack which ensure the invisible material is not set in
vmode. Not used by LATEX itself at the moment.
12
3.16
Boxes
Macro
Description
3.17
Macro
Base Conversion
Description
13
3.18
Macro
Conditionals
Description
14