latex-fast-compile is a Linux helper for the following
- Precompile the "preamble" of a given
.texfile (i.e. the part before\csname endofdump \endcsnameor\begin{document}, whichever comes first) - Create a file descriptor watch using
inotify, to bind an action whenever the given.texfile changes - The action: When the
.texfile updates, compile the file, using the precompiled preamble to save time
A working copy of pdflatex must be available on your PATH (typically associated with packages named texlive/texlive-latex).
git clone https://github.com/latex-fast-compile
cd latex-fast-compile
make
sudo make installIf required, specify some $PREFIX to install to, for example,
PREFIX=~/.local/bin make installlatex-fast-compile main.tex
Use Control+D to skip over a
Any \csname endofdump \endcsname.
% "Static" preamble
\some_stuff_like_the_page_header
\csname endofdump \endcsname % Ends the "static" preamble
% "Dynamic" preamble
\stuff_that_changes_like_minitoc
\begin{document} % End of preamble, document starts
...The inotify Linux API is a somewhat old filesystem monitor
used to modify changes in a given directory. Here, we watch a
directory; if the filename changed matches the filename in the
argument, we fire off a compile command via pdflatex.
As for the
# In this example, the argument is "main.tex"
# 1. Precompile the preamble. This creates a preamble.fmt file
pdflatex -ini -jobname=preamble "&pdflatex" mylatexformat.ltx main.tex
# 2. Compile the main.tex file using the preamble
pdflatex -fmt preamble main.texYou can read the code yourself in latex-fast-compile.c.
It is well-commented and follows this pseudocode:
compile preamble
compile using preamble
loop forever:
wait until edit
compile using preamble
GPLv3