You downloaded a .tex document from somewhere, made a few modifications and want to compile it into a PDF file now. Of course you don’t want to permanently install a plethora of software for that on your device too, as you just need to compile that single document.

If you have Docker installed, I’ve got you covered.

We use the following article.tex file to check if compilation into a PDF file works:

\documentclass{article}
\begin{document}
Hello World!
\end{document}

Simply navigate to the folder where you’ve put your article.tex file and execute the following command in your terminal:

#> docker run --rm -v $(pwd):/docs authsec/sphinx pdflatex article.tex

Note

If you’re running Windows the command is basically the same, but you need to replace $(pwd) with ${PWD} for the above command to work.

This command generates an article.pdf file with the content “Hello World!”

For advanced use cases you can of course add additional pdflatex command line flags like -interaction=batchmode. Just append after the pdflatex command as if you’d use the regular command.

#> docker run --rm -v $(pwd):/docs authsec/sphinx pdflatex -interaction=batchmode article.tex

Cleaning Up

In order to remove the downloaded container from your system you can run:

#> docker image rm authsec/sphinx

If you want to clean up everything docker, simply run:

#> docker system prune

The docker image used to compile the LaTeX document, can also be used to compile sphinx projects or a pelican blog. You can find further information in my Github Repository.

Like this post? Share on: TwitterFacebookEmail


Jens Frey Avatar Jens Frey is the creator of the datapile blog.

Keep Reading


Published

Category

Infrastructure

Tags

Stay in Touch