git - 使用带有图像的 GitLab CI 自动编译 (La)TeX 文件

标签 git gitlab continuous-integration latex

我目前正在尝试使用 GitLab CI 自动构建 PDF 文件。基于this我已经运行了基本的东西,但是,pdflatex 无法找到我包含的图形/图像:

! Unable to load picture or PDF file 'graphics/.../image.png'.
<to be read again> 

Latexmk: Missing input file: 'graphics/.../image.png' from line
'LaTeX Warning: File `graphics/.../image.png' not found on input line 802.'

我的 .gitlab-ci.yml 看起来像这样:

stages:          # List of stages for jobs, and their order of execution
  - compile

compile_pdf:
  stage: compile
  image: tianon/latex
  script:
    - latexmk -pdf -pdflatex="xelatex -interaction=nonstopmode" -use-make thing.tex
  artifacts:
    paths:
      - thing.pdf

我的 makefile 如下所示:

# From DevSolar https://tex.stackexchange.com/a/40759/201491

# You want latexmk to *always* run, because make does not have all the info.
# Also, include non-file targets in .PHONY so they are run regardless of any
# file of the given name existing.
.PHONY: thing.pdf all clean

# The first rule in a Makefile is the one executed by default ("make"). It
# should always be the "all" rule, so that "make" and "make all" are identical.
all: thing.pdf

# CUSTOM BUILD RULES

# In case you didn't know, '$@' is a variable holding the name of the target,
# and '$<' is a variable holding the (first) dependency of a rule.
# "raw2tex" and "dat2tex" are just placeholders for whatever custom steps
# you might have.

# %.tex: %.dat
#         ./dat2tex $< > $@

# MAIN LATEXMK RULE

# -pdf tells latexmk to generate PDF directly (instead of DVI).
# -pdflatex="" tells latexmk to call a specific backend with specific options.
# -use-make tells latexmk to call make for generating missing files.

# -interaction=nonstopmode keeps the pdflatex backend from stopping at a
# missing file reference and interactively asking you for an alternative.

thing.pdf: thing.tex
    latexmk -pdf -pdflatex="xelatex -interaction=nonstopmode" -use-make --shell-escape thing.tex

clean:
    latexmk -CA

两者均基于 this repo 。如何正确添加图像和图形?在我发现的所有使用数字的教程中(如 this ),它就起作用了。或者我错过了什么?

谢谢!

最佳答案

我发现 ctornau/latex Docker 镜像可以开箱即用。

我在 https://gitlab.com/WaldemarLehner/latex-starter 设置了一个小模板存储库

构建的 PDF 可以在 https://waldemarlehner.gitlab.io/latex-starter 找到。

这是我的 gitlab.ci.yml:

build:
  image: ctornau/latex
  stage: build
  artifacts:
    paths:
      - main.pdf
  script:
    # This is needed for colored code blocks. If you dont need
    # them, you can remove this section
    - apt-get -y update
    - apt-get -y install python3-pip
    - pip3 install pygments
    # section end
    - latexmk -shell-escape -pdf main.tex

# This will host the PDF w/ Gitlab Pages
pages:
  image: alpine:latest
  stage: deploy
  dependencies:
    - build
  script:
    # Feel free to change the mv target to something else. You will need to update the index.html though
    # Everything inside public will be hosted by Pages
    - mv main.pdf public/main.pdf

  artifacts:
    paths:
      - public
    

关于git - 使用带有图像的 GitLab CI 自动编译 (La)TeX 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73745571/

相关文章:

git - 是否有可能在 gitlab ci 上仅基于标签推送事件构建?

docker - 将 GitLab 运行程序与 GitLab 连接时出现问题

npm - 如何发布/部署 npm 包到自定义 Artifactory

GIT --- 将所有内容推送到远程服务器,但只有一个日志条目

node.js - Teamcity 运行的 Grunt 无法正确输出到日志

go - 使用 go run code.go 执行 Go 程序以供实际使用是最佳实践吗?

GitHub - 使用远程服务器设置自动部署

git - 当 git 存储库有多个远程仓库时,如何保护提交者的身份?

Git 存储在本地或 git 存储库中

gitlab - 在推送到 GitLab 期间,如何在提交消息中要求票号?