Skip to content

thomas-chauvet/latex2pdf-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Test LaTeX to PDF

latex2pdf-action

GitHub action to convert LaTeX documents to PDF files using LuaTeX.

Features

  • 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

Parameters

  • 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. Default false. It will compile the document twice to generate the ToC with LuaTeX.

Outputs

  • time: Timestamp of when the PDF compilation completed. Access it via ${{ steps.<step-id>.outputs.time }}.

Usage

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.pdf

You can find a more complete example in my CV repository with everything to release the PDF document.

Development

Test locally

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" \
  latex2pdf

Code Quality

This project uses pre-commit hooks to maintain code quality. Install them with:

pip install pre-commit
pre-commit install

See CONTRIBUTING.md for more details.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines on how to contribute to this project.

Running Tests

The project includes automated tests that run on every push. You can see the test workflow in .github/workflows/test.yml.

Notes

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.

License

This project is open source and available under the MIT License.

About

GitHub action to convert LaTeX document in PDF file

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •