我目前正在尝试使用 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/