[luatex] LuaTeX precompilation

Henrik Mannerström henrik.mannerstrom at gmail.com
Fri Dec 22 11:57:29 CET 2023


Thank you all for an enlightening discussion!

As it seems this can't be done from within luatex, you can always add
another layer of indirection! Alex expressed exactly what I wanted
"minimize the latency from hitting the compile button". Since I
already use Make to run my latex jobs, some shell-scripting won't hur
right? ;) Below is a proof-of-concept tex-server. You give it the
tex-sourcefile you are targeting, and it will run an infinite loop
that starts lualatex, pipes it the source file up to the line with "%%
end preamble" and then waits until a file "sourcefile.tex.resume" is
created, piping the rest of the source after that. Very crude and
simple, but it works. The main reason why I did it like this is that
it requires almost no change to the original source file.

texserver.sh:
#!/bin/sh
# texserver

while true
do
    texsplit.sh $1 | lualatex
    mv texput.pdf ${1/tex/pdf}
done

texsplit.sh:
#!/bin/sh

sed -e '/%% end preamble/q' $1
while [ ! -f "${1}.resume" ]
do
    sleep 0.05
done
rm "${1}.resume"
sed -e '1,/%% end preamble/ d' $1


More information about the luatex mailing list.