ConTeXt

Run which context on TeX Live 2024, then ls -l the path it prints, and you get context -> luametatex. The command that invokes ConTeXt turns out to be luametatex, the engine the ConTeXt developers built for themselves. That one line sums up the whole undertaking: ConTeXt is not a package you add to LaTeX but a document-preparation system you use instead of LaTeX, and it carries its own engine underneath. This page works through its \setup...-centred syntax, the three generations MkII / MkIV / LMTX, why the very first run is slow, and — reading the actual logs — who should genuinely consider it.

ConTeXt is not a LaTeX package

There is no such command as \usepackage{context}, and writing \usepackage inside a ConTeXt document stops the run with Undefined control sequence. LaTeX and ConTeXt are sibling formats on the same TeX foundation, and neither understands a word of the other. The file still ends in .tex, but what processes it is the context command, not pdflatex and not lualatex. Collaborators and CI pipelines regularly reach for a LaTeX command and fail, so one line in the README — “build this document with context main.tex” — pays for itself.

terminal
$ cat up.tex
\usepackage{amsmath}
\starttext
Hi
\stoptext

$ context up.tex
tex error       > tex error on line 1 in file ./up.tex: Undefined control sequence
mtx-context     | fatal error: return code: 1

ConTeXt has been written by Hans Hagen of the Netherlands and his company PRAGMA ADE (Advanced Document Engineering). The name comes from “text with TeX” — con-tex-t. It grew not as an academic by-product but as a production tool for the firm’s own commissioned work, and that shapes its character: it suits jobs where you design the page yourself, such as teaching material, manuals, and catalogues. Its age is visible in the sources too — the header of cont-nl.mkxl as shipped in TeX Live 2024 still reads version=1997.08.19, author=Hans Hagen, copyright={PRAGMA ADE & ConTeXt Development Team}.

ConTeXt versus LaTeX: \setup... and \start…/\stop…

The biggest difference is that all appearance settings collapse into a single family of commands. In LaTeX, margins come from geometry, colour from xcolor, footnote styling from something else again, each with its own syntax. In ConTeXt the paper is \setuppapersize, the body font \setupbodyfont, the paragraph spacing \setupwhitespaceeverything begins with \setup and everything takes key=value. Is there a lot of it? Genuinely: scanning the LMTX sources in TeX Live 2024 (tex/context/base/mkxl) turns up 498 distinct commands starting with \setup. The design asks you to learn the naming rule rather than the names.

The markup is regular too. Where LaTeX writes an environment as \begin{env}…\end{env}, ConTeXt uses matched \start… and \stop… pairs: the body is \starttext … \stoptext, a section is \startsection … \stopsection, a displayed equation is \startformula … \stopformula. And there is no mandatory declaration corresponding to LaTeX’s \documentclass. You can open the file with \setuppapersize[A4] and go straight into the text. The LaTeX habit of picking a class first and then hunting for packages that suit it simply disappears.

latex
% first-context.tex -- compile with: context first-context.tex
\setuppapersize[A4]
\setupbodyfont[12pt]

\starttext
\startsection[title=Introduction]
  Hello, \ConTeXt!
  \startformula
    E = mc^2
  \stopformula
\stopsection
\stoptext
LaTeXConTeXtWhat you want
\documentclass{article}(nothing)no class declaration is required; appearance goes into \setup...
\begin{document}\starttextbegin the body; it ends with \stoptext
\section{...}\startsection[title=...]a section; \section alone also exists for the heading
\[ ... \]\startformula … \stopformulaa displayed equation
\usepackage{geometry}\setuppapersize and the rest of \setup...paper, margins, page design; there is no package to add
pdflatexcontextthe processing command; a LaTeX command will not do, even for a .tex file

What LMTX is: the MkII, MkIV, and LMTX generations

LMTX is the current generation. ConTeXt splits into three lines by the generation of engine underneath: MkII, the oldest, runs on pdfTeX (and XeTeX); MkIV is the Lua-era rewrite running on LuaTeX; and LMTX — internally MkXL — runs on LuaMetaTeX. Running context --version on TeX Live 2024 reports both context.mkiv and context.mkxl at the same date, so MkIV is indeed still shipped. But the context command is itself a symlink to luametatex, so an unqualified run gives you LMTX. The first line of the run log says so plainly: ConTeXt ver: 2024.02.27 09:18 LMTX.

terminal
$ ls -l $(which context)
context -> luametatex

$ luametatex --version
This is LuaMetaTeX, Version 2.11.02
Functionality : level 20240226

$ context --version
mtx-context     | ConTeXt Process Management 1.06
mtx-context     | main context file: .../tex/context/base/mkiv/context.mkiv
mtx-context     | current version: 2024.02.27 09:18
mtx-context     | main context file: .../tex/context/base/mkxl/context.mkxl
mtx-context     | current version: 2024.02.27 09:18

The key piece is LuaMetaTeX. Hans Hagen and the ConTeXt developers rebuilt it as a lean engine made for ConTeXt and successor to LuaTeX, and the bold part is not what was added but what was taken out: the PDF backend, font handling, and many primitives were deliberately removed from LuaTeX and reimplemented in Lua on the ConTeXt side. The result depends on no external libraries, needs no elaborate build ecosystem, and ports across operating systems easily. The LMTX log does print used backend: pdf — but that PDF is written by the Lua-side implementation. One thing should be said honestly here: ConTeXt is effectively the only thing that puts LuaMetaTeX to serious use. It is nearer the truth to think of it as part of ConTeXt than as a general-purpose engine.

