Name
       tenkana - a spider that jumps from the checkpoints of your TeX document

Synopsis
       tenkana [tenkana options] TeX-command [TeX options] file
       tenkana [tenkana options] -q file
       tenkana [tenkana options] program arguments

Description
       tenkana runs a TeX command, such as: lualatex thesis, the way env(1) and
       time(1) run theirs, but makes repeated builds faster. While TeX runs,
       tenkana keeps frozen copies (snapshots) of the running engine: one just
       before \begin{document} and one before each \include. After an edit,
       tenkana continues from the last snapshot before the change, so the
       preamble, its packages and fonts, and all unchanged chapters before the
       edit are not processed again.

           tenkana lualatex thesis
           tenkana pdflatex -synctex=1 thesis
           tenkana pdflatex-dev '\nonstopmode\input paper.ltx'
           tenkana -q thesis
           tenkana latexmk -pdf thesis

       The TeX command may be any command that runs pdfTeX, LuaTeX (LuaHBTeX,
       LuaJITTeX) or XeTeX: pdflatex, lualatex, xelatex, pdflatex-dev and so on.
       tenkana finds the engine from the program the command finally runs. TeX
       runs in the current folder. TeX’s first line, what follows its options,
       is usually the file name; if it is TeX code, tenkana takes the file of
       the first \input as the main file, and without an \input it runs the
       command as it is, without snapshots. The file is looked for as TeX does:
       in the current folder, then on TeX’s search path (see kpsewhich(1)). If
       TeX would not find it either, tenkana runs the command as it is and TeX
       reports the problem.

       The engine and the document are not modified, and no root access is
       needed. tenkana runs your command as you typed it, and adds only
       -recorder right after the command name: it needs the list of files TeX
       reads, which TeX writes to job.fls. XeTeX also gets -no-pdf, followed by
       one xdvipdfmx(1) run at the end, as XeTeX would run it (xdvipdfmx -q -E);
       with your own -no-pdf, tenkana leaves the .xdv file as it is. TeX’s
       questions (after an error, or from \typein) appear on your terminal and
       take your answers, and Ctrl-C reaches TeX, also when a build resumes from
       a snapshot. Snapshots are made with fork(2) by a small library that
       tenkana loads into the engine with LD_PRELOAD. They live in memory, as
       ordinary processes, and survive between runs of tenkana (see Memory). The
       preamble snapshot is also saved on disk, compressed, so it survives a
       reboot (see Snapshots on disk).

       TeX’s own terminal output is shown unchanged. tenkana’s messages follow
       it. Each is one line and starts with tenkana: prefix; error messages go
       to standard error.

References
       LaTeX reads the previous run’s .aux (and .toc, ...) at \begin{document},
       so after one plain run a new or moved label shows as ?? or with an old
       number. tenkana reruns from the preamble snapshot until the .aux, .toc
       and similar files stop changing (at most 4 passes), like latexmk(1), so
       every build ends with cross-references, citations and the table of
       contents up to date. The reruns are fast: the preamble is not processed
       again.

Other programs
       A command that does not run pdfTeX, LuaTeX or XeTeX is another program,
       such as arara(1), latexmk(1), l3build(1) or make(1). tenkana runs it as
       it always runs, with another library (built from preload/tenkanawatch.rs)
       loaded into it and everything it starts. Whenever one of them starts a
       TeX engine, that TeX command runs through tenkana instead, as a single
       run (as with --single). So the program’s own rules decide how many runs
       there are, and its checks of the .aux and .log work as they always do;
       only the runs are faster. Everything other than TeX runs untouched, and a
       TeX command that tenkana cannot handle (one with -fmt, as in l3build’s
       tests) runs as it is. At the end tenkana says how many TeX runs there
       were and how each went; -v also shows each run’s details. tenkana’s exit
       status is the program’s.

       tenkana adds -recorder, so these runs write a .fls file even if the
       program does not ask for one. The memory statistics at the end of the
       .log differ slightly from a plain run’s, because of tenkana’s hooks. A
       program that starts TeX by other means than the C library’s exec
       functions and posix_spawn(3) runs its TeX without tenkana.

