GitHub Action to compile LaTeX documents.
It runs in a docker image with a full TeXLive environment installed.
-
root_file
The root LaTeX file to be compiled. This input is required.
-
working_directory
The working directory for the LaTeX engine.
-
compiler
The LaTeX engine to be invoked. By default,
latexmk
is used, which automates the process of generating LaTeX documents by issuing the appropriate sequence of commands to be run. -
args
The extra arguments to be passed to the LaTeX engine. By default, it is
-pdf -file-line-error -interaction=nonstopmode
. This tellslatexmk
to usepdflatex
. Refer tolatexmk
document for more information. -
extra_system_packages
The extra packages to be installed by
apk
separated by space. For example,extra_system_packages: "py-pygments"
will install the packagepy-pygments
to be used by theminted
for code highlights. -
extra_local_packages
The extra packages to be used via the
TEXINPUTS
environment variable.
name: Build LaTeX document
on: [push]
jobs:
build_latex:
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v1
- name: Compile LaTeX document
uses: xu-cheng/latex-action@master
with:
root_file: main.tex
By default, this action uses pdfLaTeX. If you want to use XeLaTeX or LuaLaTeX, you can set the args
to -xelatex -file-line-error -interaction=nonstopmode
or -lualatex --file-line-error --interaction=nonstopmode
respectively. Alternatively, you could create a .latexmkrc
file. Refer to the latexmk
document for more information.
To enable --shell-escape
, you should add it to args
. For example, set args
to -pdf -file-line-error -interaction=nonstopmode -shell-escape
when using pdfLaTeX.
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.
- You can use
@actions/upload-artifact
to upload PDF file to the workflow tab. - You can use
@actions/upload-release-asset
to upload PDF file to the Github Release. - You can use normal shell tools such as
scp
/git
/rsync
to upload PDF file anywhere. For example, you can git push to thegh-pages
branch in your repo, so you can view the document using Github Pages.
- Try to solve the problem by examining the build log.
- Try to build the document locally.
- You can also try to narrow the problem by creating a minimal working example to reproduce the problem.
- Open an issue if you need help.
MIT