A Docker image to run LaTeX →
source link: https://github.com/alexwlchan/tex-dockerfile
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
tex-dockerfile
This repo contains the Dockerfile I use to run LaTeX (or specifically, XeLaTeX).
I run LaTeX in a Docker container so:
-
I don't have to muck around with installing MacTeX or TeX Live. I've had particular issues in the past when the year increments (e.g. 2018 to 2019), and suddenly
tlmgr
stops working. -
I have consistent package installations across machines.
-
I can easily run LaTeX on a Linux server, which means I can compile LaTeX documents on my iPad over SSH.
The idea is that the base container should be pretty small, so it builds quickly, and then I add packages as needed with tlmgr
.
Usage
Clone this repo, then build a Docker image from the Dockerfile:
git clone https://github.com/alexwlchan/tex-dockerfile.git cd tex-dockerfile docker build --tag alexwlchan/texlive .
To build a document, mount the folder containing the document at /data
and run the Docker image, passing the name of the LaTeX binary and the source document as arguments.
For example:
docker run \ --volume $(pwd):/data \ alexwlchan/texlive \ xelatex example.tex
Adding fonts and packages
If you want to make extra fonts available to XeLaTeX, copy the font files (e.g. .otf
, .ttf
) into the fonts
directory and rebuild the Docker image.
If you want to install extra packages, create a second Dockerfile and use tlmgr
to install the packages in that image.
For example:
# lastpage.Dockerfile FROM alexwlchan/texlive RUN tlmgr update --self && tlmgr install lastpage
docker build --tag alexwlchan/texlive-with-lastpage --file lastpage.Dockerfile .
To build documents with this image, use the new image name in the docker run
command:
docker run \ --volume $(pwd):/data \ alexwlchan/texlive-with-lastpage \ xelatex example.tex
Licence
MIT.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK