0% found this document useful (0 votes)
13K views14 pages

List of Internal L TEX2e Macros Useful To Package Authors: Martin@scharrer-Online - de

This document lists macros defined by the LaTeX2e base files that may be useful for package authors. It includes macros for defining constants, variables, and control structures like loops and conditionals. The document notes that some macros are intended for temporary use while others should not be modified. It is a work in progress and may not include every relevant macro.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13K views14 pages

List of Internal L TEX2e Macros Useful To Package Authors: Martin@scharrer-Online - de

This document lists macros defined by the LaTeX2e base files that may be useful for package authors. It includes macros for defining constants, variables, and control structures like loops and conditionals. The document notes that some macros are intended for temporary use while others should not be modified. It is a work in progress and may not include every relevant macro.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

List of internal LATEX2e Macros useful to Package

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

Can be used as a replacement of pt behind a number due to the resulting multiplication


Can be used both for 0pt and 0
Largest valid dimension

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

permanently void box register


This macro is not defined. It is used to test
if other macros are undefined (using \ifx) or
set them to an undefined state (using \let).

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

String and Other Variables

Macro

Description

\@currext
\@currname
\@currenvir
\@currenvline
\@currentlabel

Extension of the current package or class file, empty outside.


File name base of the current package or class file, empty outside.
Name of the current environment.
Line number of the begin of the current environment
The value a \label will point to. Set by \stepcounter and
\refstepcounter.

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

Removes (gobbles) its argument. (long)


Removes (gobbles) two arguments. (long)
Removes (gobbles) four arguments. (long)
Gobbles a following carriage return, ignores
spaces otherwise
Expands to hargi, i.e. is used to remove braces.
(long)
Identity. Same as \@firstofone for compatibility reasons. (long)
Expands to h1 i, discards h2 i. (long)
Expands to h2 i, discards h1 i. (long)
Expands to h3 i, discards h1 i and h2 i. (long)
Expands the two arguments using \edef and
feeds it to \macro.

\@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

\loop ... \iterate ... \repeat


\@whilenumhtesti\do{hbodyi}
\@whiledimhtesti\do{hbodyi}
\@whileswhswitchi\fi{hbodyi}
\@forhmacroi:=hlisti\do{hbodyi}

\@tforhmacroi:=hlisti\do{hbodyi}

\@break@tfor

While loop with \ifnum test.


While loop with \ifdim test.
While loop with hswitchi test.
For loop. The hlisti is supposed to expand to
a comma separated list. Defines hmacroi to
each element of the list and executes hbodyi each
time. Supports an empty lists without errors.
For loop. The hlisti is not expanded and taken
as a list of tokens or {...}. Defines hmacroi to
each element of the list and executes hbodyi each
time. Supports an empty lists without errors.
Break out of a \@tfor loop. This should be
called inside the scope of an \fi.

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

Definition given by color

\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

Removes everything up to and including to the next


>.
\@makeother{hletter i}
Changes the catcode of the letter to other (12). Special letters must be escaped with a backslash.
\@sanitize
Changes catcodes of everything except braces to
other (12).
\@onelevel@sanitizehmacroi Sanitizes hmacroi, turns it definition into verbatim code. Resulting characters except spaces
are in catcode other (12)! Uses \meaning and
\strip@prefix. (With -TEX many applications can
be replaced by \detokenize{hcontenti}.)
\strip@prefix

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

Dimensions, Length and Skips

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

Class and Package Options


Description

\@classoptionslist List of options of the main class.


\@unusedoptionlist List of options to the main class that havent been declared.
\@declaredoptions
Comma separated list of the options declared by the current
package or class. The list is in the order in which the options
were declared.

3.11

Files

Macro

Description

\if@filesw

If false the package should not be produce or write to output files.


Set to false by \nofiles.

\if@partsw
\@currdir
\input@path

Holds the current directory, e.g. ./ in an Unix OS.


List of input paths. Each path should be enclosed in braces with
no delimiters between paths.
\@filelist
The comma separated list of all files read so far. Only active if
\listfiles is used in the preamble.
\@inputcheck
Input file handle to check for the existence of the file.
\@unused
Output file handle used to reserve the standard output. Used in
\typeout to write to the terminal.
\@mainaux
Output file handle for the main aux file.
\@partaux
Output file handle for include file aux files.
\@auxout
Let to \@partaux inside include files, but to \@mainaux otherwise.
\@partlist
Holds the comma-separated list defined by \includeonly.
\@pushfilename
pushes file name, extension and current catcode of @ onto the
file stack.
\@popfilename
pushes file name, extension and current catcode of @ onto the
file stack.
\@currnamestack file name stack.
\filename@parse{hfilenamei}
Parses hfilenamei and provides its directory, name base and extension in \filename@area,
\filename@base and \filename@ext. The latter is let to \relax if it does not exists.
\@filef@und
The macro \IfFileExists(which is used by \InputIfFileExists{)} stores the found
file followed by a space in this macro.
\@starttoc{hexti}
Reads the file with the given extension (\jobname.hexti) and opens it for writing afterwards. The file is initially empty. Creates the output file handle \tf@hexti.
\@writefile{hexti}{hcodei}
Writes code using the output handle \tf@hexti if it exists.
\@iffileonpath{hfilenamei}
Check if given file is found by TEX directly or in any of the directories given by \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

Saved plainTEX primitives

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

Holds the current font encoding.


Holds the current font family.
Holds the current font series.
Holds the current font shape.
Holds the current font size (in pt but without unit).
Holds the current baseline skip (in pt but without unit).
Holds the current internal value for \baselinestretch.
Let to the last font size command (e.g. \small).
Holds locally the current math size.
\f@encoding /\f@family /\f@series /\f@shape

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

Empty \hbox. Good to fill places which must


not be empty.
\strutbox
Box with dimension of \strut, i.e. maximum
height and depth of the current font and zero
width. Can be used to extract this dimension
with \ht\strutbox and \dp\strutbox.
\@arstrutbox
Defined inside array and tabular.
Like
\strutbox but stretched by \arraystretch.
\@begin@tempboxahbox i{hcontenti} Stores hcontenti into \@tempboxa as hbox i
(\hbox or \vbox) and stores its dimension into
\width, \height, \depth and \totalheight.
\@end@tempboxa
Ends a \@begin@tempboxa environment.
\hb@xt@
\hbox to
\hmode@bgroup
\leavevmode\bgroup
\null

\@settodim{hdimension csi}{hlength register i}{hcontenti}


Sets the hlength register i to the dimension given by the hdimensioni (\ht, \dp and \wd
) of the hcontenti. Example: \@settodim{\wd}{\@tempdima}{Hello World} will set
\@tempdima to the width of Hello World.

3.17
Macro

Base Conversion
Description

\hexnumber@{hnumber i} Returns a single digit hexadecimal number (09, AF) from


given hnumber i, which must either be a numeric register or
a number ending with a space!
\@alph{hnumber i}
Expands to lower case letter corresponding to the given
number (1=a, 2=b, . . . ). Expands to \@ctrerr if number
is larger then 26.
\@Alph{hnumber i}
Expands to upper case letter corresponding to the given
number (1=A, 2=B, . . . ). Expands to \@ctrerr if number
is larger then 26.
\two@digits{hnumber i} Returns hnumber i (e.g. a count register) as string and ensures that it has at least two digits by appending a 0 if
required.

13

3.18
Macro

Conditionals
Description

\if@compatibility Switch to indicate if the LaTeX2.09 compatibility mode is active.


\if@ignore
Whether or not to ignore spaces after an environment. Set to
true by \ignorespacesafterend.
\if@minipage
True for a minipage, false for a parbox. Responsible for adding
space, skips and paragraph indents for a parbox.
\if@twoside
True for two-sided documents
\if@twocolumn
Indicates if two-column mode is active
\if@firstcolumn
Indicates if the first column is processed

14

You might also like