Where the older generations survive is also visible in the configuration. TeX Live’s fmtutil.cnf contains two lines, cont-en pdftex - -8bit *cont-en.mkii and cont-en xetex - -8bit *cont-en.mkii, which are the format definitions for MkII. So MkII can still be dumped on pdfTeX and on XeTeX. LMTX does not use that mechanism at all; as described below, it builds its format into a cache of its own. If you are starting fresh, use LMTX without hesitation, and treat MkII and MkIV as things that remain because old documents remain.

Why only the first run is slow: mtxrun --generate and the cache

ConTeXt builds its format into a cache by itself, so only the first run costs you time. Measured from a clean state, the first run reports total runtime: 3.559 seconds and the second run on the same file 0.248 seconds — a factor of fourteen. What appeared in the cache during that first run is a roughly 19 MB cont-en.fmt; afterwards it is only read. One step earlier still comes the file database, built by mtxrun --generate. Invoke context --version in an environment where that has not been done and you get an error that looks baffling at first sight.

terminal
# before the file database exists
$ context --version
mtxrun          | unknown script 'mtx-context.lua' or 'mtx-mtx-context.lua'

$ mtxrun --generate            # builds the file database
mtxrun          | elapsed lua time: 3.034 seconds

$ context first.tex            # run 1: also dumps ~19 MB cont-en.fmt
system          | total runtime: 3.559 seconds

$ context first.tex            # run 2: format is cached
system          | total runtime: 0.248 seconds

The error does not mean that mtx-context.lua is missing; it means the file list has not been built yet, so it cannot be found. One run of mtxrun --generate clears it. Once past that, ConTeXt has another habit that surprises LaTeX users: it reruns itself as many times as cross-references and the table of contents require. Type context toc.tex once on a document with a table of contents and the log records two internal invocations, --c:currentrun=1 and --c:currentrun=2, alongside the ceiling --c:maxnofruns=9. What in LaTeX means remembering to compile twice, or reaching for latexmk, is default behaviour here. The auxiliary file is called .tuc rather than .aux, too.

MetaPost runs inside the same compile

One of ConTeXt’s headline features is that the drawing language MetaPost is built into the system and produces figures on the spot, without launching an external program. Write \startMPcode … \stopMPcode inside the document and the figure is generated during the compile. The log shows This is MPLIB for LuaMetaTeX, version 3.14, running in double mode next to loading metafun for lmtx — evidence that MetaPost lives inside the engine as the library MPlib, which Taco Hoekwater and Hans Hagen split out of MetaPost in 2007. Because MetaPost inherits its way of describing shapes from Knuth’s METAFONT, lines and curves can be stated as constraints rather than coordinates.

latex
\starttext
\startMPcode
  fill fullcircle scaled 3cm withcolor .6red;
  draw fullcircle scaled 3cm withpen pencircle scaled 1mm;
\stopMPcode
\stoptext
% one run of `context` produces the PDF; no external MetaPost binary is called

That is a bigger difference than it looks. Because the figure is part of the same run rather than a separate process, it can read the dimensions of the text: a figure exactly the width of the type block, ornaments keyed to the section number, rules and backgrounds generated from data — all without a post-processing step. This is why ConTeXt users draw even rules and page backgrounds in MetaPost. It is not quite the TikZ habit from LaTeX; here MetaPost is used as a tool for drawing the page elements themselves.

Who should actually choose ConTeXt — an honest answer

The answer is: people who own the page design. Teaching material, manuals, catalogues, in-house publications, typesetting generated in bulk from XML or a database — wherever the layout decisions are yours to make, ConTeXt’s integrated model, with settings gathered into \setup..., pays off. Conversely it does not suit a paper or thesis whose destination prescribes a LaTeX template. Conference templates, classes like revtex, your co-authors’ installations, the processing pipeline at arXiv: all of them assume LaTeX, and nothing you gain from porting repays the effort. The line here is not about which system is better but about who holds the decision over the page.

  • A good fit: booklets, teaching material, catalogues, manuals — anything whose page design is yours. Settings collect in \setup..., so changing the design later means looking in one place.
  • A good fit: typesetting generated automatically from XML or data. ConTeXt can read and set XML directly, and the processing can be written in Lua.
  • A good fit: documents where figures and prose should live in one source. MetaPost is inside the same run, so there is no post-processing step and no image files to manage.
  • A good fit: slides. TeX Live 2024 ships more than twenty presentation styles — s-present-boring, s-present-dark, s-present-punk and others — and MetaPost can build the ornamentation.
  • A poor fit: papers and theses whose destination prescribes a LaTeX class. Following the template is faster and safer.
  • A poor fit: manuscripts whose co-authors use only LaTeX. There is far less written about ConTeXt than about LaTeX, and fewer people to ask when you get stuck.

The documentation gathers differently, too. LaTeX knowledge is scattered across books, Q&A sites, and package manuals worldwide, whereas ConTeXt is comparatively concentrated in the official wiki, contextgarden, and primers such as ConTeXt: an excursion, with an annual ConTeXt Meeting that brings developers and users face to face. Less material, but a clearer centre — that is close to the truth. One more characteristic detail: the system offers interfaces in which the command names themselves are translated. Alongside English, the LMTX sources in TeX Live 2024 carry format definitions for Czech, German, French, Italian, Dutch, Persian, Romanian, and British English. That the Dutch cont-nl is still there reads like a monument to where the system was born.

Finally, how to begin in practice. ConTeXt ships with TeX Live, so on an ordinary installation context first.tex is all you need. If you want to track the newest releases, the usual route is the group’s own LMTX distribution — formerly called ConTeXt Standalone — a light, ConTeXt-only bundle that updates frequently. The one habit worth dropping when you start writing is the LaTeX reflex of hunting for a package whenever something is missing. Build the skeleton first with \starttext, \startsection, and \startitemize, and gather margins and fonts into \setup... commands at the top. Add styling as the chapter grows: the settings stay out of the prose, and when you want to change the page design there is exactly one place to look.