I am currently attempting to build PDF files automatically with GitLab CI. Based on this I got the basic thing running, however, pdflatex is not able to find my included figures/images:
! 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.'
My .gitlab-ci.yml looks like this:
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
and my makefile looks like this:
# 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
Both based on this repo. How do I add the images and figures correctly? In all tutorials I found, that use Figures (like this), it just worked. Or I am missing something?
Thanks!
CodePudding user response:
I found the ctornau/latex
Docker Image to work out of the box.
I have a little template Repo set up at https://gitlab.com/WaldemarLehner/latex-starter
The built PDF can be found at https://waldemarlehner.gitlab.io/latex-starter
And here's my 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