GitHub action to convert LaTeX documents to PDF files using LuaTeX.
- Compile LaTeX documents to PDF using LuaTeX
- Support for custom CTAN packages
- Table of Contents (ToC) generation with double compilation
- Based on lightweight TinyTeX distribution
- Ubuntu 24.04 LTS base image for security and stability
output_dir: use it to get the PDF file at a specific location at the end of the compilation.main_latex_file: main LaTeX file to convert (e.g.main.tex).ctan_packages: Extra packages from CTAN to install. List of packages available here. Each package must be separated by a space (e.g. "moderncv xargs").toc: boolean to add ToC or not. Defaultfalse. It will compile the document twice to generate the ToC withLuaTeX.
time: Timestamp of when the PDF compilation completed. Access it via${{ steps.<step-id>.outputs.time }}.
You can refer to the example attached in this repository.
In the example below we compile the document in PDF and upload as an artefact of the pipeline:
name: LaTeX to PDF
on:
push:
branches:
- main
- develop
tags:
- "*"
pull_request:
branches: [main]
jobs:
build_latex:
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v4
- name: latex2pdf
id: compile-latex-document
uses: thomas-chauvet/latex2pdf-action@v2
with:
output_dir: output
main_latex_file: test.tex
ctan_packages: amsmath amsfonts lua-uni-algos
- name: Upload PDF to the workflow tab
id: upload-workflow-tab
uses: actions/upload-artifact@v4
with:
name: output
path: output/test.pdfYou can find a more complete example in my CV repository with everything to release the PDF document.
Build docker image:
docker build -t latex2pdf .Run the example:
docker run \
-e OUTPUT_DIR="output" \
-e MAIN_LATEX_FILE="test.tex" \
-e CTAN_PACKAGES="amsmath amsfonts lua-uni-algos" \
-v "${PWD}/resources/test.tex":"/test.tex" \
-v "${PWD}/output":"/output" \
latex2pdfThis project uses pre-commit hooks to maintain code quality. Install them with:
pip install pre-commit
pre-commit installSee CONTRIBUTING.md for more details.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines on how to contribute to this project.
The project includes automated tests that run on every push. You can see the test workflow in .github/workflows/test.yml.
The Docker image used to compile documents is based on Ubuntu 24.04 LTS and the excellent work of @Yihui for TinyTeX. This allows the image to stay relatively small and use only what is needed.
This project is open source and available under the MIT License.