latex-action

GitHub Action to compile LaTeX documents
授权协议 MIT License
开发语言
所属分类 企业应用、 LaTeX排版系统
软件类型 开源软件
地区 不详
投 递 者 奚昌胤
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

latex-action GitHub Actions Status

GitHub Action to compile LaTeX documents.

This actions runs on docker using a maximal TeXLive environment installed.

Inputs

  • root_file

    The root LaTeX file to be compiled. This input is required.

  • working_directory

    The working directory for the latex compiler to be invoked.

  • compiler

    The LaTeX engine to be used. By default latexmk is used. latexmk 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 compiler. By default, it is -pdf -latexoption=-file-line-error -latexoption=-interaction=nonstopmode. This tells latexmk to use pdflatex. Refer to latexmk document for more information.

  • extra_system_packages

    The extra packages to be installed by apt-get separated by space.

Examples

Build main.tex using latexmk

Note that by default latexmk is used.latexmk automates the process of generating LaTeX documents by issuing the appropriate sequence of commands to be run.

name: Build LaTeX document
on: [push]
jobs:
  build_latex:
    runs-on: ubuntu-latest
    steps:
      - name: Set up Git repository
        uses: actions/checkout@v2
      - name: Compile LaTeX document
        uses: dante-ev/latex-action@latest
        with:
          root_file: main.tex

Build example-class-relations--svg.tex using lualatex

This is required if one does not trust latexmk and wants to build "by hand"

name: Build LaTeX document
on: [push]
jobs:
  build_latex:
    runs-on: ubuntu-latest
    steps:
      - name: Set up Git repository
        uses: actions/checkout@v2
      - name: example-class-relations--svg
        uses: dante-ev/latex-action@latest
        with:
          root_file: example-class-relations--svg.tex
          compiler: lualatex
          args: -interaction=nonstopmode -shell-escape

"Real" document

In a "real" document, one would have to encode all steps one after another:

name: Build LaTeX document
on: [push]
jobs:
  build_latex:
    runs-on: ubuntu-latest
    steps:
      - name: Set up Git repository
        uses: actions/checkout@v2
      - name: pdflatex main
        uses: dante-ev/latex-action@latest
        with:
          root_file: main.tex
          compiler: pdflatex
          args: -interaction=nonstopmode -shell-escape
      - name: bibtex main
        uses: dante-ev/latex-action@latest
        with:
          root_file: main.aux
          compiler: bibtex
          args: 
      - name: pdflatex main
        uses: dante-ev/latex-action@latest
        with:
          root_file: main.tex
          compiler: pdflatex
          args: -interaction=nonstopmode -shell-escape

Custom build script

When using a custom shell script for building, one can pass this as follows:

name: Build LaTeX document
on: [push]
jobs:
  build_latex:
    runs-on: ubuntu-latest
    steps:
      - name: Set up Git repository
        uses: actions/checkout@v2
      - name: release.sh
        uses: dante-ev/latex-action@latest
        with:
          entrypoint: ./release.sh

Real life example: https://github.com/koppor/plantuml/blob/main/.github/workflows/build-and-publish.yml

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 args to -xelatex -latexoption=-file-line-error -latexoption=-interaction=nonstopmode or -lualatex -latexoption=-file-line-error -latexoption=-interaction=nonstopmode respectively. Alternatively, you could create a .latexmkrc file. Refer to the latexmk document for more information.Please mind that it is not recommend to change the compiler parameter, as the by default used latexmk has the advantage of determinating the (re)compilation steps automatically and executes them.

How to enable --shell-escape?

To enable --shell-escape, you should add it to args. For example, set args to -pdf -latexoption=-file-line-error -latexoption=-interaction=nonstopmode -latexoption=-shell-escape when using pdfLaTeX.

Where does the initial code come from?

The initial code is from xu-cheng/latex-action.The idea there is to initially provide all packages instead of using texliveonfly.Using a full installation, this action also offers to use packages such as pax, which require other tooling such as perl.More reasoning is given in ADR-0002.

How can I speedup the build?

You can try to use caching, though be careful as sometimes a LaTeX document needs to be rebuilt completly in order to have a proper result.

Here is an example that rebuilds uses the cache at most once a day. The files to cache are taken from the well-known GitHub .gitignore templates:

# https://github.com/actions/cache#creating-a-cache-key
      # http://man7.org/linux/man-pages/man1/date.1.html
      - name: Get Date
        id: get-date
        run: |
          echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
        shell: bash

      - name: Cache
        uses: actions/cache@v2.1.3
        with:
          # A list of files, directories, and wildcard patterns to cache and restore
          path: |
            *.aux
            *.lof
            *.lot
            *.fls
            *.out
            *.toc
            *.fmt
            *.fot
            *.cb
            *.cb2
            .*.lb
            *.bbl
            *.bcf
            *.blg
            *-blx.aux
            *-blx.bib
            *.run.xml
          key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}

Where to find my PDF?

Please use an appropriate GitHub action.One option is upload-artifact, which collects the build artifacts and stores them into a GitHub space.Another option is to use rsync via action-rsyncer.

Available versions

License

MIT

  • 1、自动关联参考文献和引用  \usepackage{hyperref} \hypersetup{hypertex=true,             colorlinks=true,             linkcolor=blue,             anchorcolor=blue,             citecolor=blue} 2、换行 \\ 3、引用参考文献: \ci

  • \documentclass[a4paper]{article} \usepackage[margin=1in]{geometry} % 设置边距,符合Word设定 \usepackage{ctex} \usepackage{lipsum} \usepackage{graphicx} %插入图片的宏包 \usepackage{float} %设置图片浮动位置的宏包 \usepackage{list

  • Latex 问题解决 参考文章: (1)Latex 问题解决 (2)https://www.cnblogs.com/king-lps/p/10405084.html (3)https://www.codeprj.com/blog/9ec4dc1.html 备忘一下。

 相关资料
  • 部署 LaTeX 安装 texlive-core 新建 a.tex 文件,内容如下: \documentclass[11pt,a4paper]{article} %加入了一些针对XeTeX的改进并且加入了 \XeTeX 命令来输入漂亮的XeTeX logo \usepackage{xltxtra} %启用一些LaTeX中的功能 \usepackage{xunicode} %%%% fontspe

  • LaTeX(LATEX,音译“拉泰赫”)是一种基于TeX的排版系统。 LaTeX通过CTAN服务器发布,或作为TeX用户组(TUG)或第三方提供的许多易于安装和可用的TeX发布版本的一部分。如果您遇到问题,请访问帮助部分。 LaTeX本身并不是一个独立的排版程序,而是运行在Donald E. Knuth的TeX排版系统之上的文档准备软件。TeX发行版通常会将工作中的TeX系统所需的所有部件捆绑在一

  • Vim + LaTeX snippets setup How I'm able to take notes in mathematics lectures using LaTeX and Vim Vim configuration Copy tex.snippets to ~/.vim/UltiSnips/ and assuming you're using Vim Plug, add the f

  • PDF 下载: 放映版 阅读版 Copyright (C) 2018–2021 by Xiangdong Zeng.

  • Warning — looking for a maintainer This extension is no longer maintained. I'm sorry, it's not you, it's me. I still love this functionality, I've just moved to a different editor to get it.I don't wa

  • LaTeX Resources This repository provides several examples and resources for LaTeX. All examples are tested using MikTeX 2.9 on Windows 7 and on Ubuntu 12.04/14.04 using texlive-full. License Several e