Skip to content

Instantly share code, notes, and snippets.

@ThabetAmer
Created January 28, 2020 17:27
Show Gist options
  • Save ThabetAmer/7a6a60ad464d54922f803de7f6866523 to your computer and use it in GitHub Desktop.
Save ThabetAmer/7a6a60ad464d54922f803de7f6866523 to your computer and use it in GitHub Desktop.
Compile Latex files using docker
#!/bin/bash
# Either to compile single file passed in args
# OR to go over all .tex files in directory - in batch mode.
# compile the tex file in arguments
[ -f "$1" ] && { docker run -i -w "/doc" -v "$PWD":/doc thomasweise/texlive xelatex -interaction=nonstopmode -halt-on-error $1; exit 0; }
# batch mode - compile all tex files
docker run -i -w "/doc" -v "$PWD":/doc thomasweise/texlive bash -c 'for file in $(find . -maxdepth 1 -name "*.tex"); do echo "Generating pdf for $file ..." && xelatex -interaction=batchmode -halt-on-error $file; done'
# cleanup
echo "Cleanup..."
rm -rf *.log *.aux *.out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment