pub enum CatCode {
Show 16 variants
Escape,
BeginGroup,
EndGroup,
MathShift,
AlignmentTab,
EndOfLine,
Parameter,
Superscript,
Subscript,
Ignored,
Space,
Letter,
Other,
Active,
Comment,
Invalid,
}
Expand description
Enum representing all 16 category codes in TeX.
Each variant’s documentation contains an example character which is mapped to that category code in plainTeX.
Variants§
Escape
Marks the beginning of a control sequence.
Example: \
.
This category code is never seen outside of the lexer.
BeginGroup
Begins a new group.
Example: {
.
EndGroup
Ends an existing new group.
Example: }
.
MathShift
Starts or ends math mode.
Example: $
.
AlignmentTab
Used in typesetting tables to align cells.
Example: &
.
EndOfLine
Marks a new line in the input.
Example: \n
.
This code behaves similarly to Space, but has two additional properties.
First, two or more consecutive new lines, modulo intervening Space characters, create a \par
control sequence
instead of a regular space.
Second, this code terminates a comment that started with a Comment character.
This category code is never seen outside of the lexer.
Parameter
Marks the beginning of a parameter number.
It must generally be followed by a digit.
Example: #
.
Superscript
Puts following character or group in a superscript.
Example: ^
.
Subscript
Puts following character or group in a subscript.
Example: _
.
Ignored
Character that is ignored by the lexer. Example: ASCII null (0).
This category code is never seen outside of the lexer.
Space
Whitespace. Example:
.
Letter
A character that can be used as a control sequence name.
Examples: [a-zA-z]
.
Other
A character than cannot be used as a control sequence name.
Example: @
.
Active
A single character that behaves like a control sequence.
Example: ~
.
Comment
Marks the beginning of a comment.
All characters until the next EndOfLine are ignored.
Example: %
.
This category code is never seen outside of the lexer.
Invalid
An invalid character. If this is encountered in the input, the lexer will return an error. Example: ASCII delete (127).
This category code is never seen outside of the lexer.
Implementations§
source§impl CatCode
impl CatCode
sourcepub const INITEX_DEFAULTS: [CatCode; 128] = _
pub const INITEX_DEFAULTS: [CatCode; 128] = _
Default category codes in INITEX for all ASCII characters.
To find the category code for an ASCII character, convert it to an integer and use it as an index for the array.
This list was compiled by reading the source code TeX ’82, specifically section 232 in the “TeX: the program”. These defaults are also described in the TeXBook p343.
sourcepub const PLAIN_TEX_DEFAULTS: [CatCode; 128] = _
pub const PLAIN_TEX_DEFAULTS: [CatCode; 128] = _
Default category codes in plainTeX for all ASCII characters.
To find the category code for an ASCII character, convert it to an integer and use it as an index for the array.
This list was compiled by starting with INITEX_DEFAULTS and then applying all category code changes in the plainTeX format. These changes are described on p343 of the TeXBook.