Build a LaTeX file.
Project description
latex-runner
A wrapper around LaTeX to build files which
- reads magic comments to determine the TeX program and options to be used.
- filters the output to show only errors, warnings, over-/underfull boxes, tracing commands and prompts.
- runs biber and makeglossaries if necessary.
- reruns LaTeX up to -n times if necessary.
Magic Comments
This program supports the following magic comments:
% !TeX root = ../main.tex
Run the TeX program with the given file instead.
This is useful if you have split up your document into multiple files, the current file is included in the main file with \input
or \include
and you have told vim to build the currently opened file with this program.
% !TeX program = pdflatex
The program used to build the tex file.
For security reasons programs not listed in the allowed-tex-programs
setting are not executed.
By default the allowed programs are pdflatex
, xelatex
, lualatex
, latex
, tex
and pdftex
.
You can change these with latex-runner --edit-config
.
% !TeX option = -shell-escape
A command line option which should be passed to the TeX program.
You can repeat this comment to enable several command line options.
I have introduced this type of comment because at the time of this writing % !TeX program = pdflatex -shell-escape
breaks compilation in TeX studio.
For security reasons options not listed in the allowed-tex-options
setting are not passed to the TeX program.
By default the allowed options are --shell-escape
, --8bit
, --interaction=batchmode
, --interaction=nonstopmode
, --interaction=scrollmode
and --interaction=errorstopmode
.
You can change these with latex-runner --edit-config
.
Config
You can change settings with
latex-runner --edit-config
You can get help how to configure this program with
latex-runner --help-config
Installation
You can install this program via the python package manager pipx:
pipx install latex-runner
vim integration
Copy the following into ~/.vim/after/ftplugin/tex.vim
.
This will allow you to run LaTeX once with F5, build the pdf completely with Control+F5 and open the pdf at the cursor position in zathura with Shift+F5 or F6. You can open the log file with F7.
" build pdf
nnoremap <buffer> <F5> :exec "!latex-runner -n1 -synctex=1 " .. expand('%:p:S')<cr>
nnoremap <buffer> <C-F5> :exec "!latex-runner -n5 -synctex=1 " .. expand('%:p:S')<cr>
" open pdf
nnoremap <buffer> <S-F5> :exec "silent! !zathura --synctex-forward " .. line('.') .. ":" .. col('.') .. ":" .. expand('%:p') .. " " .. trim(system('latex-runner --get-pdf ' .. expand('%:p:S') .. " 2>/dev/null")) .. " >/dev/null 2>/dev/null &"<cr>:redraw!<cr>
nnoremap <buffer> <F6> :exec "silent! !zathura --synctex-forward " .. line('.') .. ":" .. col('.') .. ":" .. expand('%:p') .. " " .. trim(system('latex-runner --get-pdf ' .. expand('%:p:S') .. " 2>/dev/null")) .. " >/dev/null 2>/dev/null &"<cr>:redraw!<cr>
" open log file, return with :bp
nnoremap <buffer> <F7> :exec "edit " .. trim(system('latex-runner --get-log ' .. expand('%:p:S') .. " 2>/dev/null"))<cr>
" texdoc, to be used when cursor is in argument of \usepackage
nnoremap <buffer> K :silent exec '!texdoc <c-r>=expand("<cfile>")<cr> >/dev/null 2>&1 &' \| redraw!<cr>
" inserting magic comments
command InsertMagicCommentXelatex :0put ='% !TeX program = xelatex'
command InsertMagicCommentPdflatex :0put ='% !TeX program = pdflatex'
command InsertMagicCommentShellEscape :1put ='% !TeX option = -shell-escape'
command InsertMagicCommentRoot :0put ='% !TeX root = ../main.tex'
Running the tests
I am using mypy for static type checking and pytest for dynamic testing.
tox creates a virtual environment and installs all dependencies for you.
You can install tox with pipx (pipx install tox
).
$ tox
In order to make tox work without an internet connection install devpi:
$ pipx install devpi-server
$ devpi-init
$ devpi-gen-config
$ su
# cp gen-config/devpi.service /etc/systemd/system/
# systemctl start devpi.service
# systemctl enable devpi.service
and add the following line to your bashrc:
export PIP_INDEX_URL=http://localhost:3141/root/pypi/+simple/
Project details
Release history Release notifications | RSS feed
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 latex_runner-1.0.0.tar.gz
.
File metadata
- Download URL: latex_runner-1.0.0.tar.gz
- Upload date:
- Size: 23.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f8990a1a633f3050b17f0421197d7d7d61000b3368ff44359a34164c27915a5 |
|
MD5 | 3174244e0b2d3f4eb3bc144bd5e1b157 |
|
BLAKE2b-256 | 8018418c06bce57f224b84c886a03e2b889c0e0247033a18be51822d72eb01e8 |
File details
Details for the file latex_runner-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: latex_runner-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03567be2a18b87f62c821f14f5f7294e19120d826381ebed7642574f452c1d4d |
|
MD5 | 267c00184eb0be96f1546224dba16f7e |
|
BLAKE2b-256 | 642bf45c58d580a6ebe6a8f9abb3d992a6810497d4e8b11eeece3f4b985c43bd |