LaTeX Service contains everything needed to create a small containerised Flask server with a latexmk
and texlive
installation. It is used in combination with Spindle Server as a dependency of ParsePort.
This repository uses texlive-latex-extra
, which includes an extensive set of additional packages needed for the ParsePort. There are, however, several other texlive
packages out there. (An overview and discussion can be found here.) These packages vary greatly in size and a choice for one or another could drastically impact the size of the image.
A host machine with Docker installed.
-
Build an image with
docker build -t latex-service:latest .
-
Run a container and expose a port with
docker run -d -p 32769:5000 --name latex-service latex-service
-
Send a request with a
.tex
string as its body to 5000. -
The response should contain the PDF in byte string format.
The LaTeX compiler creates auxiliary files with a uniquely created ID in the name, which are not automatically removed. For production use, it is recommended that you periodically clean up these files. You can do this by running docker exec -it latex-service /bin/bash
and then running latexmk -C
(for the auxiliary files) followed by rm *.tex
for the source files. If you have cron
on the server, you may want to add the job in Crontab
, which performs this cleanup once a day. Make sure to change the name of the container name in the command above if it is named differently on your system.
LaTeX Service is shared under a BSD 3-Clause licence. See LICENSE for more information.
If you wish to cite this repository, please use the metadata provided in our CITATION.cff file.
For questions, small feature suggestions, and bug reports, feel free to create an issue. If you do not have a Github account, you can also contact the Centre for Digital Humanities.