A Python module to speed up TeX compilation.
Project description
tex-fast-recompile
A Python module to speed up TeX compilation.
This is similar to mylatexformat
TeX package that it works by "speed up" some "preamble",
but unlike using "precompiled preamble" i.e. custom TeX format,
this package works with every package including package that executes some Lua code, or load OpenType font.
Installation
It can be installed from PyPI or GitHub:
You also need to install the helper TeX package fastrecompile.sty
, which can be found in the tex/
directory.
Refer to https://tex.stackexchange.com/q/1137/250119 for installation instruction.
(currently the TeX package is not available on CTAN)
Usage
If installed properly, an executable tex_fast_recompile
should be available on your command-line.
Run tex_fast_recompile --help
to view the available options.
For example you can use it as follows:
tex_fast_recompile pdflatex a.tex
to compile a.tex
to a.pdf
and automatically watch it on changes.
Limitations
- SyncTeX features of the text part in the "preamble" may not be correct. (if you're not sure what this mean, you should be safe. But see the "Extra note" section below)
- The preamble must not be changed. Furthermore, any file
\input
in the preamble must not be changed. (obviously) - You must not read from the terminal anywhere in the preamble, such as with functions
\read -1 to ...
or\ior_get_term:nN ...
. (if you're not sure what this mean, you should be safe)
Extra note
If you want to read the log file, refer to the help of --copy-log
option.
It's possible to print out some content in the "preamble" part, but if you do so...
\documentclass{article}
\usepackage{fastrecompile} % add the package here
% other preamble lines...
\begin{document}
123
\clearpage
\fastrecompileendpreamble
456
\end{document}
you must also use the --copy-output
option if you want to view the resulting PDF.
--no-add-package
mode
Behind the scene, some magic is done on your TeX file.
If you want to do that manually, you need to modify your TeX file as follows:
\documentclass{article}
\usepackage{fastrecompile} % add the package here
% other preamble lines...
\begin{document}
% put the line below where the preamble ends:
\fastrecompileendpreamble
...
\end{document}
then compile your document with --no-add-package
flag added.
Note that:
\fastrecompileendpreamble
must appear exactly once in the main file.- There must be nothing else on the line that contains
\fastrecompileendpreamble
.
How does it work?
The principle is very simple. Notice that while the user want fast refresh, the file does not change very frequently.
As such, we start the compiler before the file has changed to process the "preamble", then when the file changed we continue processing the rest of the file.
A graph for illustration:
Before:
(each *
represents a file change, |--.--|
represents a compilation where the .
marks where the preamble processing is done)
+----------------------------------------------------> Time
* * * *
|--.--| |--.--| |--.--| |--.--|
After:
+----------------------------------------------------> Time
* * * *
|--.--|--. --|--. --|--. --|
It can be easily seen that after the change, it only takes 2 instead of 5 time unit from when the file is saved to when the change is reflected in the PDF.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tex-fast-recompile-0.2.0.tar.gz
.
File metadata
- Download URL: tex-fast-recompile-0.2.0.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44a3285e77431599798a9ac1b73adc2c84d38b15b11172d04dc75c6355142206 |
|
MD5 | 83cbeedd932cd935ddc0af9f62db05b9 |
|
BLAKE2b-256 | a5350b767b38a2b37c7f48bf8c8d9215bc32ce9866402b3b3e8e44cdd4706d95 |
File details
Details for the file tex_fast_recompile-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: tex_fast_recompile-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04a8f39b5caf87330efaab3fbd241908c7913a860056f63b90ceaee39c3dacca |
|
MD5 | 9dfa181d92722886b481e8b6b05324b3 |
|
BLAKE2b-256 | 62ec4bbac38e27387868d0595cd820a0d4ebd8e06f02f4178b1bc5a8757958d4 |