.\" tenkana, a spider that jumps from the checkpoints of your TeX document.
.\" Copyright © 2026 निरंजन (Niranjan)
.\"
.\" tenkana 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.
.\"
.\" tenkana 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 tenkana. If not, see .
.\"
.\" tenkana was written by Claude, a large language model (LLM) made by
.\" Anthropic. 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 GNU General Public License, version 3 or (at your option) any
.\" later version, as stated above.
.TH tenkana 1 "November 2026" "tenkana 0.2.0" "User Commands"
.SH NAME
tenkana \- a spider that jumps from the checkpoints of your TeX document
.SH SYNOPSIS
.B tenkana
[\fItenkana options\fR]
\fITeX-command\fR
[\fITeX options\fR]
\fIfile\fR
.br
.B tenkana
[\fItenkana options\fR]
.B \-q
\fIfile\fR
.SH DESCRIPTION
tenkana runs a TeX command, such as \fBlualatex thesis\fR, the way
.BR env (1)
and
.BR time (1)
run theirs, but makes repeated builds faster.
While TeX runs, tenkana keeps frozen copies (\fIsnapshots\fR) of the running
engine: one just before \fB\\begin{document}\fR and one before each
\fB\\include\fR.
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.
.PP
.RS
.nf
tenkana lualatex thesis
tenkana \-\-final pdflatex \-synctex=1 thesis
tenkana pdflatex\-dev '\\nonstopmode\\input paper.ltx'
tenkana \-q thesis
.fi
.RE
.PP
The TeX command may be any command that runs pdfTeX, LuaTeX (also
LuaHBTeX, LuaJITTeX) or XeTeX: \fBpdflatex\fR, \fBlualatex\fR,
\fBxelatex\fR, \fBpdflatex\-dev\fR 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 \fB\\input\fR as the main
file, and without an \fB\\input\fR 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
.BR kpsewhich (1)).
If TeX would not find it either, tenkana runs the command as it is and TeX
reports the problem.
.PP
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 \fB\-recorder\fR
right after the command name: it needs the list of files TeX reads, which
TeX writes to \fIjob\fB.fls\fR.
XeTeX also gets \fB\-no\-pdf\fR, followed by one
.BR xdvipdfmx (1)
run at the end, as XeTeX would run it (\fBxdvipdfmx \-q \-E\fR); with
your own \fB\-no\-pdf\fR, tenkana leaves the \fB.xdv\fR file as it is.
TeX's questions (after an error, or from \fB\\typein\fR) 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
.BR fork (2)
by a small library that tenkana loads into the engine with
.BR LD_PRELOAD .
They live in memory, as ordinary processes, and survive between runs of
tenkana (see
.BR MEMORY ).
The preamble snapshot is also saved on disk, compressed, so it survives a
reboot (see
.BR "SNAPSHOTS ON DISK" ).
.PP
TeX's own terminal output is shown unchanged.
tenkana's messages follow it.
Each is one line and starts with \fBtenkana:\fR; error messages go to
standard error.
.SH DRAFT AND FINAL BUILDS
By default tenkana makes a \fIdraft\fR build: one pass.
Cross-references, citations and the table of contents keep the values
read by the last build that started at \fB\\begin{document}\fR (a full
run, a final build, or an edit that resumed from the preamble snapshot);
new labels show as \fB??\fR.
The text and page layout are always current.
.PP
With \fB\-\-final\fR, tenkana reruns from the preamble snapshot until the
\fB.aux\fR, \fB.toc\fR and similar files stop changing (at most 4 passes),
like
.BR latexmk (1).
Use it before submitting.
.SH OPTIONS
tenkana's options come before the TeX command; the first word that is not one
of them starts it, and \fB\-\-\fR ends them explicitly.
.TP
.BR \-q ", " \-\-quick
Only the file is given, and the default engine is used:
\fBtenkana \-q thesis\fR is \fBtenkana lualatex thesis\fR (or the command in
\fBTENKANA_ENGINE\fR).
.TP
.BR \-F ", " \-\-final
Rerun until references, citations and the table of contents are up to date.
.TP
.BR \-d ", " \-\-draft
One pass; references are not updated. This is the default.
.TP
.BR \-v ", " \-\-verbose
Also show tenkana's details: passes, changed files, snapshots and their memory.
.TP
.B \-\-silent
Show only TeX's output and tenkana's error messages.
.TP
.B \-\-no\-snapshots
Build with plain runs instead of snapshots.
.TP
.BR \-f ", " \-\-force
Stop this document's snapshots, discard tenkana's cached state and build from
scratch.
.TP
.B \-\-clean
Stop a document's snapshots, delete its cache (see
.BR FILES ),
and exit.
Name the document as for a build (\fBtenkana \-\-clean lualatex thesis\fR)
or just by its name (\fBtenkana \-\-clean thesis\fR; \fBthesis.tex\fR and
\fBthesis.ltx\fR mean the same).
The file itself need not exist any more.
.TP
.BR \-V ", " \-\-version
Print the version and exit.
.TP
.BR \-h ", " \-\-help
Print a short help text and exit.
.PP
TeX's options go to TeX unchanged: for example \fB\-shell\-escape\fR,
\fB\-synctex=1\fR, \fB\-interaction=batchmode\fR, \fB\-file\-line\-error\fR
or \fB\-jobname=\fR\fIname\fR.
Not supported yet, and refused with a message: \fB\-ini\fR, \fB\-fmt\fR
(and \fB&\fR\fIformat\fR), \fB\-output\-directory\fR,
\fB\-aux\-directory\fR, \fB\-output\-format\fR and
\fB\-output\-driver\fR.
A change of the TeX command makes the next build a full run.
.PP
With SyncTeX on, the snapshot library keeps TeX's
\fIjob\fB.synctex(busy)\fR file in tenkana's cache, where the snapshots can
hold it, and copies it to \fIjob\fB.synctex.gz\fR at the end instead of
renaming it, so snapshots work as usual.
.SH SNAPSHOTS ON DISK
After a build that made a new preamble snapshot, a copy of that snapshot
writes itself to tenkana's cache (see
.BR FILES )
in the background, compressed with zstd (zlib if zstd is missing), unless
it would be larger than \fBTENKANA_SAVE_LIMIT\fR.
Only memory that differs from the files on disk is stored, and empty pages
are skipped; typical sizes are 7\(en15MB.
The default limit is 20MB.
.PP
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 \fBmain()\fR runs, typically
in 0.1\(en0.3s.
The chapter snapshots are then made again in memory during that build.
.PP
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.
.SH WHAT tenkana WATCHES
Every file the engine reads (recorded with \fB\-recorder\fR), 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
\fB\\include\fR.
The parts follow what TeX actually did, so \fB\\includeonly\fR,
conditionals and \fB\\include\fR inside an \fB\\input\fR 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.
.PP
tenkana also records every file TeX \fIlooked for but did not find\fR in the
document's folder: a chapter not written yet, an image, a \fB.bbl\fR before
.BR biber (1)
has run, an \fB.ind\fR before
.BR makeindex (1).
When such a file appears, the next build continues from the part of the
document that looked for it.
.PP
In addition, files that other programs generate for TeX to read are watched
by name, even if TeX has not looked for them yet:
.PP
.RS
.nf
\fB.bbl\fR biber, BibTeX
\fB.ind\fR makeindex, xindy
\fB.gls\fR makeglossaries (main glossary)
\fB.acr\fR makeglossaries (acronyms)
\fB.nls\fR makeindex for nomencl
\fB.glstex\fR bib2gls (read in the preamble: a full run)
.fi
.RE
.PP
Glossary types declared in the \fB.aux\fR file are added automatically.
Files are matched as \fIjob\fR.\fIext\fR, \fIjob\fR\-*.\fIext\fR and
\fIchapter\fR.\fIext\fR.
More extensions can be added with \fBTENKANA_WATCH\fR.
.PP
Changes to the \fB.aux\fR, \fB.toc\fR and similar files written by TeX
itself are deliberately ignored in draft builds.
.SH ENVIRONMENT
.TP
.B TENKANA_ENGINE
The command for \fB\-q\fR instead of \fBlualatex\fR; it may have options,
as in \fBTENKANA_ENGINE="pdflatex \-shell\-escape"\fR.
.TP
.B TENKANA_SILENT
If set, as \fB\-\-silent\fR.
.TP
.B TENKANA_TTL
Seconds the snapshots live after the document's last build (default
28800, i.e. 8 hours).
.TP
.B TENKANA_SAVE_LIMIT
Largest preamble snapshot to keep on disk, in MB (default 20).
\fB0\fR turns saving off.
.TP
.B TENKANA_WATCH
Additional generated-file extensions to watch, separated by commas or
spaces, e.g. \fBTENKANA_WATCH=xyz,abc\fR.
They are assumed to be read in the preamble, so a change causes a full run.
.TP
.B TENKANA_DEBUG
If set, explain why a snapshot could not be used.
.TP
.B TENKANA_SHIM
Use this snapshot library instead of the built-in one.
.SH FILES
.TP
.I ~/.cache/tenkana/
tenkana's cache
.RB ( $XDG_CACHE_HOME/tenkana/
if that is set), readable only by you: the compiled snapshot library
(kept in \fI/tmp/tenkana\-uid/\fR instead if the cache's path contains a space
or a colon, which \fBLD_PRELOAD\fR cannot handle), and one folder per
document under
.IR 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 \fIjob\fB.fls\fR), so a
folder synchronised between computers (by Nextcloud, Syncthing, ...)
carries no snapshots; each computer keeps its own.
.TP
.IR ~/.cache/tenkana/docs/ job \- hash / job \-snap/ck000.img
The preamble snapshot on disk.
.SH MEMORY
A snapshot holds what the engine holds at that point, mostly fonts and
packages; \fB\-v\fR 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
.BR systemd\-oomd (8),
may choose differently).
.PP
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 \fBKillUserProcesses\fR is set in
.BR logind.conf (5));
\fBTENKANA_TTL\fR after the document's last build; with
\fBtenkana \-\-clean\fR; 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.
.PP
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.
.SH EXIT STATUS
0 on success; TeX's exit status if TeX stopped with an error (or
\fBxdvipdfmx\fR'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.
.SH NOTES
Snapshots need GNU/Linux, a C compiler (to build the snapshot library on
first use) and an x86-64 machine; without the compiler or on another
processor, tenkana builds with plain runs.
Snapshots need \fB\\begin{document}\fR in the main file itself; other
documents (plain TeX, for example) are built with plain runs.
With \fB\\includeonly\fR, only the chapters it includes get snapshots.
\fB\\today\fR, time stamps and \fB\\write18\fR side effects come from the
run that made the snapshot.
.SH AUTHOR
Written by Claude, a large language model (LLM) made by Anthropic.
Designed, directed, reviewed and tested by निरंजन (Niranjan).
.SH COPYRIGHT
Copyright \(co 2026 निरंजन (Niranjan).
License GPLv3+: GNU GPL version 3 or later
.
.br
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
.PP
tenkana was written by Claude, a large language model (LLM) made by
Anthropic.
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
GNU General Public License, version 3 or (at your option) any later
version.
.SH SEE ALSO
.BR lualatex (1),
.BR pdflatex (1),
.BR xelatex (1),
.BR latexmk (1),
.BR biber (1),
.BR makeindex (1)