A Toy TeX

TeX compilers have two modes:

Normal mode

luahbtex --fmt=lualatex XXX.tex

Every TeX dialect has a format file. --fmt=XXX will load XXX.fmt. If --fmt is missing in command line options, it will search luahbtex.fmt, which luahbtex is the program name. It means:

cp /usr/bin/luahbtex /usr/bin/luatex
luatex XXX.tex

is equal to:

luahbtex --fmt=luatex XXX.tex

except texlua and texluac.

Initial mode

luahbtex --ini XXX.ini

It will not load any TeX formats and generate XXX.fmt. XXX.ini is a TeX file written in TeX primitives without any predefined macros by TeX dialects. Different from XXX.tex, XXX.ini must end with \dump.

This example is a toy TeX dialect. It only can draw lines, because we don't add any fonts.

Lua mode

LuaTeX has an extra mode:

luahbtex --luaonly XXX.lua
luahbtex --luaconly XXX.lua

They are equal to:

texlua XXX.lua
texluac XXX.lua

So you can use lua to write TeX tools, like using lua to write Neovim plugins.

generated by LDoc 1.5.0 Last updated 2025-08-16 20:10:55