Module texlang::command

source ·
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:

ExpansionExecution
Can read tokens from the input stream?YesYes
Can add tokens to the input stream>YesIt’s possible, but the API discourages it.1
Can make changes to the state?NoYes
Is evaluated when tokens are only being expanded, like in \edefYesNo

  1. \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

Type Aliases