Skip to content

global tex

😱 Types incomplete or incorrect? 🙏 Please contribute!


methods


tex.set


function tex.set(
  global: "global",
  parameter: InternalParameter,
  ...: any
)
@param global - It is possible to use global as the first argument to tex.set; this makes the assignment global instead of local.

@param parameter - The name of the TeX parameter.

Set the given TeX parameter globally.

Reference:

tex.set


function tex.set(
  parameter: InternalParameter,
  ...: any
)
@param parameter - The name of the TeX parameter.

Set the given TeX parameter.

When you set a glue quantity you can either pass a glue_spec or upto five numbers.

Reference:

tex.set


function tex.set(
  global: "global",
  parameter: GlueParameter,
  width: integer,
  stretch: integer?,
  stretch_order: integer?,
  shrink: integer?,
  shrink_order: integer?
)
@param global - It is possible to use global as the first argument to tex.set; this makes the assignment global instead of local.

@param parameter - The name of the glue parameter.

@param width - The horizontal or vertical displacement.

@param stretch - An extra (positive) displacement or stretch amount.

@param stretch_order - Factor applied to stretch amount.

@param shrink - An extra (negative) displacement or shrink amount.

@param shrink_order - Factor applied to shrink amount.

Set the given glue parameter globally by specifying the width, stretch, stretch_order, shrink and shrink_order of the glue.

Reference:

tex.set


function tex.set(
  parameter: GlueParameter,
  width: integer,
  stretch: integer?,
  stretch_order: integer?,
  shrink: integer?,
  shrink_order: integer?
)
@param parameter - The name of the glue parameter.

@param width - The horizontal or vertical displacement.

@param stretch - An extra (positive) displacement or stretch amount.

@param stretch_order - Factor applied to stretch amount.

@param shrink - An extra (negative) displacement or shrink amount.

@param shrink_order - Factor applied to shrink amount.

Set the given glue parameter by specifying the width, stretch, stretch_order, shrink and shrink_order of the glue.

Reference:

tex.set


function tex.set(
  global: "global",
  parameter: GlueParameter,
  glue_spec: GlueSpecNode {
    width = integer,
    stretch = integer,
    stretch_order = integer,
    shrink = integer,
    shrink_order = integer,
}
)
@param global - It is possible to use global as the first argument to tex.set; this makes the assignment global instead of local.

@param parameter - The name of the glue parameter.

@param glue_spec - A glue spec node.

Set the given glue parameter globally using a glue_spec node.

Reference:

tex.set


function tex.set(
  parameter: GlueParameter,
  glue_spec: GlueSpecNode {
    width = integer,
    stretch = integer,
    stretch_order = integer,
    shrink = integer,
    shrink_order = integer,
}
)
@param parameter - The name of the glue parameter.

@param glue_spec - A glue spec node.

Set the given glue parameter using a glue_spec node.

Reference:

tex.get


function tex.get(
  parameter: InternalParameter,
  opts: boolean?
) ->  any ...

Query the given TeX parameter.

The exact return values differ depending on the actual parameter.

Reference:

tex.get


function tex.get(parameter: GlueParameter) ->  GlueSpecNode {
    width = integer,
    stretch = integer,
    stretch_order = integer,
    shrink = integer,
    shrink_order = integer,
}

tex.get


function tex.get(
  parameter: GlueParameter,
  all: true
)
 -> width integer
 -> stretch integer
 -> stretch_order integer
 -> shrink integer
 -> shrink_order integer

@return width - The horizontal or vertical displacement.

@return stretch - An extra (positive) displacement or stretch amount.

@return stretch_order - Factor applied to stretch amount.

@return shrink - An extra (negative) displacement or shrink amount.

@return shrink_order - Factor applied to shrink amount.

Query the given glue parameter.

The exact return values differ depending on the actual parameter.

Glue is kind of special: The return value is a glue_spec node but when you pass false as last argument to tex.get you get the width of the glue and when you pass true you get all five values. Otherwise you get a node which is a copy of the internal value so you are responsible for its freeing at the Lua end.

If you pass true to get you get 5 values returned for a glue and when you pass false you only get the width returned.

Reference:

tex.get


function tex.get(
  parameter: GlueParameter,
  all: false
) -> width integer

@return width - The horizontal or vertical displacement.

Query the given glue parameter.

The exact return values differ depending on the actual parameter.

Glue is kind of special: The return value is a glue_spec node but when you pass false as last argument to tex.get you get the width of the glue and when you pass true you get all five values. Otherwise you get a node which is a copy of the internal value so you are responsible for its freeing at the Lua end.

If you pass true to get you get 5 values returned for a glue and when you pass false you only get the width returned.

Reference:

tex.setattribute