Options
       tenkana’s options come before the TeX command; the first word that is not
       one of them starts it, and -- ends them explicitly.

       -q, --quick
              Only the file is given, and the default engine is used:

              tenkana -q thesis is tenkana lualatex thesis (or the command in
              TENKANA_ENGINE).

       -s, --single
              One TeX run: no reruns for the references, as TeX alone does. Each
              TeX run of another program is one (see Other programs).

       -v, --verbose
              Also show tenkana’s details: passes, changed files, snapshots and
              their memory.

       --silent
              Show only TeX’s output and tenkana’s error messages.

       --no-snapshots
              Build with plain runs instead of snapshots.

       -f, --force
              Stop this document’s snapshots, discard tenkana’s cached state and
              build from scratch.

       -F, --final, -d, --draft
              Ignored: since version 0.3.0 every build updates the references
              (see References). They are accepted so that older uses still work.

       --clean
              Stop a document’s snapshots, delete its cache (see Files), and
              exit. Name the document as for a build (tenkana --clean lualatex
              thesis) or just by its name (tenkana --clean thesis). The file
              itself need not exist any more.

       --clean-all
              Stop the snapshots of every document and delete every document’s
              cache, and exit. tenkana’s libraries stay. It lists the caches
              with the space each takes and asks first [y/n]; without a terminal
              to ask on, it needs --yes. A document’s cache is never deleted on
              its own, so this is the way to get the space back from documents
              you no longer build.

       --uninstall
              Remove this tenkana, its man page next to it, its cache and
              /tmp/tenkana-uid, after stopping your snapshots, and exit. It
              lists what it removes and asks first [y/n]; without a terminal to
              ask on, it needs --yes. A tenkana that belongs to TeX Live is not
              removed. For removing that, use: tlmgr remove tenkana. This option
              has no one-letter form.

       --yes
              With --uninstall or --clean-all: remove without asking.

       -V, --version
              Print the version and exit.

       -h, --help
              Print a short help text and exit.

       The one-letter options -q, -s and -v, and the ignored -F and -d, can be
       combined in any order: tenkana -qv thesis is tenkana -q -v thesis. -f, -h
       and -V stand alone. For an unknown or wrongly combined option, tenkana
       suggests the nearest right one.

       TeX’s options go to TeX unchanged, e.g.: -shell-escape, -synctex=1,
       -interaction=batchmode, -file-line-error or -jobname=name. Not supported
       yet, and refused with a message: -ini, -fmt (and &format),
       -output-directory, -aux-directory, -output-format and -output-driver. A
       change of the TeX command makes the next build a full run.

       With SyncTeX on, the snapshot library keeps TeX’s job.synctex(busy) file
       in tenkana’s cache, where the snapshots can hold it, and copies it to
       job.synctex.gz at the end instead of renaming it, so snapshots work as
       usual.

Snapshots on disk
       After a build that made a new preamble snapshot, a copy of that snapshot
       writes itself to tenkana’s cache (see Files) in the background,
       compressed with zstd (zlib if zstd is missing), unless it would be larger
       than TENKANA_SAVE_LIMIT. Only memory that differs from the files on disk
       is stored, and empty pages are skipped; typical sizes are 7–15MB. The
       default limit is 20MB.

       When the snapshots in memory have ended, tenkana starts the engine
       exactly as before (same command, environment and memory layout;
       address-space randomisation is switched off for the engine) and the
       snapshot library restores the image into it before the engine’s main()
       runs, typically in 0.1–0.3s. The chapter snapshots are then made again in
       memory during that build.

       An image is used only on the same kernel and with the same engine,
       libraries and font files as when it was saved; otherwise tenkana makes a
       full run and says why. Images contain the engine’s memory, including its
       environment variables; tenkana’s cache is readable only by you.

What tenkana watches
       Every file the engine reads (recorded with -recorder), assigned to the
       part of the run that first read it: the preamble, the body of the main
       file, or the stretch after one of the pauses before an \include. The
       parts follow what TeX actually did, so \includeonly, conditionals and
       \include inside an \input file are handled correctly. A change to a file
       read in the preamble needs a full run; a change to the main file’s body
       resumes from the preamble snapshot; any other change resumes from the
       snapshot just before the part that first read the file.

       tenkana also records every file TeX looked for but did not find in the
       document’s folder: a chapter not written yet, an image, a .bbl before
       biber(1) has run, an .ind before makeindex(1). When such a file appears,
       the next build continues from the part of the document that looked for
       it.

       In addition, files that other programs generate for TeX to read are
       watched by name, even if TeX has not looked for them yet:

           .bbl      biber, BibTeX
           .ind      makeindex, xindy
           .gls      makeglossaries (main glossary)
           .acr      makeglossaries (acronyms)
           .nls      makeindex for nomencl
           .glstex   bib2gls (read in the preamble: a full run)

       Glossary types declared in the .aux file are added automatically. Files
       are matched as job.ext, job-*.ext and chapter.ext. More extensions can be
       added with TENKANA_WATCH.

       Changes to the .aux, .toc and similar files written by TeX itself are not
       watched: tenkana reruns until they stop changing (see References).

Environment
       TENKANA_ENGINE
              The command for -q instead of lualatex; it may have options, as in
              TENKANA_ENGINE="pdflatex -shell-escape".

       TENKANA_SILENT
              If set, as --silent.

       TENKANA_TTL
              Seconds the snapshots live after the document’s last build
              (default 28800, i.e. 8 hours).

       TENKANA_SAVE_LIMIT
              Largest preamble snapshot to keep on disk, in MB (default 20). 0
              turns saving off.

       TENKANA_WATCH
              Additional generated-file extensions to watch, separated by commas
              or spaces, e.g. TENKANA_WATCH=xyz,abc. They are assumed to be read
              in the preamble, so a change causes a full run.

       TENKANA_DEBUG
              If set, explain why a snapshot could not be used.

       TENKANA_SHIM
              Use this snapshot library instead of the built-in one.

Files
       ~/.cache/tenkana/
              tenkana’s cache ($XDG_CACHE_HOME/tenkana/ if that is set),
              readable only by you: tenkana’s two libraries, written there from
              tenkana itself on first use (in /tmp/tenkana-uid/ instead if the
              cache’s path contains a space or a colon, which LD_PRELOAD cannot
              handle), and one folder per document under docs/, named after the
              job and a hash of the document’s location. One build of a document
              runs at a time; a second one waits for the first. Nothing is
              written next to the document except TeX’s own output (including
              job.fls), so a folder synchronised between computers (by
              Nextcloud, Syncthing, ...) carries no snapshots; each computer
              keeps its own.

       ~/.cache/tenkana/docs/job-hash/job-snap/ck000.img
              The preamble snapshot on disk.

Memory
       A snapshot holds what the engine holds at that point, mostly fonts and
       packages; -v shows the total. Snapshots mark themselves as the first
       processes for the kernel’s out-of-memory killer to stop (other memory
       managers, such as systemd-oomd(8), may choose differently).

       Snapshots are ordinary processes: they survive closing the terminal. They
       end at a reboot; at a logout only if the system ends a user’s processes
       then (with systemd, when KillUserProcesses is set in logind.conf(5));
       TENKANA_TTL after the document’s last build; with tenkana --clean or
       --clean-all; and within half a minute after the document’s cache folder
       is deleted. tenkana does not watch for any of this: at the next build it
       finds that the snapshots are gone, and restores the preamble snapshot
       from disk, or makes a full run if there is none.

       Snapshots keep the output files open. If another program replaces one of
       them (some synchronisation tools do), the snapshots that hold it cannot
       be used, and tenkana starts from an earlier one or makes a full run.

Exit status
       0 on success; TeX’s exit status if TeX stopped with an error (or
       xdvipdfmx’s, if it failed); 2 for a missing or unknown command or a wrong
       option; 128 plus the signal’s number if tenkana or TeX was ended by a
       signal; 1 for other errors. For another program, its exit status.

Notes
       tenkana is built for GNU/Linux and needs nothing else installed.
       Snapshots need an x86-64 processor; on others, such as aarch64, tenkana
       builds with plain runs. Its libraries are loaded into TeX and into
       programs such as latexmk(1), which must therefore use the GNU C library
       (2.17 or newer); with an engine that cannot load them, tenkana builds
       with plain runs. Snapshots need \begin{document} in the main file itself;
       other documents (plain TeX, for example) are built with plain runs. With
       \includeonly, only the chapters it includes get snapshots. \today, time
       stamps and \write18 side effects come from the run that made the
       snapshot.

Unsafe code
       tenkana is written in Rust. Where it calls the C library, takes the place
       of C library functions in TeX and other programs, or restores a snapshot,
       it uses unsafe code, which the Rust compiler does not check. Claude
       checked every unsafe block against the behaviour that the Rust Reference
       and the Rustonomicon list as undefined (data races, dangling or
       misaligned pointers, broken aliasing rules, invalid or uninitialised
       values, calls with the wrong ABI, unwinding, misused inline assembly),
       and changed the code until it found none of it. This is a check by an
       LLM, not a human review or a proof: the Reference says that its list is
       not complete, and restoring a snapshot from disk replaces the memory of
       the engine, which Rust’s rules do not describe (that code uses only
       system calls and its own instructions).

Author
       Written by Claude, a large language model (LLM) made by Anthropic.
       Designed, directed and tested by निरंजन (Niranjan), who does not
       understand its code; as far as he knows, no human has reviewed it.

License
       Copyright © 2026 निरंजन (Niranjan)

       This program is free software: you can redistribute it and/or modify it
       under the terms of the GNU General Public License as published by the
       Free Software Foundation, either version 3 of the License, or (at your
       option) any later version.

       This program is distributed in the hope that it will be useful, but
       WITHOUT ANY WARRANTY; without even the implied warranty of
       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
       Public License for more details.

       You should have received a copy of the GNU General Public License along
       with this program. If not, see <https://www.gnu.org/licenses/>.

       tenkana was written by Claude, a large language model (LLM) made by
       Anthropic. Its maintainer designs tenkana and tests what it does, but
       does not understand its code; as far as he knows, no human has reviewed
       it. Courts are divided on whether material generated by an LLM can be
       protected by copyright. Should it be found that the copyright claimant
       cannot hold copyright in any part of tenkana, that part is in the public
       domain. Wherever copyright does hold, tenkana is distributed under the
       terms of the aforementioned license.

Reporting bugs
       Home page, sources and releases: <https://sij.ai/niru/tenkana>.

See also
       arara(1), l3build(1), lualatex(1), pdflatex(1), xelatex(1), latexmk(1),
       biber(1), makeindex(1)
