Expand description
Texlang commands API
Texcraft commands API
One of the most important parts of any TeX engine is the primitives that it provides. This documentation describes the Texcraft commands API, which is the mechanism by which TeX engines add new primitives.
A note on terminology: commands can be categorized into primitives,
which are implemented in the TeX engine, and user defined macros,
which are created in specific TeX documents using primitives like \def
.
We often use the word command and primitive interchangeably here because in the context
of implementing TeX engines they’re basically synonymous.
A TeX engine could theoretically provide a native user defined macro…but it’s unlikely.
Expansion vs execution
Expansion and execution commands seem similar because they both optionally read input tokens and then make changes to the VM. However the differences are pretty significant in practice:
Expansion | Execution | |
---|---|---|
Can read tokens from the input stream? | Yes | Yes |
Can add tokens to the input stream> | Yes | It’s possible, but the API discourages it.1 |
Can make changes to the state? | No | Yes |
Is evaluated when tokens are only being expanded, like in \edef | Yes | No |
\futurelet
is an example of an execution command that does this. ↩
Re-exports
pub use crate::error::Error;
Structs
- A built-in command. This is a command provided at VM initialization.
- Map is a map type where the keys are control sequence names and the values are TeX commands.
- A static tag enables creating a tag in a static variable.
- A tag is a piece of metadata that is optionally attached to a command.
Enums
- A TeX command.
Type Aliases
- The Rust type of execution primitive functions.
- The Rust type of expansion primitive functions.