function tex.setattribute(
  global: "global",
  register: (string|integer),
  value: integer
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param register - A register number or a predefined csname string from \attributedef.

tex.setattribute


function tex.setattribute(
  register: (string|integer),
  value: integer
)
@param register - A register number or a predefined csname string from \attributedef.

tex.getattribute


function tex.getattribute(register: (string|integer)) -> value integer
@param register - A register number or a predefined csname string from \attributedef.

tex.isattribute


function tex.isattribute(register: (string|integer)) ->  (false|integer)
@param register - A register number or a predefined csname string from \attributedef.

tex.setcount


function tex.setcount(
  global: "global",
  register: (string|integer),
  value: integer
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param register - A register number or a predefined csname string from \countdef.

tex.setcount


function tex.setcount(
  register: (string|integer),
  value: integer
)
@param register - A register number or a predefined csname string from \countdef.

tex.getcount


function tex.getcount(register: (string|integer)) -> value integer
@param register - A register number or a predefined csname string from \countdef.

tex.iscount


function tex.iscount(register: (string|integer)) ->  (false|integer)
@param register - A register number or a predefined csname string from \countdef.

tex.setdimen


function tex.setdimen(
  global: "global",
  register: (string|integer),
  value: (integer|string)
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param register - A register number or a predefined csname string from \dimendef.

tex.getdimen


function tex.getdimen(register: (string|integer)) -> value integer
@param register - A register number or a predefined csname string from \dimendef.

tex.isdimen


function tex.isdimen(register: (string|integer)) ->  (false|integer)
@param register - A register number or a predefined csname string from \dimendef.

tex.setglue


function tex.setglue(
  global: "global",
  register: (string|integer),
  width: number?,
  stretch: number?,
  shrink: number?,
  stretch_order: integer?,
  shrink_order: integer?
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param register - A register number or a predefined csname string from \skipdef.

tex.setglue


function tex.setglue(
  register: (string|integer),
  width: number?,
  stretch: number?,
  shrink: number?,
  stretch_order: integer?,
  shrink_order: integer?
)
@param register - A register number or a predefined csname string from \skipdef.

tex.getglue


function tex.getglue(register: (string|integer))
 -> width integer
 -> stretch integer
 -> shrink integer
 -> stretch_order integer
 -> shrink_order integer
@param register - A register number or a predefined csname string from \skipdef.

tex.isglue


function tex.isglue(register: (string|integer)) ->  (false|integer)
@param register - A register number or a predefined csname string from \skipdef.

Alias of tex.isskip()

tex.setmuglue


function tex.setmuglue(
  global: "global",
  register: (string|integer),
  width: number?,
  stretch: number?,
  shrink: number?,
  stretch_order: integer?,
  shrink_order: integer?
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param register - A register number or a predefined csname string from \muskipdef.

tex.setmuglue


function tex.setmuglue(
  register: (string|integer),
  width: number?,
  stretch: number?,
  shrink: number?,
  stretch_order: integer?,
  shrink_order: integer?
)
@param register - A register number or a predefined csname string from \muskipdef.

tex.getmuglue


function tex.getmuglue(register: (string|integer))
 -> width integer
 -> stretch integer
 -> shrink integer
 -> stretch_order integer
 -> shrink_order integer
@param register - A register number or a predefined csname string from \muskipdef.

tex.ismuglue


function tex.ismuglue(register: (string|integer)) ->  (false|integer)
@param register - A register number or a predefined csname string from \muskipdef.

Alias of tex.ismuskip()

tex.setmuskip


function tex.setmuskip(
  global: "global",
  register: (string|integer),
  value: Node {
    next = Node?,
    prev = Node?,
    id = integer,
    subtype = integer,
    head = Node?,
    attr = Node,
}
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param register - A register number or a predefined csname string from \muskipdef.

tex.setmuskip


function tex.setmuskip(
  register: (string|integer),
  value: Node {
    next = Node?,
    prev = Node?,
    id = integer,
    subtype = integer,
    head = Node?,
    attr = Node,
}
)
@param register - A register number or a predefined csname string from \muskipdef.

tex.getmuskip


function tex.getmuskip(register: (string|integer)) -> value Node {
    next = Node?,
    prev = Node?,
    id = integer,
    subtype = integer,
    head = Node?,
    attr = Node,
}
@param register - A register number or a predefined csname string from \muskipdef.

tex.ismuskip


function tex.ismuskip(register: (string|integer)) ->  (false|integer)
@param register - A register number or a predefined csname string from \muskipdef.

tex.setskip


function tex.setskip(
  global: "global",
  register: (string|integer),
  skip: GlueSpecNode {
    width = integer,
    stretch = integer,
    stretch_order = integer,
    shrink = integer,
    shrink_order = integer,
}
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param register - A register number or a predefined csname string from \skipdef.

tex.setskip


function tex.setskip(
  register: (string|integer),
  skip: GlueSpecNode {
    width = integer,
    stretch = integer,
    stretch_order = integer,
    shrink = integer,
    shrink_order = integer,
}
)
@param register - A register number or a predefined csname string from \skipdef.

tex.getskip


function tex.getskip(register: (string|integer)) ->  GlueSpecNode {
    width = integer,
    stretch = integer,
    stretch_order = integer,
    shrink = integer,
    shrink_order = integer,
}
@param register - A register number or a predefined csname string from \skipdef.

tex.isskip


function tex.isskip(register: (string|integer)) ->  (false|integer)
@param register - A register number or a predefined csname string from \skipdef.

tex.settoks


function tex.settoks(
  global: "global",
  register: (string|integer),
  toks: string
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param register - A register number or a predefined csname string from \toksdef.

Set a toks register. Also accepts a predefined csname string.

tex.gettoks


function tex.gettoks(register: (string|integer)) -> toks string
@param register - A register number or a predefined csname string from \toksdef.

Get a toks register. Also accepts a predefined csname string.

tex.istoks


function tex.istoks(register: (string|integer)) ->  (false|integer)
@param register - A register number or a predefined csname string from \toksdef.

tex.scantoks


function tex.scantoks(
  global: "global",
  register: integer,
  catcodetable: integer,
  toks: string
)

For tokens registers we have an alternative where a catcode table is specified:

tex.scantoks(0,3,"$e=mc^2$")
tex.scantoks("global",0,"$\\int\\limits^1_2$")

tex.getmark


function tex.getmark(
  position: ("top"|"bottom"|"first"|"splitbottom"|"splitfirst")?,
  class: integer?
) ->  (integer|string)
@param position - one of top, bottom, first, splitbottom or splitfirst

@param class - marks class number.

When no arguments are given the current maximum number of classes is returned.

tex.setlccode


function tex.setlccode(
  global: "global",
  char_code: integer,
  lower_case: integer,
  upper_case: integer?
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param char_code - A Unicode code point for which a lowercase variant of the character is to be set, for example 65 stands for an uppercase A and 97 for a lowercase a.

@param lower_case - The Unicode code point for the lowercase variant of the character.

@param upper_case - The Unicode code point for the uppercase variant of the character.

😱 Types incomplete or incorrect? 🙏 Please contribute!

Set the lccode (lower case code) and additionally the associated sibling for a character code at the same time.

Reference:

tex.setlccode


function tex.setlccode(
  char_code: integer,
  lower_case: integer,
  upper_case: integer?
)
@param char_code - A Unicode code point for which a lowercase variant of the character is to be set, for example 65 stands for an uppercase A and 97 for a lowercase a.

@param lower_case - The Unicode code point for the lowercase variant of the character.

@param upper_case - The Unicode code point for the uppercase variant of the character.

😱 Types incomplete or incorrect? 🙏 Please contribute!

Set the lccode (lower case code) and additionally the associated sibling for a character code at the same time.

Reference:

tex.getlccode


function tex.getlccode(char_code: integer) -> lower_case integer
@param char_code - A Unicode code point for which a lowercase variant of the character should be returned, for example 65 stands for an uppercase A and 97 for a lowercase a.

@return lower_case - The Unicode code point for the lowercase variant of the character. 😱 Types incomplete or incorrect? 🙏 Please contribute!

Reference:

tex.setuccode


function tex.setuccode(
  global: "global",
  char_code: integer,
  upper_case: integer,
  lower_case: integer?
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param char_code - A Unicode code point for which a uppercase variant of the character is to be set, for example 65 stands for an uppercase A and 97 for a lowercase a.

@param upper_case - The Unicode code point for the uppercase variant of the character.

@param lower_case - The Unicode code point for the lowercase variant of the character.

😱 Types incomplete or incorrect? 🙏 Please contribute!

The function call interface for uccode (upper case code) additionally allows you to set the associated sibling at the same time.

Reference:

tex.setuccode


function tex.setuccode(
  char_code: integer,
  upper_case: integer,
  lower_case: integer?
)
@param char_code - A Unicode code point for which a uppercase variant of the character is to be set, for example 65 stands for an uppercase A and 97 for a lowercase a.

@param upper_case - The Unicode code point for the uppercase variant of the character.

@param lower_case - The Unicode code point for the lowercase variant of the character.

The function call interface for uccode (upper case code) additionally allows you to set the associated sibling at the same time.

Reference:

@see tex.getuccode tex.setlccode

tex.getuccode


function tex.getuccode(char_code: integer) -> upper_case integer
@param char_code - A Unicode code point for which a uppercase variant of the character should be returned, for example 65 stands for an uppercase A and 97 for a lowercase a.

@return upper_case - The Unicode code point for the uppercase variant of the character. 😱 Types incomplete or incorrect? 🙏 Please contribute!

Corresponding plain TeX control sequence: \uccode

Reference:

tex.setsfcode


function tex.setsfcode(
  global: "global",
  char_code: integer,
  space_factor: integer
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param char_code - A Unicode code point, for example 65 stands for an uppercase A and 97 for a lowercase a.

@param space_factor - The code (between 0 and 32767) to adjust the space factor in a horizontal list. The uppercase letters A-Z have space factor code 999. Most other characters have code 1000.

😱 Types incomplete or incorrect? 🙏 Please contribute!

Set the space factor code for a character globally.

Reference:

tex.setsfcode


function tex.setsfcode(
  char_code: integer,
  space_factor: integer
)
@param char_code - A Unicode code point, for example 65 stands for an uppercase A and 97 for a lowercase a.

@param space_factor - The code (between 0 and 32767) to adjust the space factor in a horizontal list. The uppercase letters A-Z have space factor code 999. Most other characters have code 1000.

😱 Types incomplete or incorrect? 🙏 Please contribute!

Set the space factor code for a character.

Reference:

tex.getsfcode


function tex.getsfcode(char_code: integer) -> space_factor integer
@param char_code - A Unicode code point, for example 65 stands for an uppercase A and 97 for a lowercase a.

@return space_factor - The code (between 0 and 32767) to adjust the space factor in a horizontal list. The uppercase letters A-Z have space factor code 999. Most other characters have code 1000. 😱 Types incomplete or incorrect? 🙏 Please contribute!

Get the space factor code of a character.

Reference:

tex.setcatcode


function tex.setcatcode(
  global: "global",
  char_code: integer,
  cat_code: integer
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param char_code - The character code, for example ASCII or UNICODE character code.

@param cat_code - The category code (0 stands for the escape character, normally \, 1 stands for begin grouping, normally { and so on).

😱 Types incomplete or incorrect? 🙏 Please contribute!

Specify a category table to use on assignment or on query (default in both cases is the current one).

tex.setcatcode


function tex.setcatcode(
  char_code: integer,
  cat_code: integer
)
@param char_code - The character code, for example ASCII or UNICODE character code.

@param cat_code - The category code (0 stands for the escape character, normally \, 1 stands for begin grouping, normally { and so on). 😱 Types incomplete or incorrect? 🙏 Please contribute!

Specify a category table to use on assignment or on query (default in both cases is the current one).

Category codes:

  • 0: Escape character, normally \
  • 1: Begin grouping, normally {
  • 2: End grouping, normally }
  • 3: Math shift, normally $
  • 4: Alignment tab, normally &
  • 5: End of line, normally <return>
  • 6: Parameter, normally #
  • 7: Superscript, normally ^
  • 8: Subscript, normally _
  • 9: Ignored character, normally <null>
  • 10: Space, normally <space> and <tab>
  • 11: Letter, normally only contains the letters a,...,z and A,...,Z. These characters can be used in command names
  • 12: Other, normally everything else not listed in the other categories
  • 13: Active character, for example ~
  • 14: Comment character, normally %
  • 15: Invalid character, normally <delete>

Reference:

tex.setcatcode


function tex.setcatcode(
  global: "global",
  cat_table: integer,
  char_code: integer,
  cat_code: integer
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param char_code - The character code, for example ASCII or UNICODE character code.

@param cat_code - The category code (0 stands for the escape character, normally \, 1 stands for begin grouping, normally { and so on). 😱 Types incomplete or incorrect? 🙏 Please contribute!

Specify a category table to use on assignment or on query (default in both cases is the current one).

Category codes:

  • 0: Escape character, normally \
  • 1: Begin grouping, normally {
  • 2: End grouping, normally }
  • 3: Math shift, normally $
  • 4: Alignment tab, normally &
  • 5: End of line, normally <return>
  • 6: Parameter, normally #
  • 7: Superscript, normally ^
  • 8: Subscript, normally _
  • 9: Ignored character, normally <null>
  • 10: Space, normally <space> and <tab>
  • 11: Letter, normally only contains the letters a,...,z and A,...,Z. These characters can be used in command names
  • 12: Other, normally everything else not listed in the other categories
  • 13: Active character, for example ~
  • 14: Comment character, normally %
  • 15: Invalid character, normally <delete>

Reference:

tex.setcatcode


function tex.setcatcode(
  global,
  cat_table: integer,
  char_code: integer,
  cat_code: integer
)
@param char_code - The character code, for example ASCII or UNICODE character code.

@param cat_code - The category code (0 stands for the escape character, normally \, 1 stands for begin grouping, normally { and so on). 😱 Types incomplete or incorrect? 🙏 Please contribute!

Specify a category table to use on assignment or on query (default in both cases is the current one).

Category codes:

  • 0: Escape character, normally \
  • 1: Begin grouping, normally {
  • 2: End grouping, normally }
  • 3: Math shift, normally $
  • 4: Alignment tab, normally &
  • 5: End of line, normally <return>
  • 6: Parameter, normally #
  • 7: Superscript, normally ^
  • 8: Subscript, normally _
  • 9: Ignored character, normally <null>
  • 10: Space, normally <space> and <tab>
  • 11: Letter, normally only contains the letters a,...,z and A,...,Z. These characters can be used in command names
  • 12: Other, normally everything else not listed in the other categories
  • 13: Active character, for example ~
  • 14: Comment character, normally %
  • 15: Invalid character, normally <delete>

Reference:

tex.getcatcode


function tex.getcatcode(
  cat_table: integer,
  char_code: integer
) -> cat_code integer
@param char_code - The character code, for example ASCII or UNICODE character code.

@return cat_code - The category code (0 stands for the escape character, normally \, 1 stands for begin grouping, normally { and so on). 😱 Types incomplete or incorrect? 🙏 Please contribute!

The function call interface for catcode (category code) also allows you to specify a category table to use on assignment or on query (default in both cases is the current one):

Category codes:

  • 0: Escape character, normally \
  • 1: Begin grouping, normally {
  • 2: End grouping, normally }
  • 3: Math shift, normally $
  • 4: Alignment tab, normally &
  • 5: End of line, normally <return>
  • 6: Parameter, normally #
  • 7: Superscript, normally ^
  • 8: Subscript, normally _
  • 9: Ignored character, normally <null>
  • 10: Space, normally <space> and <tab>
  • 11: Letter, normally only contains the letters a,...,z and A,...,Z. These characters can be used in command names
  • 12: Other, normally everything else not listed in the other categories
  • 13: Active character, for example ~
  • 14: Comment character, normally %
  • 15: Invalid character, normally <delete>

tex.setmathcode


function tex.setmathcode(
  global: "global",
  char_code: integer,
  class: integer,
  family: integer,
  character: integer
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param char_code - The ASCII or UNICODE charcater code point.

@param class - The class to which a math character belongs (0: Ordinary, 1: Large operator, 2: Binary operation, 3: Relation, 4: Opening, 5: Closing, 6: Punctuation, 7: Variable family).

@param family - TeX uses fonts from one or more of the sixteen font families to typeset mathematical characters. Each font family consists of three fonts — textfont, scriptfont, and scriptscriptfont. (0: Roman, 1: Math italic, 2: Math symbol, 3: Math extension, 4: Italic text, 5: Slanted text, 6: Bold text, 7: Typewriter)

@param character - The character position 😱 Types incomplete or incorrect? 🙏 Please contribute!

class:

Class Meaning Example
0 Ordinary /
1 Large operator \sum
2 Binary operation +
3 Relation =
4 Opening (
5 Closing )
6 Punctuation ,
7 Variable family x

family:

% Family 0 (Roman)
\font\tenrm=mdbchr7t at10pt
\font\sevenrm=mdbchr7t at7pt
\font\fiverm=mdbchr7t at5pt
\textfont0=\tenrm
\scriptfont0=\sevenrm
27
\scriptscriptfont0=\fiverm
\def\rm{\fam=0 \tenrm}
%
% Family 1 (Math italic)
\font\teni=mdbchri7m at10pt
\font\seveni=mdbchri7m at7pt
\font\fivei=mdbchri7m at5pt
\textfont1=\teni
\scriptfont1=\seveni
\scriptscriptfont1=\fivei
\def\mit{\fam=1}
%
% Family 2 (Math symbols)
\font\tensy=md-chr7y at10pt
\font\sevensy=md-chr7y at7pt
\font\fivesy=md-chr7y at5pt
\textfont2=\tensy
\scriptfont2=\
% Family 3 (Math extension)
\font\tenex=mdbchr7v at10pt
\font\sevenex=mdbchr7v at7pt
\font\fiveex=mdbchr7v at5pt
\textfont3=\tenex
\scriptfont3=\sevenex
\scriptscriptfont3=\fiveex
%
% Family 4 (Italic text)
\font\tenit=mdbchri7t at10pt
\font\sevenit=mdbchri7t at7pt
\font\fiveit=mdbchri7t at5pt
\textfont\itfam=\tenit
\scriptfont\itfam=\sevenit
\scriptscriptfont\itfam=\fiveit
\def\it{\fam=\itfam \tenit}
%
% Family 5 (Slanted text)
\font\tensl=mdbchro7t at10pt
\font\sevensl=mdbchro7t at7pt
\font\fivesl=mdbchro7t at5pt
\textfont\slfam=\tensl
\scriptfont\slfam=\sevensl
\scriptscriptfont\slfam=\fivesl
\def\sl{\fam=\slfam \tensl}
%
% Family 6 (Bold text)
\font\tenbf=mdbchb7t at10pt
\font\sevenbf=mdbchb7t at7pt
\font\fivebf=mdbchb7t at5pt
\textfont\bffam=\tenbf
\scriptfont\bffam=\sevenbf
\scriptscriptfont\bffam=\fivebf
\def\bf{\fam=\bffam \tenbf}
%
% Family 7 (Typewriter)
\font\tentt=cmtt10---%
\rm
% Sets normal roman font
\font\seventt=cmtt10 at7pt
\font\fivett=cmtt10 at5pt
\textfont\ttfam=\tentt
\scriptfont\ttfam=\seventt
\scriptscriptfont\ttfam=\fivett
\def\tt{\fam=\ttfam \tentt}
```sevensy
\scriptscriptfont2=\fivesy
\def\cal{\fam=2}
%
% Family 3 (Math extension)
\font\tenex=mdbchr7v at10pt
\font\sevenex=mdbchr7v at7pt
\font\fiveex=mdbchr7v at5pt
\textfont3=\tenex
\scriptfont3=\sevenex
\scriptscriptfont3=\fiveex
%
% Family 4 (Italic text)
\font\tenit=mdbchri7t at10pt
\font\sevenit=mdbchri7t at7pt
\font\fiveit=mdbchri7t at5pt
\textfont\itfam=\tenit
\scriptfont\itfam=\sevenit
\scriptscriptfont\itfam=\fiveit
\def\it{\fam=\itfam \tenit}
%
% Family 5 (Slanted text)
\font\tensl=mdbchro7t at10pt
\font\sevensl=mdbchro7t at7pt
\font\fivesl=mdbchro7t at5pt
\textfont\slfam=\tensl
\scriptfont\slfam=\sevensl
\scriptscriptfont\slfam=\fivesl
\def\sl{\fam=\slfam \tensl}
%
% Family 6 (Bold text)
\font\tenbf=mdbchb7t at10pt
\font\sevenbf=mdbchb7t at7pt
\font\fivebf=mdbchb7t at5pt
\textfont\bffam=\tenbf
\scriptfont\bffam=\sevenbf
\scriptscriptfont\bffam=\fivebf
\def\bf{\fam=\bffam \tenbf}
%
% Family 7 (Typewriter)
\font\tentt=cmtt10---%
\rm
% Sets normal roman font
\font\seventt=cmtt10 at7pt
\font\fivett=cmtt10 at5pt
\textfont\ttfam=\tentt
\scriptfont\ttfam=\seventt
\scriptscriptfont\ttfam=\fivett
\def\tt{\fam=\ttfam \tentt}

Reference:

  • Corresponding C source code: ltexlib.c#L1524-1561
  • Corresponding plain TeX control sequence: \mathcode
  • Donald E. Knuth: The TeXbook, Page 154
  • TUGboat, Volume 31 (2010), No. 1, Mathematical typefaces in TEX documents, Amit Raj Dhawan

tex.setmathcode


function tex.setmathcode(
  global: "global",
  char_code: integer,
  class: integer,
  family: integer,
  character: integer
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param char_code - The ASCII or UNICODE charcater code point.

@param class - The class to which a math character belongs (0: Ordinary, 1: Large operator, 2: Binary operation, 3: Relation, 4: Opening, 5: Closing, 6: Punctuation, 7: Variable family).

@param family - TeX uses fonts from one or more of the sixteen font families to typeset mathematical characters. Each font family consists of three fonts — textfont, scriptfont, and scriptscriptfont. (0: Roman, 1: Math italic, 2: Math symbol, 3: Math extension, 4: Italic text, 5: Slanted text, 6: Bold text, 7: Typewriter)

@param character - The character position 😱 Types incomplete or incorrect? 🙏 Please contribute!

class:

Class Meaning Example
0 Ordinary /
1 Large operator \sum
2 Binary operation +
3 Relation =
4 Opening (
5 Closing )
6 Punctuation ,
7 Variable family x

family:

% Family 0 (Roman)
\font\tenrm=mdbchr7t at10pt
\font\sevenrm=mdbchr7t at7pt
\font\fiverm=mdbchr7t at5pt
\textfont0=\tenrm
\scriptfont0=\sevenrm
27
\scriptscriptfont0=\fiverm
\def\rm{\fam=0 \tenrm}
%
% Family 1 (Math italic)
\font\teni=mdbchri7m at10pt
\font\seveni=mdbchri7m at7pt
\font\fivei=mdbchri7m at5pt
\textfont1=\teni
\scriptfont1=\seveni
\scriptscriptfont1=\fivei
\def\mit{\fam=1}
%
% Family 2 (Math symbols)
\font\tensy=md-chr7y at10pt
\font\sevensy=md-chr7y at7pt
\font\fivesy=md-chr7y at5pt
\textfont2=\tensy
\scriptfont2=\
% Family 3 (Math extension)
\font\tenex=mdbchr7v at10pt
\font\sevenex=mdbchr7v at7pt
\font\fiveex=mdbchr7v at5pt
\textfont3=\tenex
\scriptfont3=\sevenex
\scriptscriptfont3=\fiveex
%
% Family 4 (Italic text)
\font\tenit=mdbchri7t at10pt
\font\sevenit=mdbchri7t at7pt
\font\fiveit=mdbchri7t at5pt
\textfont\itfam=\tenit
\scriptfont\itfam=\sevenit
\scriptscriptfont\itfam=\fiveit
\def\it{\fam=\itfam \tenit}
%
% Family 5 (Slanted text)
\font\tensl=mdbchro7t at10pt
\font\sevensl=mdbchro7t at7pt
\font\fivesl=mdbchro7t at5pt
\textfont\slfam=\tensl
\scriptfont\slfam=\sevensl
\scriptscriptfont\slfam=\fivesl
\def\sl{\fam=\slfam \tensl}
%
% Family 6 (Bold text)
\font\tenbf=mdbchb7t at10pt
\font\sevenbf=mdbchb7t at7pt
\font\fivebf=mdbchb7t at5pt
\textfont\bffam=\tenbf
\scriptfont\bffam=\sevenbf
\scriptscriptfont\bffam=\fivebf
\def\bf{\fam=\bffam \tenbf}
%
% Family 7 (Typewriter)
\font\tentt=cmtt10---%
\rm
% Sets normal roman font
\font\seventt=cmtt10 at7pt
\font\fivett=cmtt10 at5pt
\textfont\ttfam=\tentt
\scriptfont\ttfam=\seventt
\scriptscriptfont\ttfam=\fivett
\def\tt{\fam=\ttfam \tentt}
```sevensy
\scriptscriptfont2=\fivesy
\def\cal{\fam=2}
%
% Family 3 (Math extension)
\font\tenex=mdbchr7v at10pt
\font\sevenex=mdbchr7v at7pt
\font\fiveex=mdbchr7v at5pt
\textfont3=\tenex
\scriptfont3=\sevenex
\scriptscriptfont3=\fiveex
%
% Family 4 (Italic text)
\font\tenit=mdbchri7t at10pt
\font\sevenit=mdbchri7t at7pt
\font\fiveit=mdbchri7t at5pt
\textfont\itfam=\tenit
\scriptfont\itfam=\sevenit
\scriptscriptfont\itfam=\fiveit
\def\it{\fam=\itfam \tenit}
%
% Family 5 (Slanted text)
\font\tensl=mdbchro7t at10pt
\font\sevensl=mdbchro7t at7pt
\font\fivesl=mdbchro7t at5pt
\textfont\slfam=\tensl
\scriptfont\slfam=\sevensl
\scriptscriptfont\slfam=\fivesl
\def\sl{\fam=\slfam \tensl}
%
% Family 6 (Bold text)
\font\tenbf=mdbchb7t at10pt
\font\sevenbf=mdbchb7t at7pt
\font\fivebf=mdbchb7t at5pt
\textfont\bffam=\tenbf
\scriptfont\bffam=\sevenbf
\scriptscriptfont\bffam=\fivebf
\def\bf{\fam=\bffam \tenbf}
%
% Family 7 (Typewriter)
\font\tentt=cmtt10---%
\rm
% Sets normal roman font
\font\seventt=cmtt10 at7pt
\font\fivett=cmtt10 at5pt
\textfont\ttfam=\tentt
\scriptfont\ttfam=\seventt
\scriptscriptfont\ttfam=\fivett
\def\tt{\fam=\ttfam \tentt}

Reference:

  • Corresponding C source code: ltexlib.c#L1524-L1561
  • Corresponding plain TeX control sequence: \mathcode
  • Donald E. Knuth: The TeXbook, Page 154
  • TUGboat, Volume 31 (2010), No. 1, Mathematical typefaces in TEX documents, Amit Raj Dhawan

tex.setmathcode


function tex.setmathcode(
  global: "global",
  char_code: integer,
  math_code: MathCode
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param char_code - The ASCII or UNICODE charcater code point.

@param math_code - A table with three integers (class, family, character). 😱 Types incomplete or incorrect? 🙏 Please contribute!

Reference:

tex.setmathcode


function tex.setmathcode(
  char_code: integer,
  math_code: MathCode
)
@param char_code - The ASCII or UNICODE charcater code point.

@param math_code - A table with three integers (class, family, character). 😱 Types incomplete or incorrect? 🙏 Please contribute!

Reference:

tex.getmathcode


function tex.getmathcode(char_code: integer) -> math_code MathCode

@return math_code - A table with three integers (class, family, character). 😱 Types incomplete or incorrect? 🙏 Please contribute!

Retrieve the math code of a character as a table with three integers (class, family, character).

Examples from The TeXBook, page 154:

\mathcode‘<="313C

  • ASCII <: 60 (decimal) 3C (hexadecimal)
  • class: 3
  • family: 1
  • character: 60
local mathcode = tex.getmathcode(60)
print(mathcode[1], mathcode[2], mathcode[3]) -- 3 1 60

\mathcode‘*="2203

  • ASCII *: 42 (decimal) 2A (hexadecimal)
  • class: 2
  • family: 2
  • character: 3
local mathcode = tex.getmathcode(42)
print(mathcode[1], mathcode[2], mathcode[3]) -- 2 2 3

Reference:

tex.getmathcodes


function tex.getmathcodes(char_code: integer)
 -> class integer
 -> family integer
 -> character integer

@return class - The class to which a math character belongs (0: Ordinary, 1: Large operator, 2: Binary operation, 3: Relation, 4: Opening, 5: Closing, 6: Punctuation, 7: Variable family).

@return family - TeX uses fonts from one or more of the sixteen font families to typeset mathematical characters. Each font family consists of three fonts — textfont, scriptfont, and scriptscriptfont. (0: Roman, 1: Math italic, 2: Math symbol, 3: Math extension, 4: Italic text, 5: Slanted text, 6: Bold text, 7: Typewriter)

@return character - The character position 😱 Types incomplete or incorrect? 🙏 Please contribute!

Retrieve the math code of a character as three integers (class, family, character).

Examples from The TeXBook, page 154:

\mathcode‘<="313C

  • ASCII <: 60 (decimal) 3C (hexadecimal)
  • class: 3
  • family: 1
  • character: 60
print(tex.getmathcodes(60)) -- 3 1 60

\mathcode‘*="2203

  • ASCII *: 42 (decimal) 2A (hexadecimal)
  • class: 2
  • family: 2
  • character: 3
print(tex.getmathcodes(42)) -- 2 2 3

class:

Class Meaning Example
0 Ordinary /
1 Large operator \sum
2 Binary operation +
3 Relation =
4 Opening (
5 Closing )
6 Punctuation ,
7 Variable family x

family:

% Family 0 (Roman)
\font\tenrm=mdbchr7t at10pt
\font\sevenrm=mdbchr7t at7pt
\font\fiverm=mdbchr7t at5pt
\textfont0=\tenrm
\scriptfont0=\sevenrm
27
\scriptscriptfont0=\fiverm
\def\rm{\fam=0 \tenrm}
%
% Family 1 (Math italic)
\font\teni=mdbchri7m at10pt
\font\seveni=mdbchri7m at7pt
\font\fivei=mdbchri7m at5pt
\textfont1=\teni
\scriptfont1=\seveni
\scriptscriptfont1=\fivei
\def\mit{\fam=1}
%
% Family 2 (Math symbols)
\font\tensy=md-chr7y at10pt
\font\sevensy=md-chr7y at7pt
\font\fivesy=md-chr7y at5pt
\textfont2=\tensy
\scriptfont2=\
% Family 3 (Math extension)
\font\tenex=mdbchr7v at10pt
\font\sevenex=mdbchr7v at7pt
\font\fiveex=mdbchr7v at5pt
\textfont3=\tenex
\scriptfont3=\sevenex
\scriptscriptfont3=\fiveex
%
% Family 4 (Italic text)
\font\tenit=mdbchri7t at10pt
\font\sevenit=mdbchri7t at7pt
\font\fiveit=mdbchri7t at5pt
\textfont\itfam=\tenit
\scriptfont\itfam=\sevenit
\scriptscriptfont\itfam=\fiveit
\def\it{\fam=\itfam \tenit}
%
% Family 5 (Slanted text)
\font\tensl=mdbchro7t at10pt
\font\sevensl=mdbchro7t at7pt
\font\fivesl=mdbchro7t at5pt
\textfont\slfam=\tensl
\scriptfont\slfam=\sevensl
\scriptscriptfont\slfam=\fivesl
\def\sl{\fam=\slfam \tensl}
%
% Family 6 (Bold text)
\font\tenbf=mdbchb7t at10pt
\font\sevenbf=mdbchb7t at7pt
\font\fivebf=mdbchb7t at5pt
\textfont\bffam=\tenbf
\scriptfont\bffam=\sevenbf
\scriptscriptfont\bffam=\fivebf
\def\bf{\fam=\bffam \tenbf}
%
% Family 7 (Typewriter)
\font\tentt=cmtt10---%
\rm
% Sets normal roman font
\font\seventt=cmtt10 at7pt
\font\fivett=cmtt10 at5pt
\textfont\ttfam=\tentt
\scriptfont\ttfam=\seventt
\scriptscriptfont\ttfam=\fivett
\def\tt{\fam=\ttfam \tentt}
```sevensy
\scriptscriptfont2=\fivesy
\def\cal{\fam=2}
%
% Family 3 (Math extension)
\font\tenex=mdbchr7v at10pt
\font\sevenex=mdbchr7v at7pt
\font\fiveex=mdbchr7v at5pt
\textfont3=\tenex
\scriptfont3=\sevenex
\scriptscriptfont3=\fiveex
%
% Family 4 (Italic text)
\font\tenit=mdbchri7t at10pt
\font\sevenit=mdbchri7t at7pt
\font\fiveit=mdbchri7t at5pt
\textfont\itfam=\tenit
\scriptfont\itfam=\sevenit
\scriptscriptfont\itfam=\fiveit
\def\it{\fam=\itfam \tenit}
%
% Family 5 (Slanted text)
\font\tensl=mdbchro7t at10pt
\font\sevensl=mdbchro7t at7pt
\font\fivesl=mdbchro7t at5pt
\textfont\slfam=\tensl
\scriptfont\slfam=\sevensl
\scriptscriptfont\slfam=\fivesl
\def\sl{\fam=\slfam \tensl}
%
% Family 6 (Bold text)
\font\tenbf=mdbchb7t at10pt
\font\sevenbf=mdbchb7t at7pt
\font\fivebf=mdbchb7t at5pt
\textfont\bffam=\tenbf
\scriptfont\bffam=\sevenbf
\scriptscriptfont\bffam=\fivebf
\def\bf{\fam=\bffam \tenbf}
%
% Family 7 (Typewriter)
\font\tentt=cmtt10---%
\rm
% Sets normal roman font
\font\seventt=cmtt10 at7pt
\font\fivett=cmtt10 at5pt
\textfont\ttfam=\tentt
\scriptfont\ttfam=\seventt
\scriptscriptfont\ttfam=\fivett
\def\tt{\fam=\ttfam \tentt}

Reference:

  • Corresponding C source code: ltexlib.c#L1579-L1589
  • Corresponding plain TeX control sequence: \mathcode
  • Donald E. Knuth: The TeXbook, Page 154
  • TUGboat, Volume 31 (2010), No. 1, Mathematical typefaces in TEX documents, Amit Raj Dhawan

tex.setdelcode


function tex.setdelcode(
  global: "global",
  char_code: integer,
  small_family: integer,
  small_character: integer,
  large_family: integer,
  large_character: integer
)
@param global - It is possible to define values globally by using the string global as the first function argument.

-Reference:

tex.setdelcode


function tex.setdelcode(
  char_code: integer,
  small_family: integer,
  small_character: integer,
  large_family: integer,
  large_character: integer
)

-Reference:

tex.setdelcode


function tex.setdelcode(
  global: "global",
  char_code: integer,
  del_code: DelCode
)
@param global - It is possible to define values globally by using the string global as the first function argument.

tex.setdelcode


function tex.setdelcode(
  char_code: integer,
  del_code: DelCode
)

-Reference:

tex.getdelcodes


function tex.getdelcodes(char_code: integer)
 -> small_family integer
 -> small_character integer
 -> large_family integer
 -> large_character integer

tex.getdelcode


function tex.getdelcode(char_code: integer) ->  DelCode

-Reference:

tex.setbox


function tex.setbox(
  global: "global",
  register: integer,
  head: Node {
    next = Node?,
    prev = Node?,
    id = integer,
    subtype = integer,
    head = Node?,
    attr = Node,
}
)
@param global - It is possible to define values globally by using the string global as the first function argument.

@param register - A box register number (0 to 65535).

@param head - A hlist or vlist node. 😱 Types incomplete or incorrect? 🙏 Please contribute!

Set a box, coming for instance from hbox, vbox or vtop.

Reference:

tex.setbox


function tex.setbox(
  register: integer,
  head: Node {
    next = Node?,
    prev = Node?,
    id = integer,
    subtype = integer,
    head = Node?,
    attr = Node,
}
)
@param register - A box register number (0 to 65535).

@param head - A hlist or vlist node. 😱 Types incomplete or incorrect? 🙏 Please contribute!

Set a box, coming for instance from hbox, vbox or vtop.

Reference:

tex.getbox


function tex.getbox(register: (integer|string)) -> head Node?
@param register - A box register number (0 to 65535) or a cs name (for example \newbox\MyBox: MyBox)

Query an actual box, coming for instance from hbox, vbox or vtop.

Reference:

tex.isbox


function tex.isbox(register: (integer|string)) ->  boolean
@param register - A box register number (0 to 65535) or a cs name (for example \newbox\MyBox: MyBox)

Check if the given integer is a valid box register number.

Example:

print(tex.isbox(65535)) -- true
print(tex.isbox(65536)) -- false

Reference:

tex.saveboxresource


function tex.saveboxresource(
  n: (Node|integer),
  attributes: string,
  resources: string,
  immediate: boolean,
  type: integer,
  margin: integer
) -> index integer
@param n - Instead of a box number one can also pass a [h|v]list node.

@param type - When set to non-zero the /Type entry is omitted. A value of 1 or 3 still writes a /BBox, while 2 or 3 will write a /Matrix.

@param margin - The (virtual) margin that extends beyond the effective boundingbox as seen by TeX.

Register a box for reuse (this is modelled after so called xforms in PDF). You can (re)use the box with useboxresource or by creating a rule node with subtype 2.

@see tex.useboxresource

tex.getboxresourcebox


function tex.getboxresourcebox(n: integer) ->  Node {
    next = Node?,
    prev = Node?,
    id = integer,
    subtype = integer,
    head = Node?,
    attr = Node,
}

tex.useboxresource


function tex.useboxresource(
  n: integer,
  width: integer?,
  height: integer?,
  depth: integer?
)
 -> margin Node?
 -> width integer?
 -> height integer?
 -> depth integer?

Generate the reference (a rule type).

The dimensions are optional and the final ones are returned as extra values.

@see tex.saveboxresource

tex.getboxresourcedimensions


function tex.getboxresourcedimensions(n: Node {
    next = Node?,
    prev = Node?,
    id = integer,
    subtype = integer,
    head = Node?,
    attr = Node,
})
 -> width integer?
 -> height integer?
 -> depth integer?
 -> margin integer?

Return the width, height, depth and margin of the resource.

No dimensions returned means that the resource is unknown.

tex.triggerbuildpage


function tex.triggerbuildpage()

Call the internal function that build a page, given that there is something to build.

You should not expect to much from the triggerbuildpage helpers because often TeX doesn't do much if it thinks nothing has to be done, but it might be useful for some applications.

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.splitbox


function tex.splitbox(
  n: Node {
    next = Node?,
    prev = Node?,
    id = integer,
    subtype = integer,
    head = Node?,
    attr = Node,
},
  height: integer,
  mode: ("additional"|"exactly")
) -> vlist Node?

Split a box.

The remainder is kept in the original box and a packaged vlist is returned. This operation is comparable to the vsplit operation. The mode can be additional or exactly and concerns the split off box.

tex.setmath


function tex.setmath(
  math_param_name: MathParamName,
  math_style_name: MathStyleName,
  value: integer
)

Set the internal math parameters.

tex.setmath


function tex.setmath(
  global: "global",
  math_param_name: MathParamName,
  math_style_name: MathStyleName,
  value: (integer|Node)
)
@param global - Indicate a global assignment.

@param value - The value is either a number (representing a dimension or number) or a glue spec node representing a muskip for ordordspacing and similar spacing parameters. 😱 Types incomplete or incorrect? 🙏 Please contribute!

Set the internal math parameters.

tex.getmath


function tex.getmath(
  math_param_name: MathParamName,
  math_style_name: MathStyleName
) -> value (integer|Node)

@return value - The value is either a number (representing a dimension or number) or a glue spec node representing a muskip for ordordspacing and similar spacing parameters.

😱 Types incomplete or incorrect? 🙏 Please contribute!

Query the internal math parameters.

tex.setlist


function tex.setlist()

You have to be careful with what you set as TeX can have expectations with regards to how a list is constructed or in what state it is.

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.getlist


function tex.getlist()

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.getnest


function tex.getnest() ->  Nest {
    mode = number,
    modeline = integer,
    head = Node,
    tail = Node,
    prevgraf = integer,
    prevdepth = integer,
    spacefactor = integer,
    dirs = Node,
    noad = Node,
    delimptr = Node,
    mathdir = boolean,
    mathstyle = integer,
    ...(+0)
}

The getter function is getnest. You can pass a number (which gives you a list), nothing or top, which returns the topmost list, or the string ptr which gives you the index of the topmost list.

tex.setnest


function tex.setnest()

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.getmodevalues


function tex.getmodevalues()

tex.getmodevalues() to get the mapping: positive values signal vertical, horizontal and math mode, while negative values indicate inner and inline variants (all modes).

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.print


function tex.print(
  input_line: PrintableInput,
  ...: PrintableInput
)
@param input_line - Each string argument is treated by TeX as a separate input line.

@param ... - The very last string of the very last tex.print command in a directlua will not have the endlinechar appended, all others do.

Reference:

@see tex.sprint tex.tprint tex.cprint tex.write

tex.print


function tex.print(
  catcodetable_no: integer,
  input_line: PrintableInput,
  ...: PrintableInput
)
@param catcodetable_no - The parameter can be used to print the strings using the catcode regime defined by \catcodetable catcodetable_no. If catcodetable_no is -1, the currently active catcode regime is used. If catcodetable_no is -2, the resulting catcodes are the result of \the \toks: all category codes are 12 (other) except for the space character, that has category code 10 (space). Otherwise, if catcodetable_no is not a valid catcode table, then it is ignored, and the currently active catcode regime is used instead.

@param input_line - Each string argument is treated by TeX as a separate input line.

@param ... - The very last string of the very last tex.print command in a directlua will not have the endlinechar appended, all others do.

Reference:

@see tex.print tex.sprint tex.tprint tex.cprint tex.write

tex.print


function tex.print(input_lines: PrintableInput[])
@param input_lines - Each string (or number) element of the input table is treated by TeX as a separate input line.

If there is a table argument instead of a list of strings, this has to be a consecutive array of strings to print (the first non-string value will stop the printing process).

see LuaTeX manual: 10.3.14.1 print

Reference:

@see tex.sprint tex.tprint tex.cprint tex.write

tex.print


function tex.print(
  catcodetable_no: integer,
  input_lines: PrintableInput[]
)
@param catcodetable_no - The parameter can be used to print the strings using the catcode regime defined by \catcodetable catcodetable_no. If catcodetable_no is -1, the currently active catcode regime is used. If catcodetable_no is -2, the resulting catcodes are the result of \the \toks: all category codes are 12 (other) except for the space character, that has category code 10 (space). Otherwise, if catcodetable_no is not a valid catcode table, then it is ignored, and the currently active catcode regime is used instead.

@param input_lines - Each string element of the input table is treated by TeX as a separate input line.

see LuaTeX manual: 10.3.14.1 print

Reference:

@see tex.sprint tex.tprint tex.cprint tex.write

tex.sprint


function tex.sprint(
  input: PrintableInput,
  ...: PrintableInput
)

combines all of its arguments (or the elements of array argument) into a single input line for TeX. So any leading spaces will be treated as if they were typed, etc. (s(ingle-input-line)print).

Each string argument is treated by TeX as a special kind of input line that makes it suitable for use as a partial line input mechanism:

  • TeX does not switch to the “new line” state, so that leading spaces are not ignored.
  • No endlinechar is inserted.
  • Trailing spaces are not removed. Note that this does not prevent TeX itself from eating spaces as result of interpreting the line. For example, in
before\directlua{tex.sprint("\\relax")tex.sprint(" inbetween")}after

the space before in between will be gobbled as a result of the “normal” scanning of \relax.

If there is a table argument instead of a list of strings, this has to be a consecutive array of strings to print (the first non-string value will stop the printing process).

The optional argument sets the catcode regime, as with tex.print. This influences the string arguments (or numbers turned into strings).

Although this needs to be used with care, you can also pass token or node userdata objects. These get injected into the stream. Tokens had best be valid tokens, while nodes need to be around when they get injected. Therefore it is important to realize the following:

  • When you inject a token, you need to pass a valid token userdata object. This object will be collected by Lua when it no longer is referenced. When it gets printed to TeX the token itself gets copied so there is no interference with the Lua garbage collection. You manage the object yourself. Because tokens are actually just numbers, there is no real extra overhead at the TeX end.
  • When you inject a node, you need to pass a valid node userdata object. The node related to the object will not be collected by Lua when it no longer is referenced. It lives on at the TeX end in its own memory space. When it gets printed to TeX the node reference is used assuming that node stays around. There is no Lua garbage collection involved. Again, you manage the object yourself. The node itself is freed when TeX is done with it.

If you consider the last remark you might realize that we have a problem when a printed mix of strings, tokens and nodes is reused. Inside TeX the sequence becomes a linked list of input buffers. So, "123" or "\foo{123"} gets read and parsed on the fly, while <token userdata> already is tokenized and effectively is a token list now. A <node userdata> is also tokenized into a token list but it has a reference to a real node. Normally this goes fine. But now assume that you store the whole lot in a macro: in that case the tokenized node can be flushed many times. But, after the first such flush the node is used and its memory freed. You can prevent this by using copies which is controlled by setting luacopyinputnodes to a non-zero value. This is one of these fuzzy areas you have to live with if you really mess with these low level issues.

Reference:

@see tex.print tex.tprint tex.cprint tex.write

tex.sprint


function tex.sprint(
  catcodetable_no: integer,
  input: PrintableInput,
  ...: PrintableInput
)
@param catcodetable_no - The parameter can be used to print the strings using the catcode regime defined by \catcodetable catcodetable_no. If catcodetable_no is -1, the currently active catcode regime is used. If catcodetable_no is -2, the resulting catcodes are the result of \the \toks: all category codes are 12 (other) except for the space character, that has category code 10 (space). Otherwise, if catcodetable_no is not a valid catcode table, then it is ignored, and the currently active catcode regime is used instead.

Reference:

@see tex.print tex.tprint tex.cprint tex.write

tex.sprint


function tex.sprint(input: PrintableInput[])
@param input - Each string element of the input table is treated by TeX as a separate input argument.

(s(ingle-input-line)print).

Reference:

@see tex.print tex.tprint tex.cprint tex.write

tex.sprint


function tex.sprint(
  catcodetable_no: integer,
  input: PrintableInput[]
)
@param catcodetable_no - The parameter can be used to print the strings using the catcode regime defined by \catcodetable catcodetable_no. If catcodetable_no is -1, the currently active catcode regime is used. If catcodetable_no is -2, the resulting catcodes are the result of \the \toks: all category codes are 12 (other) except for the space character, that has category code 10 (space). Otherwise, if catcodetable_no is not a valid catcode table, then it is ignored, and the currently active catcode regime is used instead.---@param t table

@param input - Each string element of the input table is treated by TeX as a separate input argument.

Reference:

@see tex.print tex.tprint tex.cprint tex.write

tex.tprint


function tex.tprint(
  input: PrintableInput[],
  ...: PrintableInput[]
)
@param input - Each string element of the input table is treated by TeX as a separate input argument.

Print tables of strings to the input stream (t(able)print).

This function is basically a shortcut for repeated calls to tex.sprint(catcodetable_no, input, ...), once for each of the supplied argument tables.

\begingroup
\catcode`\_=12
\savecatcodetable 2
\endgroup
\tt\directlua{tex.tprint({ 2, '_' })}
tex.tprint({ 1, 1, 2, 3 }) -- output: 123

Reference:

@see tex.print tex.sprint tex.cprint tex.write

tex.cprint


function tex.cprint(
  catcode: integer,
  input: PrintableInput,
  ...: PrintableInput
)
@param catcode - The category code (0 stands for the escape character, normally \, 1 stands for begin grouping, normally { and so on).

Print to the input stream and specify a catcode (c(atcode)print).

tex.cprint( 1, " 1: `&{\\foo}") tex.print("\\par") -- a lot of \bgroup s
tex.cprint( 2, " 2: `&{\\foo}") tex.print("\\par") -- matching \egroup s
tex.cprint( 9, " 9: `&{\\foo}") tex.print("\\par") -- all get ignored
tex.cprint(10, "10: `&{\\foo}") tex.print("\\par") -- all become spaces
tex.cprint(11, "11: `&{\\foo}") tex.print("\\par") -- letters
tex.cprint(12, "12: `&{\\foo}") tex.print("\\par") -- other characters
tex.cprint(14, "12: $&{\\foo}") tex.print("\\par") -- comment triggers

Reference:

@see tex.print tex.sprint tex.tprint tex.write

tex.cprint


function tex.cprint(
  catcode: integer,
  input: PrintableInput[]
)
@param catcode - The category code (0 stands for the escape character, normally \, 1 stands for begin grouping, normally { and so on).

@param input - Each string element of the input table is treated by TeX as a separate input argument.

Print to the input stream and specify a catcode (c(atcode)print).

Reference:

@see tex.print tex.sprint tex.tprint tex.write

tex.write


function tex.write(
  input: PrintableInput,
  ...: PrintableInput
)

Print to the input stream using category code 12 (other) except for the space character, that has category code 10 (space).

Each string argument is treated by TeX as a special kind of input line that makes it suitable for use as a quick way to dump information:

  • All catcodes on that line are either “space” (for ) or “character” (for all others).
  • There is no endlinechar appended.

Reference:

@see tex.print tex.sprint tex.tprint tex.cprint

tex.write


function tex.write(input: PrintableInput[])
@param input - Each string element of the input table is treated by TeX as a separate input argument.

Print to the input stream using category code 12 (other) except for the space character, that has category code 10 (space).

Each string argument is treated by TeX as a special kind of input line that makes it suitable for use as a quick way to dump information:

  • All catcodes on that line are either “space” (for ) or “character” (for all others).
  • There is no endlinechar appended.

Reference:

@see tex.print tex.sprint tex.tprint tex.cprint

tex.round


function tex.round(o: number) ->  integer

Rounds Lua number o, and returns a number that is in the range of a valid TeX register value. If the number starts out of range, it generates a “number too big” error as well.

Reference:

tex.scale


function tex.scale(
  o: number,
  delta: number
) ->  number

Multiplies the Lua numbers o and delta, and returns a rounded number that is in the range of a valid TeX register value. In the table version, it creates a copy of the table with all numeric top-level values scaled in that manner. If the multiplied number(s) are of range, it generates “number too big” error(s) as well.

Note: the precision of the output of this function will depend on your computer's architecture and operating system, so use with care! An interface to LuaTeX's internal, 100% portable scale function will be added at a later date.

Reference:

tex.scale


function tex.scale(
  o: table,
  delta: number
) ->  table

tex.number


function tex.number(n: integer) ->  integer

Companion to the primitive \number.

Reference:

  • Corresponding C source code: ltexlib.c#L2484-2513
  • https://www.tug.org/utilities/plain/cseq.html#number-rp

tex.romannumeral


function tex.romannumeral(n: integer) ->  string
@param n - for example 2025

@return - for example mmxxv

😱 Types incomplete or incorrect? 🙏 Please contribute!

Companion to the primitive \romannumeral.

Reference:

tex.fontidentifier


function tex.fontidentifier(font_id: integer) ->  string

@return - for example \tenrm.

😱 Types incomplete or incorrect? 🙏 Please contribute!

returns the csname string that matches a font id number (if there is one).

Reference:

tex.fontname


function tex.fontname(font_id: integer) ->  string

@return - for example cmr10.

😱 Types incomplete or incorrect? 🙏 Please contribute!

The first one returns the name only, the second one reports the size too.

Reference:

tex.sp


function tex.sp(o: integer) ->  integer

Converts the number o that represents an explicit dimension into an integer number of scaled points.

see LuaTeX manual: 10.3.15.5 sp

Reference:

tex.sp


function tex.sp(s: string) ->  integer
@param s - A string to convert into scaled points.

@return - The dimension in the scaled points format.

😱 Types incomplete or incorrect? 🙏 Please contribute!

Convert a string s that represents an explicit dimension into an integer number of scaled points.

For parsing the string, the same scanning and conversion rules are used that LuaTeX would use if it was scanning a dimension specifier in its TeX-like input language (this includes generating errors for bad values), expect for the following:

  • only explicit values are allowed, control sequences are not handled
  • infinite dimension units (fil...) are forbidden
  • mu units do not generate an error (but may not be useful either)

Example:

local scaled_points = tex.sp('1cm')
print(scaled_points) -- 1864679

Reference:

tex.error


function tex.error(
  message: string,
  help: table?
)
@param message - An error message like \errmessage.

@param help - The array part of the help table has to contain strings, one for each line of error help.

😱 Types incomplete or incorrect? 🙏 Please contribute!

Create an error like the combination of \errhelp and \errmessage.

During this error, deletions are disabled.

see LuaTeX manual: 10.3.15.5 sp

Reference:

tex.show_context


function tex.show_context()

Show the current (expansion) context in case of an error.

-Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.run


function tex.run()

Start the interpretation.

A run normally boils down to TeX entering the so called main loop. A token is fetched and depending on it current meaning some actions takes place. Sometimes that actions comes immediately, sometimes more scanning is needed. Quite often tokens get pushed back into the input. This all means that the TeX scanner is constantly pushing and popping input states, but in the end after all the action is done returns to the main loop.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.finish


function tex.finish()

Force the end of an interpretation.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.runtoks


function tex.runtoks(
  token_register: integer,
  force: boolean?,
  grouped: boolean?
)
@param force - force the local main loop

@param grouped - adds a level of grouping.

😱 Types incomplete or incorrect? 🙏 Please contribute!

Because of the fact that TeX is in a complex dance of expanding, dealing with fonts, typesetting paragraphs, messing around with boxes, building pages, and so on, you cannot easily run a nested TeX run (read nested main loop). However, there is an option to force a local run with runtoks. The content of the given token list register gets expanded locally after which we return to where we triggered this expansion, at the Lua end. Instead a function can get passed that does some work. You have to make sure that at the end TeX is in a sane state and this is not always trivial. A more complex mechanism would complicate TeX itself (and probably also harm performance) so this simple local expansion loop has to do.

When the tracingnesting parameter is set to a value larger than 2 some information is reported about the state of the local loop.

Inside for instance an \edef the runtoks function behaves (at least tries to) like it were an \the. This prevents unwanted side effects: normally in such an definition tokens remain tokens and (for instance) characters don't become nodes.

Example:

\toks0{\setbox0\hbox{one}}
\toks1{\setbox0\hbox{first}}
\directlua {
  tex.forcehmode(true)
  tex.runtoks(0)
  print(tex.getbox(0).width)
  tex.runtoks(1)
  print(tex.getbox(0).width)
}

Reference:

tex.runtoks


function tex.runtoks(func: function)

tex.quittoks


function tex.quittoks()

You can quit the local loop with \endlocalcontrol or from the Lua end with tex.quittoks. In that case you end one level up! Of course in the end that can mean that you arrive at the main level in which case an extra end will trigger a redundancy warning (not an abort!).

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.forcehmode


function tex.forcehmode(indented: boolean?)

An example of a (possible error triggering) complication is that TeX expects to be in some state, say horizontal mode, and you have to make sure it is when you start feeding back something from Lua into TeX. Normally a user will not run into issues but when you start writing tokens or nodes or have a nested run there can be situations that you need to run forcehmode. There is no recipe for this and intercepting possible cases would weaken LuaTeX's flexibility.

tex.hashtokens


function tex.hashtokens()

Return a list of names.

This can be useful for debugging, but note that this also reports control sequences that may be unreachable at this moment due to local redefinitions: it is strictly a dump of the hash table. You can use token.create to inspect properties, for instance when the command key in a created table equals 123, you have the cmdname value undefined_cs.

for i,v in pairs(tex.hashtokens()) do ... end

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.definefont


function tex.definefont(
  csname: string,
  fontid: integer
)

Associates csname with the internal font number fontid. The definition is global if (and only if) global is specified and true (the setting of globaldefs is not taken into account).

tex.definefont


function tex.definefont(
  global: boolean,
  csname: string,
  fontid: integer
)

Associates csname with the internal font number fontid. The definition is global if (and only if) global is specified and true (the setting of globaldefs is not taken into account).

tex.enableprimitives


function tex.enableprimitives(
  prefix: string,
  primitive_names: string[]
)

This function accepts a prefix string and an array of primitive names. For each combination of “prefix” and “name”, the tex.enableprimitives first verifies that “name” is an actual primitive (it must be returned by one of the tex.extraprimitives calls explained below, or part of TeX82, or directlua). If it is not, tex.enableprimitives does nothing and skips to the next pair.

But if it is, then it will construct a csname variable by concatenating the “prefix” and “name”, unless the “prefix” is already the actual prefix of “name”. In the latter case, it will discard the “prefix”, and just use “name”.

Then it will check for the existence of the constructed csname. If the csname is currently undefined (note: that is not the same as relax), it will globally define the csname to have the meaning: run code belonging to the primitive “name”. If for some reason the csname is already defined, it does nothing and tries the next pair.

An example:

tex.enableprimitives('LuaTeX', {'formatname'})

will define \LuaTeXformatname with the same intrinsic meaning as the documented primitive formatname, provided that the control sequences \LuaTeXformatname is currently undefined.

When LuaTeX is run with --ini only the TeX82 primitives and directlua are available, so no extra primitives {\bf at all}.

If you want to have all the new functionality available using their default names, as it is now, you will have to add

\ifx\directlua\undefined \else
    \directlua {tex.enableprimitives('',tex.extraprimitives ())}
\fi

near the beginning of your format generation file. Or you can choose different prefixes for different subsets, as you see fit.

Calling some form of tex.enableprimitives is highly important though, because if you do not, you will end up with a TeX82-lookalike that can run Lua code but not do much else. The defined csnames are (of course) saved in the format and will be available at runtime.

*

tex.extraprimitives


function tex.extraprimitives(...: TexEngine) ->  string[]

Return a list of the primitives that originate from the engine(s) given by the requested string value(s).

The possible values and their (current) return values are given in the following table. In addition the somewhat special primitives “\tex{ ”}, “\tex {/”} and “-” are defined.

Note that luatex does not contain directlua, as that is considered to be a core primitive, along with all the TeX82 primitives, so it is part of the list that is returned from core.

Running tex.extraprimitives() will give you the complete list of primitives -ini startup. It is exactly equivalent to tex.extraprimitives("etex","luatex").

tex.primitives


function tex.primitives() ->  string[]

Return a list of all primitives that LuaTeX knows about.

tex.badness


function tex.badness(
  total: integer,
  sum: integer
) -> badness integer
@param total - scaled values

@param sum - scaled values

Calculate the badness.

This helper function is useful during linebreak calculations. The function returns the badness for when total total is supposed to be made from amounts that sum to sum. The returned number is a reasonable approximation of 100(total/sum)^3.

tex.resetparagraph


function tex.resetparagraph()

Reset the parameters that TeX normally resets when a new paragraph is seen.

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.linebreak


function tex.linebreak(
  listhead: Node {
    next = Node?,
    prev = Node?,
    id = integer,
    subtype = integer,
    head = Node?,
    attr = Node,
},
  parameters: LinebreakParameters {
    pardir = string,
    pretolerance = integer,
    tracingparagraphs = integer,
    tolerance = integer,
    looseness = integer,
    hyphenpenalty = integer,
    exhyphenpenalty = integer,
    pdfadjustspacing = integer,
    adjdemerits = integer,
    pdfprotrudechars = integer,
    linepenalty = integer,
    lastlinefit = integer,
    ...(+13)
}
)
 ->  Node {
    next = Node?,
    prev = Node?,
    id = integer,
    subtype = integer,
    head = Node?,
    attr = Node,
}
 ->  table

Note that there is no interface for displaywidowpenalties, you have to pass the right choice for widowpenalties yourself.

It is your own job to make sure that listhead is a proper paragraph list: this function does not add any nodes to it. To be exact, if you want to replace the core line breaking, you may have to do the following (when you are not actually working in the pre_linebreak_filter or linebreak_filter callbacks, or when the original list starting at listhead was generated in horizontal mode):

  • add an “indent box” and perhaps a local_par node at the start (only if you need them)

  • replace any found final glue by an infinite penalty (or add such a penalty, if the last node is not a glue)

  • add a glue node for the parfillskip after that penalty node

  • make sure all the prev pointers are OK

The result is a node list, it still needs to be vpacked if you want to assign it to a vbox. The returned info table contains four values that are all numbers:

name explanation

prevdepth depth of the last line in the broken paragraph prevgraf number of lines in the broken paragraph looseness the actual looseness value in the broken paragraph demerits the total demerits of the chosen solution

Note there are a few things you cannot interface using this function: You cannot influence font expansion other than via pdfadjustspacing, because the settings for that take place elsewhere. The same is true for hbadness and hfuzz etc. All these are in the hpack routine, and that fetches its own variables via globals.

tex.shipout


function tex.shipout()

Ships out box number n to the output file, and clears the box register.

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.getpagestate


function tex.getpagestate()

This helper reports the current page state: empty, box_there or inserts_only as integer value.

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.getlocallevel


function tex.getlocallevel()

This integer reports the current level of the local loop. It's only useful for debugging and the (relative state) numbers can change with the implementation.

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.init_rand


function tex.init_rand(seed: integer)

Initialize a new seed.

lua_math_randomseed is equivalent to this function.

@see tex.lua_math_randomseed

tex.lua_math_randomseed


function tex.lua_math_randomseed(seed: integer)

Initialize a new seed.

init_rand is equivalent to this function.

@see tex.init_rand

tex.lua_math_random


function tex.lua_math_random(
  lower: number,
  upper: number
) ->  number

For practical reasons LuaTeX has its own random number generator. This is the original Lua random function.

tex.lua_math_random


function tex.lua_math_random(upper: number?) ->  number

For practical reasons LuaTeX has its own random number generator. This is the original Lua random function.

tex.normal_rand


function tex.normal_rand()

no argument is used

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.uniform_rand


function tex.uniform_rand()

takes a number that will get rounded before being used

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.uniformdeviate


function tex.uniformdeviate(n: integer)
@param n - a scaled integer

😱 Types incomplete or incorrect? 🙏 Please contribute!

which behaves like the primitive and expects a scaled integer, so

tex.print(tex.uniformdeviate(65536)/65536)

will give a random number between zero and one.

tex.set_synctex_mode


function tex.set_synctex_mode(mode: SyntexMode)

tex.get_synctex_mode


function tex.get_synctex_mode() -> mode SyntexMode

Return the current mode.

tex.set_synctex_tag


function tex.set_synctex_tag(tag: integer)

Set the current tag (file) value (obeys save stack).

tex.get_synctex_tag


function tex.get_synctex_tag() -> tag integer

Get the currently set value of a tag (file).

tex.force_synctex_tag


function tex.force_synctex_tag(tag: integer)

Overload the tag (file) value (0 resets).

tex.set_synctex_line


function tex.set_synctex_line(line: integer)

Set the current line value (obeys save stack).

tex.get_synctex_line


function tex.get_synctex_line() -> line integer

Get the currently set value of a line.

tex.force_synctex_line


function tex.force_synctex_line(line: integer)

Overload the line value (0 resets)

tex.set_synctex_no_files


function tex.set_synctex_no_files(flag: integer)

Disable synctex file logging.

fields


tex.adjdemerits


tex.adjdemerits : integer

\adjdemerits: Penalty for adjacent visually incompatible lines. Default: 10000.

Reference:

tex.binoppenalty


tex.binoppenalty : integer

\binoppenalty: Penalty for breaking after a binary operator not enclosed in a subformula. Default: 700

Reference:

tex.brokenpenalty


tex.brokenpenalty : integer

\brokenpenalty: Additional penalty for breaking a page after a hyphenated line. Default: 100.

Reference:

tex.catcodetable


tex.catcodetable : integer

Catcode tables are a new feature that allows you to switch to a predefined catcode regime in a single statement.

tex.clubpenalty


tex.clubpenalty : integer

\clubpenalty: Extra penalty for breaking a page after the first line of a paragraph. In Plain TeX this is 150. This amount, and the following penalties, are added to the \interlinepenalty, and a penalty of the resulting size is inserted after the \hbox containing the first line of a paragraph instead of the \interlinepenalty.

Reference:

tex.day


tex.day : integer

\day: The day of the current job.

Reference:

tex.defaulthyphenchar


tex.defaulthyphenchar : integer

\defaulthyphenchar: Value of \hyphenchar when a font is loaded. Default: ‘\-.

Reference:

tex.defaultskewchar


tex.defaultskewchar : integer

\defaultskewchar: Value of \skewchar when a font is loaded.

Reference:

tex.delimiterfactor


tex.delimiterfactor : integer

\delimiterfactor: 1000 times the fraction of a delimited formula that should be covered by a delimiter. Default: 901.

Reference:

tex.displaywidowpenalty


tex.displaywidowpenalty : integer

\displaywidowpenalty: Extra penalty for breaking a page before the last line above a display formula. The default value in Plain TeX is 50.

Reference:

tex.doublehyphendemerits


tex.doublehyphendemerits : integer

\doublehyphendemerits: Penalty for consecutive lines ending with a hyphen. Default: 10000.

Reference:

tex.endlinechar


tex.endlinechar : integer

\endlinechar: The character code of the end-of-line character appended to input lines. IniTEX default: 13.

tex.errorcontextlines


tex.errorcontextlines : integer

\errorcontextlines: (TeX3 only) Number of additional context lines shown in error messages.

Reference:

tex.escapechar


tex.escapechar : integer

\escapechar: Number of the character that is to be used for the escape character when control sequences are being converted into character tokens. IniTEX default: 92 (\).

Reference:

tex.exhyphenpenalty


tex.exhyphenpenalty : integer

\exhyphenpenalty: Penalty for breaking a horizontal line at a discretionary item in the special case where the prebreak text is empty. Default: 50.

Reference:

tex.fam


tex.fam : integer

\fam: The number of the current font family.

Reference:

tex.finalhyphendemerits


tex.finalhyphendemerits : integer

\finalhyphendemerits: Penalty added when the penultimate line of a paragraph ends with a hyphen. Default: 5000.

Reference:

tex.floatingpenalty


tex.floatingpenalty : integer

\floatingpenalty: Penalty added when an insertion is split.

Reference:

tex.globaldefs


tex.globaldefs : integer

\globaldefs: Parameter for overriding \global prefixes. IniTEX default: 0.

\globaldefs is a TeX internal parameter. Normally set to 0. If set equal to a positive number, all following definitions and assignments are treated as if preceded by \global. If set equal to a negative number, none of the following definitions or assignments are global, meaning that an explicit \global is ignored. This remains in effect until \globaldefs is explicitly set to 0 again, or the group containing the \globaldefs reassignment ends (assuming it was not made global as well).

Reference:

tex.hangafter


tex.hangafter : integer

\hangafter: If positive, this denotes the number of lines before indenting starts; if negative, the absolute value of this is the number of indented lines starting with the first line of the paragraph. Default: 1.

Reference:

tex.hbadness


tex.hbadness : integer

\hbadness: Amount of tolerance before TEX reports an underfull or overfull horizontal box.

Reference:

tex.holdinginserts


tex.holdinginserts : integer

\holdinginserts (TeX3 only) If this is positive, insertions are not placed in their boxes at output time.

Reference:

tex.hyphenpenalty


tex.hyphenpenalty : integer

\hyphenpenalty: Penalty associated with break at a discretionary item in the general case. Default: 50.

Reference:

tex.interlinepenalty


tex.interlinepenalty : integer

\interlinepenalty: Penalty for breaking a page between lines of a paragraph. Default: 0.

Reference:

tex.language


tex.language : integer

\language: Choose a set of hyphenation patterns and exceptions.

Reference:

tex.lastlinefit


tex.lastlinefit : integer

tex.lefthyphenmin


tex.lefthyphenmin : integer

\lefthyphenmin (TeX3 only) Minimal number of characters before a hyphenation. Default: 2.

Reference:

tex.linepenalty


tex.linepenalty : integer

\linepenalty: Penalty value associated with each line break. Default: 10.

Reference:

tex.localbrokenpenalty


tex.localbrokenpenalty: integer = 0

Local broken penalty (from \localbrokenpenalty)

---@type integer # A readable and writable integer parameter that accepts and returns Lua numbers.

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.localinterlinepenalty


tex.localinterlinepenalty : integer

Local interline penalty (from \localinterlinepenalty)

tex.looseness


tex.looseness : integer

\looseness: Number of lines by which this paragraph has to be made longer than it would be ideally.

Reference:

tex.mag


tex.mag : integer

\mag: 1000 times the magnification of the document.

Reference:

tex.maxdeadcycles


tex.maxdeadcycles : integer

\maxdeadcycles: The maximum number of times that the output routine is allowed to be called without a \shipout occurring. IniTEX default: 25.

Reference:

tex.month


tex.month : integer

\month: The month of the current job.

Reference:

tex.newlinechar


tex.newlinechar : integer

\newlinechar: Number of the character that triggers a new line in \write statements.

Reference:

tex.outputpenalty


tex.outputpenalty : integer

\outputpenalty: Value of the penalty at the current page break, or 10000 if the break was not at a penalty.

Reference:

tex.pausing


tex.pausing : integer

\pausing: Specify that TEX should pause after each line that is read from a file.

Reference:

tex.postdisplaypenalty


tex.postdisplaypenalty : integer

\postdisplaypenalty: Penalty placed in the vertical list below a display. Default: 0

Reference:

tex.predisplaydirection


tex.predisplaydirection: integer = 0

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.predisplaypenalty


tex.predisplaypenalty : integer

\predisplaypenalty: Penalty placed in the vertical list above a display. Default: 10000.

Reference:

tex.pretolerance


tex.pretolerance : integer

\pretolerance: Tolerance value for a paragraph without hyphenation. Default: 100.

Reference:

tex.relpenalty


tex.relpenalty : integer

\relpenalty: Penalty for breaking after a binary relation not enclosed in a subformula. Default: 500

Reference:

tex.righthyphenmin


tex.righthyphenmin : integer

\righthyphenmin: (TeX3 only) Minimum number of characters after a hyphenation. Default: 3.

Reference:

tex.savinghyphcodes


tex.savinghyphcodes : integer

When a \patterns command is executed and \savinghyphcodes has a positive value, the current \lccode values are saved as hyphenation codes for the current language.

Reference:

  • The ε-TEX manual Version 2, February 1998 (updated March 2024), page 11

tex.savingvdiscards


tex.savingvdiscards : integer

When ε-TEX’s parameter \savingvdiscards has been assigned a positive value, these ‘discarded items’ are saved in two lists and can be recovered by the commands \pagediscards and \splitdiscards that act like ‘unvboxing’ hypothetical box registers containing a vbox with the discarded items.

Reference:

  • The ε-TEX manual Version 2, February 1998 (updated March 2024), page 12

tex.showboxbreadth


tex.showboxbreadth : integer

\showboxbreadth: Number of successive elements on each level that are shown when boxes are displayed.

Reference:

tex.showboxdepth


tex.showboxdepth : integer

\showboxdepth: The number of levels of box dump that are shown when boxes are displayed.

Reference:

tex.time


tex.time : integer

\time: Number of minutes after midnight that the current job started.

Reference:

tex.tolerance


tex.tolerance : integer

\tolerance: Tolerance value for lines in a paragraph with hyphenation. Default: 200.

Reference:

tex.tracingassigns


tex.tracingassigns : integer

When the program is compiled with the code for collecting statistics and \tracingassigns has a value of 1 or more, all assignments subject to TeX’s grouping mechanism are traced.

Reference:

  • The ε-TEX manual Version 2, February 1998 (updated March 2024), page 4

tex.tracingcommands


tex.tracingcommands : integer

\tracingcommands: If this is 1 TEX displays primitive commands executed; if this is 2 or more the outcome of conditionals is also recorded.

Reference:

tex.tracinggroups


tex.tracinggroups : integer

When \tracinggroups has a value of 1 or more, the start and end of each save group is traced, together with the starting line and grouping level.

Reference:

  • The ε-TEX manual Version 2, February 1998 (updated March 2024), page 4

tex.tracingifs


tex.tracingifs : integer

When \tracingifs has a value of 1 or more, all conditionals (including \unless, \or, \else, and \fi) are traced, together with the starting line and nesting level.

Reference:

  • The ε-TEX manual Version 2, February 1998 (updated March 2024), page 4

tex.tracinglostchars


tex.tracinglostchars : integer

\tracinglostchars: If this parameter is positive, TeX gives diagnostic messages whenever a character is accessed that is not present in a font. Plain default: 1.

Reference:

tex.tracingmacros


tex.tracingmacros : integer

\tracingmacros: If this is 1, the log file shows expansion of macros that are performed and the actual values of the arguments; if this is 2 or more token parameters such as \output and \everypar are also traced.

Reference:

tex.tracingnesting


tex.tracingnesting : integer

When \tracingnesting has a value of 1 or more, these anomalies are shown; when \tracingnesting has a value of 2 or more, the current context (traceback) is shown as well.

Reference:

  • The ε-TEX manual Version 2, February 1998 (updated March 2024), page 5

tex.tracingonline


tex.tracingonline : integer

\tracingonline: If this parameter is positive, TeX will write trace information to the terminal in addition to the log file.

Reference:

tex.tracingoutput


tex.tracingoutput : integer

\tracingoutput: If this is positive, the log file shows a dump of boxes that are shipped to the dvi file.

Reference:

tex.tracingpages


tex.tracingpages : integer

\tracingpages: If this parameter is positive, TeX generates a trace of the page breaking algorithm.

Reference:

tex.tracingparagraphs


tex.tracingparagraphs : integer

\tracingparagraphs: If this parameter is positive, TeX generates a trace of the line breaking algorithm.

Reference:

tex.tracingrestores


tex.tracingrestores : integer

\tracingrestores: If this parameter is positive, TeX will report all values that are restored when a group ends.

Reference:

tex.tracingscantokens


tex.tracingscantokens : integer

When \tracingscantokens has a value of 1 or more, the opening and closing of pseudo-files (generated by \scantokens) is recorded as for any other file, with ‘␣’ as filename.

Reference:

  • The ε-TEX manual Version 2, February 1998 (updated March 2024), page 5

tex.tracingstats


tex.tracingstats : integer

\tracingstats: If this parameter is 1, TeX reports at the end of the job the usage of various internal arrays; if it is 2, the memory demands are given whenever a page is shipped out.

Reference:

tex.uchyph


tex.uchyph : integer

\uchyph: Positive to allow hyphenation of words starting with a capital letter. Default: 1.

Reference:

tex.vbadness


tex.vbadness : integer

\vbadness: Amount of tolerance before TeX reports an underfull or overfull vertical box.

Reference:

tex.widowpenalty


tex.widowpenalty : integer

\widowpenalty: Additional penalty for breaking a page before the last line of a paragraph. Default: 150

Reference:

tex.year


tex.year : integer

\year: The year of the current job.

Reference:

tex.deadcycles


tex.deadcycles : integer

\deadcycles: Counter that keeps track of how many times the output routine has been called without a \shipout taking place.

Reference:

tex.insertpenalties


tex.insertpenalties : integer

\insertpenalties: Total of penalties for split insertions. Inside the output routine, the number of held-over insertions.

Reference:

tex.parshape


tex.parshape : integer

\parshape: Command for general paragraph shapes.

Reference:

tex.interlinepenalties


tex.interlinepenalties : integer

An extension to \interlinepenalty that allows different penalties to be added after each line. It takes a space separated list of numbers as value. If n is positive interlinepenalties n i_1 ... i_n specifies the penalty to be used after each of the lines in a paragraph, with the last value being repeated as often as needed if the paragraph has more then n lines.

Reference:

tex.clubpenalties


tex.clubpenalties : integer

An extension to \clubpenalty that allows different penalties to be added after each line. It takes a space separated list of numbers as value. If n is positive clubpenalties n i_1 ... i_n specifies the penalty to be used after each of the lines in a paragraph, with the last value being repeated as often as needed if the paragraph has more then n lines.

Reference:

tex.widowpenalties


tex.widowpenalties : integer

An extension to \widowpenalty that allows different penalties to be added after each line. It takes a space separated list of numbers as value. If n is positive widowpenalties n i_1 ... i_n specifies the penalty to be used after each of the lines in a paragraph, with the last value being repeated as often as needed if the paragraph has more then n lines. Lines are counted backwards from the last line in this case.

Reference:

tex.displaywidowpenalties


tex.displaywidowpenalties : integer

An extension to \widowpenalty that allows different penalties to be added after each line. It takes a space separated list of numbers as value. If n is positive displaywidowpenalties n i_1 ... i_n specifies the penalty to be used after each of the lines in a paragraph, with the last value being repeated as often as needed if the paragraph has more then n lines. Lines counted backwards from each display math within a paragraph.

Reference:

tex.prevgraf


tex.prevgraf : integer

\prevgraf: The number of lines in the paragraph last added to the vertical list.

Reference:

tex.spacefactor


tex.spacefactor : integer

\spacefactor: 1000 times the ratio by which the stretch (shrink) component of the interword glue should be multiplied (divided).

Reference:

tex.boxmaxdepth


tex.boxmaxdepth : integer

\boxmaxdepth: Maximum allowed depth of boxes. Default: \maxdimen.

Reference:

tex.delimitershortfall


tex.delimitershortfall : integer

\delimitershortfall: Size of the part of a delimited formula that is allowed to go uncovered by a delimiter. Default: 5pt.

Reference:

tex.displayindent


tex.displayindent : integer

\displayindent: Distance by which the box, in which the display is centred, is indented owing to hanging indentation.

Reference:

tex.displaywidth


tex.displaywidth : integer

\displaywidth: Width of the box in which the display is centred.

Reference:

tex.emergencystretch


tex.emergencystretch : integer

\emergencystretch (TeX3 only) Assumed extra stretchability in lines of a paragraph.

Reference:

tex.hangindent


tex.hangindent : integer

\hangindent: If positive, this indicates indentation from the left margin; if negative, this is the negative of the indentation from the right margin.

Reference:

tex.hfuzz


tex.hfuzz : integer

\hfuzz: Excess size that TeX tolerates before it considers a horizontal box overfull.

Reference:

tex.hoffset


tex.hoffset : integer

\hoffset: Distance by which the page is shifted right with respect to the reference point.

Reference:

tex.hsize


tex.hsize : integer

\hsize: Line width used for typesetting a paragraph. Default: 6.5in.

Reference:

tex.lineskiplimit


tex.lineskiplimit : integer

\lineskiplimit: Distance to be maintained between the bottom and top of neighbouring boxes on a vertical list. Default: 0pt.

Reference:

tex.mathsurround


tex.mathsurround : integer

\mathsurround: Kern amount placed before and after in-line formulas.

Reference:

tex.maxdepth


tex.maxdepth : integer

\maxdepth: Maximum depth of the page box. Default: 4pt.

Reference:

tex.nulldelimiterspace


tex.nulldelimiterspace : integer

\nulldelimiterspace: Width taken for empty delimiters. Default: 1.2pt.

Reference:

tex.overfullrule


tex.overfullrule : integer

\overfullrule: Width of the rule that is printed to indicate overfull horizontal boxes.

Reference:

tex.pagebottomoffset


tex.pagebottomoffset : integer

\pagebottomoffset: To set the bottom margin in non-TLT text.

Reference:

  • https://mirrors.aliyun.com/CTAN/systems/doc/aleph/News

tex.pageheight


tex.pageheight : integer

\pageheight: The page height of the PDF output (the screen, the paper, etc.).

Reference:

  • pdfTeX-Manual, page 25

tex.pageleftoffset


tex.pageleftoffset : integer

\pageleftoffset: To set the left margin in non-TLT text.

Reference:

  • https://mirrors.aliyun.com/CTAN/systems/doc/aleph/News

tex.pagerightoffset


tex.pagerightoffset : integer

\pagerightoffset: To set the right margin in non-TLT text.

Reference:

  • https://mirrors.aliyun.com/CTAN/systems/doc/aleph/News

tex.pagetopoffset


tex.pagetopoffset : integer

\pagetopoffset: To set the top margin in non-TLT text.

Reference:

  • https://mirrors.aliyun.com/CTAN/systems/doc/aleph/News

tex.pagewidth


tex.pagewidth : integer

\pagewidth: The page width of the PDF output (the screen, the paper, etc.).

Reference:

  • pdfTeX-Manual, page 25

tex.parindent


tex.parindent : integer

\parindent: Width of the indentation box added in front of a paragraph. Default: 20pt.

Reference:

tex.predisplaysize


tex.predisplaysize : integer

\predisplaysize: Effective width of the line preceding the display.

Reference:

tex.scriptspace


tex.scriptspace : integer

\scriptspace: Extra space after subscripts and superscripts. Default: 0.5pt.

Reference:

tex.splitmaxdepth


tex.splitmaxdepth : integer

\splitmaxdepth: Maximum depth of a box split off by a \vsplit operation. Default: \maxdimen.

Reference:

tex.vfuzz


tex.vfuzz : integer

\vfuzz: Excess size that TeX tolerates before it considers a vertical box overfull.

Reference:

tex.voffset


tex.voffset : integer

\voffset: Distance by which the page is shifted right/down with respect to the reference point.

Reference:

tex.vsize


tex.vsize : integer

\vsize: Height of the page box. Default: 8.9in.

Reference:

tex.prevdepth


tex.prevdepth : integer

\prevdepth: Depth of the last box added to a vertical list as it is perceived by TeX.

Reference:

tex.prevgraf


tex.prevgraf : integer

\prevgraf: The number of lines in the paragraph last added to the vertical list.

Reference:

tex.spacefactor


tex.spacefactor : integer

\spacefactor: 1000 times the ratio by which the stretch (shrink) component of the interword glue should be multiplied (divided).

Reference:

tex.pagedepth


tex.pagedepth : integer

\pagedepth: Depth of the current page.

Reference:

A read only dimension parameter. The result is always a number in scaled points.

tex.pagefilllstretch


tex.pagefilllstretch : integer

\pagefilllstretch: Accumulated third-order stretch of the current page.

Reference:

A read only dimension parameter. The result is always a number in scaled points.

tex.pagefillstretch


tex.pagefillstretch : integer

\pagefillstretch: Accumulated second-order stretch of the current page.

Reference:

A read only dimension parameter. The result is always a number in scaled points.

tex.pagefilstretch


tex.pagefilstretch : integer

\pagefilstretch: Accumulated first-order stretch of the current page.

Reference:

A read only dimension parameter. The result is always a number in scaled points.

tex.pagegoal


tex.pagegoal : integer

\pagegoal: Goal height of the page box. This starts at \vsize, and is diminished by heights of insertion items.

Reference:

A read only dimension parameter. The result is always a number in scaled points.

tex.pageshrink


tex.pageshrink : integer

\pageshrink: Accumulated shrink of the current page.

Reference:

* TeX by Topic, page 226

A read only dimension parameter. The result is always a number in scaled points.

tex.pagestretch


tex.pagestretch : integer

\pagestretch: Accumulated zeroth-order stretch of the current page.

Reference:

A read only dimension parameter. The result is always a number in scaled points.

tex.pagetotal


tex.pagetotal : integer

\pagetotal: Accumulated natural height of the current page.

Reference:

A read only dimension parameter. The result is always a number in scaled points.

tex.bodydir


tex.bodydir : DirectionSpecifier

The direction for vboxes, including the main body of text. Default: TLT.

Reference:

tex.mathdir


tex.mathdir : DirectionSpecifier

The direction for mathematics. Default: TLT.

Reference:

tex.pagedir


tex.pagedir : DirectionSpecifier

The direction for pages (\shipout). Default: TLT.

Reference:

tex.pardir


tex.pardir : DirectionSpecifier

The direction for paragraphs. Default: TLT.

Reference:

tex.textdir


tex.textdir : DirectionSpecifier

The direction for text and hboxes. Default: TLT.

Reference:

tex.abovedisplayshortskip


tex.abovedisplayshortskip : GlueSpecNode {
    width: integer,
    stretch: integer,
    stretch_order: integer,
    shrink: integer,
    shrink_order: integer,
}

\abovedisplayshortskip: Glue above a display if the line preceding the display was short. Default: 0pt plus 3pt.

Reference:

tex.abovedisplayskip


tex.abovedisplayskip : GlueSpecNode {
    width: integer,
    stretch: integer,
    stretch_order: integer,
    shrink: integer,
    shrink_order: integer,
}

\abovedisplayskip: Glue above a display. Default: 12pt plus 3pt minus 9pt.

Reference:

tex.baselineskip


tex.baselineskip : GlueSpecNode {
    width: integer,
    stretch: integer,
    stretch_order: integer,
    shrink: integer,
    shrink_order: integer,
}

\baselineskip: The ‘ideal’ baseline distance between neighbouring boxes on a vertical list. Default: 12pt.

Reference:

tex.belowdisplayshortskip


tex.belowdisplayshortskip : GlueSpecNode {
    width: integer,
    stretch: integer,
    stretch_order: integer,
    shrink: integer,
    shrink_order: integer,
}

\belowdisplayshortskip: Glue above/below a display if the line preceding the display was short. Default: 0pt plus 3pt and 7pt plus 3pt minus 4pt respectively.

Reference:

tex.belowdisplayskip


tex.belowdisplayskip : GlueSpecNode {
    width: integer,
    stretch: integer,
    stretch_order: integer,
    shrink: integer,
    shrink_order: integer,
}

\belowdisplayskip: Glue below a display. Default: 12pt plus 3pt minus 9pt.

Reference:

tex.leftskip


tex.leftskip : GlueSpecNode {
    width: integer,
    stretch: integer,
    stretch_order: integer,
    shrink: integer,
    shrink_order: integer,
}

\leftskip: Glue that is placed to the left of all lines of a paragraph.

Reference:

tex.lineskip


tex.lineskip : GlueSpecNode {
    width: integer,
    stretch: integer,
    stretch_order: integer,
    shrink: integer,
    shrink_order: integer,
}

\lineskip: Glue added if the distance between bottom and top of neighbouring boxes is less than \lineskiplimit. Default: 1pt.

Reference:

tex.parfillskip


tex.parfillskip : GlueSpecNode {
    width: integer,
    stretch: integer,
    stretch_order: integer,
    shrink: integer,
    shrink_order: integer,
}

\parfillskip: Glue that is placed between the last element of the paragraph and the line end. Default: 0pt plus 1fil.

Reference:

tex.parskip


tex.parskip : GlueSpecNode {
    width: integer,
    stretch: integer,
    stretch_order: integer,
    shrink: integer,
    shrink_order: integer,
}

\parskip: Amount of glue added to the surrounding vertical list when a paragraph starts. Default: 0pt plus 1pt.

Reference:

tex.rightskip


tex.rightskip : GlueSpecNode {
    width: integer,
    stretch: integer,
    stretch_order: integer,
    shrink: integer,
    shrink_order: integer,
}

\rightskip: Glue that is placed to the right of all lines of a paragraph.

Reference:

tex.spaceskip


tex.spaceskip : GlueSpecNode {
    width: integer,
    stretch: integer,
    stretch_order: integer,
    shrink: integer,
    shrink_order: integer,
}

\spaceskip: Interword glue if non-zero.

Reference:

tex.splittopskip


tex.splittopskip : GlueSpecNode {
    width: integer,
    stretch: integer,
    stretch_order: integer,
    shrink: integer,
    shrink_order: integer,
}

\splittopskip: Minimum distance between the top of what remains after a \vsplit operation, and the first item in that box. Default: 10pt.

Reference:

tex.tabskip


tex.tabskip : GlueSpecNode {
    width: integer,
    stretch: integer,
    stretch_order: integer,
    shrink: integer,
    shrink_order: integer,
}

\tabskip: Amount of glue in between columns (rows) of an \halign (\valign).

Reference:

tex.topskip


tex.topskip : GlueSpecNode {
    width: integer,
    stretch: integer,
    stretch_order: integer,
    shrink: integer,
    shrink_order: integer,
}

\topskip: Minimum distance between the top of the page box and the baseline of the first box on the page. Default: 10pt.

Reference:

tex.xspaceskip


tex.xspaceskip : GlueSpecNode {
    width: integer,
    stretch: integer,
    stretch_order: integer,
    shrink: integer,
    shrink_order: integer,
}

\xspaceskip: Interword glue if non-zero and \spacefactor ≥ 2000.

Reference:

tex.medmuskip


tex.medmuskip : string

\medmuskip: Medium amount of mu (math units) glue.

Reference:

tex.thickmuskip


tex.thickmuskip : string

\thickmuskip: Large amount of mu (math units) glue.

Reference:

tex.thinmuskip


tex.thinmuskip : string

\thinmuskip: Small amount of mu (math units) glue.

Reference:

tex.errhelp


tex.errhelp : string

\errhelp: Tokens that will be displayed if the user asks further help after an \errmessage.

A tokenlist parameters that accepts and returns a Lua string.

The Lua string is converted to and from a token list using \the \toks style expansion: all category codes are either space (10) or other (12).

Reference:

tex.everycr


tex.everycr : string

\everycr: Token list inserted after every \cr or non-redundant \crcr.

A tokenlist parameters that accepts and returns a Lua string.

The Lua string is converted to and from a token list using \the \toks style expansion: all category codes are either space (10) or other (12).

Reference:

* TeX by Topic, page 215

tex.everydisplay


tex.everydisplay : string

\everydisplay: Token list inserted at the start of a display.

A tokenlist parameters that accepts and returns a Lua string.

The Lua string is converted to and from a token list using \the \toks style expansion: all category codes are either space (10) or other (12).

Reference:

* TeX by Topic, page 210

tex.everyeof


tex.everyeof : string

\everyeof: The content of this token list is injected when a file ends.

A tokenlist parameters that accepts and returns a Lua string.

The Lua string is converted to and from a token list using \the \toks style expansion: all category codes are either space (10) or other (12).

Reference:

  • LuaMetaTeX-Manual, page 115

tex.everyhbox


tex.everyhbox : string

\everyhbox: Token list inserted at the start of a horizontal box.

A tokenlist parameters that accepts and returns a Lua string.

The Lua string is converted to and from a token list using \the \toks style expansion: all category codes are either space (10) or other (12).

Reference:

tex.everyjob


tex.everyjob : string

\everyjob: Token list that is inserted at the start of each new job.

A tokenlist parameters that accepts and returns a Lua string.

The Lua string is converted to and from a token list using \the \toks style expansion: all category codes are either space (10) or other (12).

Reference:

tex.everymath


tex.everymath : string

\everymath: Token list inserted at the start of non-display math.

A tokenlist parameters that accepts and returns a Lua string.

The Lua string is converted to and from a token list using \the \toks style expansion: all category codes are either space (10) or other (12).

Reference:

tex.everypar


tex.everypar : string

\everypar: Token list inserted in front of paragraph text.

A tokenlist parameters that accepts and returns a Lua string.

The Lua string is converted to and from a token list using \the \toks style expansion: all category codes are either space (10) or other (12).

Reference:

tex.everyvbox


tex.everyvbox : string

\everyvbox: Token list inserted at the start of a vertical box.

A tokenlist parameters that accepts and returns a Lua string.

The Lua string is converted to and from a token list using \the \toks style expansion: all category codes are either space (10) or other (12).

Reference:

tex.output


tex.output : string

\output: Token list with instructions for shipping out pages.

A tokenlist parameters that accepts and returns a Lua string.

The Lua string is converted to and from a token list using \the \toks style expansion: all category codes are either space (10) or other (12).

Reference:

tex.eTeXVersion


tex.eTeXVersion : string

tex.eTeXrevision


tex.eTeXrevision : string

tex.formatname


tex.formatname : string

tex.jobname


tex.jobname : string

tex.luatexbanner


tex.luatexbanner : string

tex.luatexrevision


tex.luatexrevision : string

tex.lastpenalty


tex.lastpenalty : integer

All “last item” commands are read-only and return a number.

tex.lastkern


tex.lastkern : integer

All “last item” commands are read-only and return a number.

tex.lastskip


tex.lastskip : integer

All “last item” commands are read-only and return a number.

tex.lastnodetype


tex.lastnodetype : integer

All “last item” commands are read-only and return a number.

tex.inputlineno


tex.inputlineno : integer

All “last item” commands are read-only and return a number.

tex.lastxpos


tex.lastxpos : integer

All “last item” commands are read-only and return a number.

tex.lastypos


tex.lastypos : integer

All “last item” commands are read-only and return a number.

tex.randomseed


tex.randomseed : integer

All “last item” commands are read-only and return a number.

tex.luatexversion


tex.luatexversion : integer

All “last item” commands are read-only and return a number.

tex.eTeXminorversion


tex.eTeXminorversion : integer

All “last item” commands are read-only and return a number.

tex.eTeXversion


tex.eTeXversion : integer

All “last item” commands are read-only and return a number.

tex.currentgrouplevel


tex.currentgrouplevel : integer

All “last item” commands are read-only and return a number.

tex.currentgrouptype


tex.currentgrouptype : integer

All “last item” commands are read-only and return a number.

tex.currentiflevel


tex.currentiflevel : integer

All “last item” commands are read-only and return a number.

tex.currentiftype


tex.currentiftype : integer

All “last item” commands are read-only and return a number.

tex.currentifbranch


tex.currentifbranch : integer

All “last item” commands are read-only and return a number.

tex.attribute


tex.attribute: table

The attribute registers accept and return Lua numbers.

see LuaTeX manual: 10.3.5 Accessing registers: set*, get* and is*

Reference:

tex.count


tex.count: table

The count registers accept and return Lua numbers.

see LuaTeX manual: 10.3.5 Accessing registers: set*, get* and is*

Reference:

tex.dimen


tex.dimen: table

The dimension registers accept Lua numbers (in scaled points) or strings (with an included absolute dimension; em and ex and px are forbidden). The result is always a number in scaled points.

see LuaTeX manual: 10.3.5 Accessing registers: set*, get* and is*

Reference:

tex.glue


tex.glue: table

The glue registers are just skip registers but instead of userdata are verbose.

see LuaTeX manual: 10.3.5 Accessing registers: set*, get* and is*

Reference:

tex.muglue


tex.muglue: table

see LuaTeX manual: 10.3.5 Accessing registers: set*, get* and is*

Reference:

tex.muskip


tex.muskip: table

see LuaTeX manual: 10.3.5 Accessing registers: set*, get* and is*

Reference:

tex.skip


tex.skip: table

The skip registers accept and return glue_spec userdata node objects.

see LuaTeX manual: 10.3.5 Accessing registers: set*, get* and is*

Reference:

tex.toks


tex.toks: table

The token registers accept and return Lua strings. Lua strings are converted to and from token lists using \the \toks style expansion: all category codes are either space (10) or other (12).

see LuaTeX manual: 10.3.5 Accessing registers: set*, get* and is*

Reference:

tex.lccode


tex.lccode : table<integer,integer>

The TeX's character code table lccode (lower case code) can be accessed and written to using a virtual subtable of the tex table.

for i = 0, 1024 do
 -- Exclude C0 and C1 control codes
  if i > 31 and not (i >= 127 and i <= 159) then
    print(i, utf8.char(i), tex.lccode[i], utf8.char(tex.lccode[i]))
  end
end

Output:

...
65  A   97  a
66  B   98  b
67  C   99  c
...
90  Z   122 z
...
97  a   97  a
98  b   98  b
99  c   99  c
...
122 z   122 z
...

Reference:

tex.uccode


tex.uccode : table<integer,integer>

TeX's character code table uccode (upper case code) can be accessed and written to using a virtual subtable of the tex table.

for i = 0, 1024 do
 -- Exclude C0 and C1 control codes
  if i > 31 and not (i >= 127 and i <= 159) then
    print(i, utf8.char(i), tex.uccode[i], utf8.char(tex.uccode[i]))
  end
end

Output:

...
65  A   65  A
66  B   66  B
67  C   67  C
...
90  Z   90  Z
...
97  a   65  A
98  b   66  B
99  c   67  C
...
122 z   90  Z
...

Reference:

tex.sfcode


tex.sfcode : table<integer,integer>

Each character in a font has a space factor code that is an integer between 0 and 32767. The code is used to adjust the space factor in a horizontal list. The uppercase letters A-Z have space factor code 999. Most other characters have code 1000 [Donald E. Knuth, The TeXbook, page 76]. However, Plain TeX makes )','', and ]' have space factor code0. Also, the\frenchspacingand\nonfrenchspacingmodes in Plain TeX work by changing the\sfcodefor:.,?,!,:,;, and,` [Donald E. Knuth, The TeXbook, 351].

TeX's character code table sfcode (space factor code) can be accessed and written to using a virtual subtable of the tex table.

for i = 0, 1024 do
  -- Exclude C0 and C1 control codes
  if i > 31 and not (i >= 127 and i <= 159) then
    print(i, utf8.char(i), tex.sfcode[i])
  end
end

Output:

32      1000
33  !   3000
34  "   1000
35  #   1000
36  $   1000
37  %   1000
38  &   1000
39  '   0
40  (   1000
41  )   0
42  *   1000
43  +   1000
44  ,   1250
45  -   1000
46  .   3000
47  /   1000
48  0   1000
49  1   1000
50  2   1000
51  3   1000
52  4   1000
53  5   1000
54  6   1000
55  7   1000
56  8   1000
57  9   1000
58  :   2000
59  ;   1500
60  <   1000
61  =   1000
62  >   1000
63  ?   3000
64  @   1000
65  A   999
...

Reference:

tex.catcode


tex.catcode : table<integer,integer>

A virtual subtable of the tex table called catcode (category code) can be used to access and write to TeX's character code table.

The category codes are indexed by the character code.

for i=33,126 do
  print(i, utf8.char(i), tex.catcode[i])
end

Output:

33  !   12
34  "   12
35  #   6
36  $   3
37  %   14
38  &   4
39  '   12
40  (   12
41  )   12
42  *   12
43  +   12
44  ,   12
45  -   12
46  .   12
47  /   12
48  0   12
49  1   12
50  2   12
51  3   12
52  4   12
53  5   12
54  6   12
55  7   12
56  8   12
57  9   12
58  :   12
59  ;   12
60  <   12
61  =   12
62  >   12
63  ?   12
64  @   12
65  A   11
66  B   11
67  C   11
68  D   11
69  E   11
70  F   11
71  G   11
72  H   11
73  I   11
74  J   11
75  K   11
76  L   11
77  M   11
78  N   11
79  O   11
80  P   11
81  Q   11
82  R   11
83  S   11
84  T   11
85  U   11
86  V   11
87  W   11
88  X   11
89  Y   11
90  Z   11
91  [   12
92  \   0
93  ]   12
94  ^   7
95  _   8
96  `   12
97  a   11
98  b   11
99  c   11
100 d   11
101 e   11
102 f   11
103 g   11
104 h   11
105 i   11
106 j   11
107 k   11
108 l   11
109 m   11
110 n   11
111 o   11
112 p   11
113 q   11
114 r   11
115 s   11
116 t   11
117 u   11
118 v   11
119 w   11
120 x   11
121 y   11
122 z   11
123 {   1
124 |   12
125 }   2
126 ~   13

Category codes:

  • 0: Escape character, normally \
  • 1: Begin grouping, normally {
  • 2: End grouping, normally }
  • 3: Math shift, normally $
  • 4: Alignment tab, normally &
  • 5: End of line, normally <return>
  • 6: Parameter, normally #
  • 7: Superscript, normally ^
  • 8: Subscript, normally _
  • 9: Ignored character, normally <null>
  • 10: Space, normally <space> and <tab>
  • 11: Letter, normally only contains the letters a,...,z and A,...,Z. These characters can be used in command names
  • 12: Other, normally everything else not listed in the other categories
  • 13: Active character, for example ~
  • 14: Comment character, normally %
  • 15: Invalid character, normally <delete>

  • Corresponding C source code: ltexlib.c#L3710

tex.mathcode


tex.mathcode : table<integer,MathCode>

The TeX's character code table mathcode can be accessed and written to using a virtual subtable of the tex table.

for i = 1, 128 do
  local mathcode = tex.mathcode[i]
  print(i, utf8.char(i), mathcode[1], mathcode[2], mathcode[3])
end

Output:

1       3   2   35
2       0   1   11
3       0   1   12
4       2   2   94
5       0   2   58
6       3   2   50
7       0   1   25
8       0   1   21
9       0   1   13
10      0   1   14
11      3   2   34
12      2   2   6
1       2   2   8
14      0   2   49
15      0   1   64
16      3   2   26
17      3   2   27
18      2   2   92
19      2   2   91
20      0   2   56
21      0   2   57
22      2   2   10
23      3   2   36
24      3   2   32
25      3   2   33
26  �   8   0   0
27          2   5
28      3   2   20
29      3   2   21
30      3   2   17
31      2   2   95
32      8   0   0
33  !   5   0   33
34  "   0   0   34
35  #   0   0   35
36  $   0   0   36
37  %   0   0   37
38  &   0   0   38
39  '   8   0   0
40  (   4   0   40
41  )   5   0   41
42  *   2   2   3
43  +   2   0   43
44  ,   6   1   59
45  -   2   2   0
46  .   0   1   58
47  /   0   1   61
48  0   7   0   48
49  1   7   0   49
50  2   7   0   50
51  3   7   0   51
52  4   7   0   52
53  5   7   0   53
54  6   7   0   54
55  7   7   0   55
56  8   7   0   56
57  9   7   0   57
58  :   3   0   58
59  ;   6   0   59
60  <   3   1   60
61  =   3   0   61
62  >   3   1   62
63  ?   5   0   63
64  @   0   0   64
65  A   7   1   65
66  B   7   1   66
67  C   7   1   67
68  D   7   1   68
69  E   7   1   69
70  F   7   1   70
71  G   7   1   71
72  H   7   1   72
73  I   7   1   73
74  J   7   1   74
75  K   7   1   75
76  L   7   1   76
77  M   7   1   77
78  N   7   1   78
79  O   7   1   79
80  P   7   1   80
81  Q   7   1   81
82  R   7   1   82
83  S   7   1   83
84  T   7   1   84
85  U   7   1   85
86  V   7   1   86
87  W   7   1   87
88  X   7   1   88
89  Y   7   1   89
90  Z   7   1   90
91  [   4   0   91
92  \   0   2   110
93  ]   5   0   93
94  ^   0   0   94
95  _   8   0   0
96  `   0   0   96
97  a   7   1   97
98  b   7   1   98
99  c   7   1   99
100 d   7   1   100
101 e   7   1   101
102 f   7   1   102
103 g   7   1   103
104 h   7   1   104
105 i   7   1   105
106 j   7   1   106
107 k   7   1   107
108 l   7   1   108
109 m   7   1   109
110 n   7   1   110
111 o   7   1   111
112 p   7   1   112
113 q   7   1   113
114 r   7   1   114
115 s   7   1   115
116 t   7   1   116
117 u   7   1   117
118 v   7   1   118
119 w   7   1   119
120 x   7   1   120
121 y   7   1   121
122 z   7   1   122
123 {   4   2   102
124 |   0   2   106
125 }   5   2   103
126 ~   0   0   126
127     1   2   115
128     0   0   128

In math mode, the math atoms require more structure. Each symbol originates from a different font and receives different spacing based on its class (operator, binary infix, relation, etc.). Following the typical style of the 1970s, these properties are compactly packed into bit fields within a single integer called a mathcode. The mathcode is usually expressed in hexadecimal so that the fields can easily be pulled apart. The mathcode of + in plain TeX is set as:

\mathcode`\+="202B

This means it is class 2 (binary infix) and fam0 (the Roman font). The character hex is 2B, which is the decimal 43, the character code for + in the Roman font encoding.

The mathcode section in the plain.tex format file:

\mathcode`\^^?="1273 % \smallint
% INITEX sets up \mathcode x=x, for x=0..255, except that
% \mathcode x=x+"7100, for x = `A to `Z and `a to `z;
% \mathcode x=x+"7000, for x = `0 to `9.
% The following changes define internal codes as recommended
% in Appendix C of The TeXbook:
\mathcode`\^^@="2201 % \cdot
\mathcode`\^^A="3223 % \downarrow
\mathcode`\^^B="010B % \alpha
\mathcode`\^^C="010C % \beta
\mathcode`\^^D="225E % \land
\mathcode`\^^E="023A % \lnot
\mathcode`\^^F="3232 % \in
\mathcode`\^^G="0119 % \pi
\mathcode`\^^H="0115 % \lambda
\mathcode`\^^I="010D % \gamma
\mathcode`\^^J="010E % \delta
\mathcode`\^^K="3222 % \uparrow
\mathcode`\^^L="2206 % \pm
\mathcode`\^^M="2208 % \oplus
\mathcode`\^^N="0231 % \infty
\mathcode`\^^O="0140 % \partial
\mathcode`\^^P="321A % \subset
\mathcode`\^^Q="321B % \supset
\mathcode`\^^R="225C % \cap
\mathcode`\^^S="225B % \cup
\mathcode`\^^T="0238 % \forall
\mathcode`\^^U="0239 % \exists
\mathcode`\^^V="220A % \otimes
\mathcode`\^^W="3224 % \leftrightarrow
\mathcode`\^^X="3220 % \leftarrow
\mathcode`\^^Y="3221 % \rightarrow
\mathcode`\^^Z="8000 % \ne
\mathcode`\^^[="2205 % \diamond
\mathcode`\^^\="3214 % \le
\mathcode`\^^]="3215 % \ge
\mathcode`\^^^="3211 % \equiv
\mathcode`\^^_="225F % \lor
\mathcode`\ ="8000 % \space
\mathcode`\!="5021
\mathcode`\'="8000 % ^\prime
\mathcode`\(="4028
\mathcode`\)="5029
\mathcode`\*="2203 % \ast
\mathcode`\+="202B
\mathcode`\,="613B
\mathcode`\-="2200
\mathcode`\.="013A
\mathcode`\/="013D
\mathcode`\:="303A
\mathcode`\;="603B
\mathcode`\<="313C
\mathcode`\=="303D
\mathcode`\>="313E
\mathcode`\?="503F
\mathcode`\[="405B
\mathcode`\\="026E % \backslash
\mathcode`\]="505D
\mathcode`\_="8000 % \_
\mathcode`\{="4266
\mathcode`\|="026A
\mathcode`\}="5267

Reference:

tex.delcode


tex.delcode : table<integer,DelCode>
for i=1,128 do
  local delcode = tex.delcode[i]
  print(i, utf8.char(i), delcode[1], delcode[2], delcode[3], delcode[4])
end

Output:

1       -1  0   0   0
...
40  (   0   40  3   0
41  )   0   41  3   1
...
47  /   0   47  3   14
...
60  <   2   104 3   10
61  =   -1  0   0   0
62  >   2   105 3   11
...
91  [   0   91  3   2
92  \   2   110 3   15
93  ]   0   93  3   3
...
124 |   2   106 3   12
...

The delcode section in the plain.tex format file:

% Finally, INITEX sets all \delcode values to -1, except \delcode`.=0
\delcode`\(="028300
\delcode`\)="029301
\delcode`\[="05B302
\delcode`\]="05D303
\delcode`\<="26830A
\delcode`\>="26930B
\delcode`\/="02F30E
\delcode`\|="26A30C
\delcode`\\="26E30F
% N.B. { and } should NOT get delcodes; otherwise parameter grouping fails!

Reference:

tex.box


tex.box : table<integer,Node>

Reference:

tex.lists


tex.lists: table

The virtual table tex.lists contains the set of internal registers that keep track of building page lists.

Reference:

😱 Types incomplete or incorrect? 🙏 Please contribute!

tex.nest


tex.nest : table<integer,Nest>

The virtual table nest contains the currently active semantic nesting state. It has two main parts: a zero-based array of userdata for the semantic nest itself, and the numerical value ptr, which gives the highest available index. Neither the array items in nest[] nor ptr can be assigned to (as this would confuse the typesetting engine beyond repair), but you can assign to the individual values inside the array items, e.g. tex.nest[tex.nest.ptr].prevdepth.

tex.nest[tex.nest.ptr] is the current nest state, nest[0] the outermost (main vertical list) level.

Reference: