Home

Awesome

latex-action

GitHub Actions Status

GitHub Action to compile LaTeX documents.

It runs in a docker container with a full TeXLive environment installed.

If you want to run arbitrary commands in a TeXLive environment, use texlive-action instead.

Inputs

Each input is provided as a key inside the with section of the action.

The following inputs are only valid if the input compiler is not changed.

Example

name: Build LaTeX document
on: [push]
jobs:
  build_latex:
    runs-on: ubuntu-latest
    steps:
      - name: Set up Git repository
        uses: actions/checkout@v4
      - name: Compile LaTeX document
        uses: xu-cheng/latex-action@v3
        with:
          root_file: main.tex
      - name: Upload PDF file
        uses: actions/upload-artifact@v4
        with:
          name: PDF
          path: main.pdf

FAQs

How to use XeLaTeX or LuaLaTeX instead of pdfLaTeX?

By default, this action uses pdfLaTeX. If you want to use XeLaTeX or LuaLaTeX, you can set the latexmk_use_xelatex or latexmk_use_lualatex input respectively. For example:

- uses: xu-cheng/latex-action@v3
  with:
    root_file: main.tex
    latexmk_use_xelatex: true
- uses: xu-cheng/latex-action@v3
  with:
    root_file: main.tex
    latexmk_use_lualatex: true

Alternatively, you could create a .latexmkrc file. Refer to the latexmk document for more information.

How to enable --shell-escape?

To enable --shell-escape, set the latexmk_shell_escape input.

- uses: xu-cheng/latex-action@v3
  with:
    root_file: main.tex
    latexmk_shell_escape: true

Where is the PDF file? How to upload it?

The PDF file will be in the same folder as that of the LaTeX source in the CI environment. It is up to you on whether to upload it to some places. Here are some example.

How to add additional paths to the LaTeX input search path?

Sometimes you may have custom package (.sty) or class (.cls) files in other directories. If you want to add these directories to the LaTeX input search path, you can add them in TEXINPUTS environment variable. For example:

- name: Download custom template
  run: |
    curl -OL https://example.com/custom_template.zip
    unzip custom_template.zip
- uses: xu-cheng/latex-action@v3
  with:
    root_file: main.tex
  env:
    TEXINPUTS: ".:./custom_template//:"

Noted that you should NOT use {{ github.workspace }} or $GITHUB_WORKSPACE in TEXINPUTS. This action works in a separated docker container, where the workspace directory is mounted into it. Therefore, the workspace directory inside the docker container is different from github.workspace.

You can find more information of TEXINPUTS here.

It fails due to xindy cannot be found.

This is an upstream issue where xindy.x86_64-linuxmusl is currently missing in TeXLive. To work around it, try this.

It fails to build the document, how to solve it?

License

MIT