Skip to main content

CLI reference

The binary is matex-cli. From the repository root, cargo mx is an alias for cargo run -q -p matex-cli --.

cargo mx <command> [options] <input>
Usage: matex-cli <COMMAND>

Commands:
collect Resolve, expand, number, and write one store per citable kind
compile Resolve, expand, paginate and write the static dialect
render Draw a static file as a PDF
check Parse, resolve and number without writing anything

collect​

Usage: matex-cli collect [OPTIONS] <INPUT>

Arguments:
<INPUT> Dynamic source to collect

Options:
-c, --config <CONFIG> Project configuration to use instead of the nearest one

Resolves, expands and numbers the document, then writes one store per citable kind into generated.dir. Prints a line per store and a count.

cargo mx collect paper.mtx
wrote paper/gen/eq.g.mtx
wrote paper/gen/fig.g.mtx
wrote paper/gen/head.g.mtx
wrote paper/gen/tab.g.mtx
wrote paper/gen/refs.g.mtx
collected 5 store(s)

compile​

Usage: matex-cli compile [OPTIONS] <INPUT>

Arguments:
<INPUT> Dynamic source to compile

Options:
-o, --output <OUTPUT> Where to write the static file (default: beside the input)
-c, --config <CONFIG> Project configuration to use instead of the nearest one

Resolves, expands, paginates and emits one static file. Without -o, the file is <stem>.static.mtx beside the input.

cargo mx compile paper.mtx -o build/paper.static.mtx
wrote build/paper.static.mtx (2 page(s))

The page count is the number of pages compile decided. render must produce the same count; it never expands a page.

render​

Usage: matex-cli render [OPTIONS] <INPUT>

Arguments:
<INPUT> Static source to render

Options:
-o, --output <OUTPUT> Where to write the PDF (default: beside the input)
-c, --config <CONFIG> Project configuration to use instead of the nearest one

Draws a static file as a PDF. Without -o, the output is the static file's name with .static.mtx replaced by .pdf.

cargo mx render build/paper.static.mtx -o build/paper.pdf
wrote build/paper.pdf (2 page(s))

A dynamic input is refused:

error[not-static]: `render` accepts static source only; run `compile` first

The config still matters at render time: page geometry, fonts and pagination settings are read from it. Render and compile must therefore see the same config, or the page count will differ.

check​

Usage: matex-cli check [OPTIONS] <INPUT>

Arguments:
<INPUT> Source to check

Options:
-c, --config <CONFIG> Project configuration to use instead of the nearest one

Parses, resolves, expands and numbers without writing anything. It treats generated stores as provisional, so it works before a collect.

cargo mx check paper.mtx
ok

or

3 warning(s)

Errors are printed and exit non-zero.

Options​

Every command accepts -c/--config <path> to use a specific project file instead of the nearest matex.config.json or config.json.

compile and render accept -o/--output <path>. collect and check write nothing, so they have no output option.

Diagnostics​

A diagnostic names a stable code and, where possible, a span:

warning[loose-line]: a justified line needs word gaps wider than the engine allows
--> paper.mtx:88:17
= help: shorten the measure or add the words to the hyphenation list

Errors stop the command with exit code 1. Warnings are printed and the command succeeds. The diagnostics index lists the codes.

Exit codes​

CodeMeaning
0Success, with or without warnings
1At least one error

A full build​

cargo mx collect paper.mtx
cargo mx compile paper.mtx -o build/paper.static.mtx
cargo mx render build/paper.static.mtx -o build/paper.pdf

collect is required whenever the document prints a number: a heading label, a caption, a citation. A document with none of those can go straight to compile.