Wandmalfarbe / pandoc-latex-template

A pandoc LaTeX template to convert markdown files to PDF or LaTeX.
BSD 3-Clause "New" or "Revised" License
6.09k stars 959 forks source link

Error: ! Argument of \strip@prefix has an extra }. #259

Closed mariobaldini closed 2 years ago

mariobaldini commented 2 years ago

Hi,

I am facing the following error while using eisvogel with pandoc in Fedora 34. Any pointers on how could I solve this?

Error:

Error producing PDF.
! Argument of \strip@prefix has an extra }.
<inserted text> 
                \par 
l.6277 ...nglish,usenglish}\contentsname{Contents}

Steps to reproduce: (build from example)

cd pandoc-latex-template/examples/basic-example 
pandoc "document.md" -o "document.pdf" --from markdown --template "../../eisvogel.tex" --listings

Also tried with eisvogel.latex from main or latest release.

Environment:

Fedora 34 Workstation - kernel 5.13.19-200.fc34.x86_64 
pandoc 2.9.2.1
Compiled with pandoc-types 1.20, texmath 0.12.0.2, skylighting 0.8.5
TeX 3.14159265 (TeX Live 2020)
kpathsea version 6.3.2
texlive-koma-script - svn54825 - texlive-2020-39.fc34.src.rpm

Running with verbose:

(...)
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/tocbasic.sty)
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/scrsize11pt.clo)
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/typearea.sty)
! Argument of \strip@prefix has an extra }.
<inserted text> 
                \par 
l.6277 ...nglish,usenglish}\contentsname{Contents}
                                                  %
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on /tmp/tex2pdf.-18de7987545342ac/input.log.

[makePDF] Run #2
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(/tmp/tex2pdf.-18de7987545342ac/input.tex
LaTeX2e <2020-02-02> patch level 5
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/scrartcl.cls
Document Class: scrartcl 2020/04/19 v3.30 KOMA-Script document class (article)
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/scrkbase.sty
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/scrbase.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/scrlfile.sty)))
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/tocbasic.sty)
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/scrsize11pt.clo)
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/typearea.sty)
! Argument of \strip@prefix has an extra }.
<inserted text> 
                \par 
l.6277 ...nglish,usenglish}\contentsname{Contents}
                                                  %
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on /tmp/tex2pdf.-18de7987545342ac/input.log.

Error producing PDF.
! Argument of \strip@prefix has an extra }.
<inserted text> 
                \par 
l.6277 ...nglish,usenglish}\contentsname{Contents}

I would prefer a solution that does not involve changing packages beyond distro version (to avoid break some other project), and that is backwards compatible (avoid breaking the build in other developers machine), if possible.

Thank you

mariobaldini commented 2 years ago

PS:

I consider that eisvogel should build correctly from its examples, that's why I posted the issue here.

But am not sure if it's really an issue with eisvogel or with some other included package?

koma-script maybe? Since the error comes from /usr/share/texlive/texmf-dist/tex/latex/koma-script/typearea.sty

PhilipWhiteside commented 2 years ago

Having the same problem using the example "basic-example".

Error

[makePDF] Run #1
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(/tmp/tex2pdf.-3389cb39ac3a8baf/input.tex
LaTeX2e <2020-02-02> patch level 5
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/scrartcl.cls
Document Class: scrartcl 2020/04/19 v3.30 KOMA-Script document class (article)
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/scrkbase.sty
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/scrbase.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/scrlfile.sty)))
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/tocbasic.sty)
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/scrsize11pt.clo)
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/typearea.sty)
! Argument of \strip@prefix has an extra }.
<inserted text> 
                \par 
l.6277 ...nglish,usenglish}\contentsname{Contents}
                                                  %
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on /tmp/tex2pdf.-3389cb39ac3a8baf/input.log.

Steps to reproduce: (build from example)

pandoc --verbose "basic-example.md" -o "basic-example.pdf" --from markdown --template eisvogel --listings

Environment

OS: Fedora 34 Kernel: Linux x1carbon 5.13.19-200.fc34.x86_64 Pandoc: 2.9.2.1 Eisvogel: 2.0.0 texlive-koma-script.noarch: 9:svn54825-39.fc34 texlive-kpathsea.x86_64: 9:20200327-30.fc34

PhilipWhiteside commented 2 years ago

I have worked around the issue. It is related to a package we have as it worked on Ubuntu. By default Fedora has Podman installed, which is CLI compatible with Docker. I have podman-docker installed which links all Docker commands to Podman (without Docker being installed).

Happy to push the Dockerfile in a PR if maintainers think it would be useful for other users.

Copy this into a file called "Dockerfile" in your working directory.

FROM ubuntu:hirsute

RUN apt-get update

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ="Europe/London"
RUN apt-get install -y tzdata

RUN apt-get install -y pandoc
RUN apt-get install -y texlive-base

RUN apt-get install -y texlive-fonts-recommended
RUN apt-get install -y texlive-fonts-recommended-doc
RUN apt-get install -y texlive-latex-recommended
RUN apt-get install -y texlive-latex-recommended-doc

RUN apt-get install -y texlive-latex-extra
RUN apt-get install -y texlive-fonts-extra

WORKDIR /data 
RUN mkdir /config/
COPY eisvogel.latex /config/

ENTRYPOINT pandoc -o output.pdf --from markdown --template=/config/eisvogel.latex input.md

Copy the template file into your working directory. So you should have this.

x1carbon ➜  workdir ll
total 36K
-rw-r--r--. 1 philip philip 644 Sep 27 22:57 Dockerfile
-rw-r--r--. 1 philip philip 31K Jan 31  2021 eisvogel.latex
x1carbon ➜  

Build the container image

x1carbon ➜  workdir docker build -t eisvogel .
STEP 1/17: FROM ubuntu:hirsute
STEP 2/17: RUN apt-get update
--> Using cache 507b866980a8d426e3c7b4536545b7aae115e6e7363d4932470ad505ae95feed
--> 507b866980a
STEP 3/17: ARG DEBIAN_FRONTEND=noninteractive
--> Using cache e973efa72478f0369eb60b6db90b1b70666ac86835211d0c672e63c122da46be
--> e973efa7247
STEP 4/17: ENV TZ="Europe/London"
--> Using cache e51f498129805940c26d03d2bece4841182f1ee9b47441856be933f4a4cf8e38
--> e51f4981298
STEP 5/17: RUN apt-get install -y tzdata
--> Using cache 97fe3b39116cdec28d58844281a40455cd5fdac6039c0998a4ef8fae9ad6ef75
--> 97fe3b39116
STEP 6/17: RUN apt-get install -y pandoc
--> Using cache 511bd282fafb6332dfac9f7894840751135767dfd5a8863d0afd8e84b2828d91
--> 511bd282faf
STEP 7/17: RUN apt-get install -y texlive-base
--> Using cache a1cedb98209426ba6ef81825cfed0c41c1d3de594e4b89f79fdf4abc0b1d479e
--> a1cedb98209
STEP 8/17: RUN apt-get install -y texlive-fonts-recommended
--> Using cache b7067a71d778f75369b79601a18abe65582d25a7a611ed43d98254464ea67b7e
--> b7067a71d77
STEP 9/17: RUN apt-get install -y texlive-fonts-recommended-doc
--> Using cache 516d49d9451c50e1880d1ebb315652d0700ef812e70ab65178105375b7d4c40d
--> 516d49d9451
STEP 10/17: RUN apt-get install -y texlive-latex-recommended
--> Using cache 8f94fe59fa6de2677c6e5f975ecb9c13f1e92ccb4fa4d5f2eb7ecb20de780952
--> 8f94fe59fa6
STEP 11/17: RUN apt-get install -y texlive-latex-recommended-doc
--> Using cache 0fbba4ffc9b6d014a8a70b754f92dea8f6b8aa29746db5c7b93bd2081f332587
--> 0fbba4ffc9b
STEP 12/17: RUN apt-get install -y texlive-latex-extra
--> Using cache dd1f33c48b3412e7891a243aa593a00e2f68d64d2bee0a93921bb709c4d19ae5
--> dd1f33c48b3
STEP 13/17: RUN apt-get install -y texlive-fonts-extra
--> Using cache 8585fbae1633bd7fb672587c5b224d41e76589ef4b228791a785a4603ac89e9b
--> 8585fbae163
STEP 14/17: WORKDIR /data 
--> Using cache 478fbeab8ba730481372d55549e2729facd808743052e4c7b66684cac414f1ef
--> 478fbeab8ba
STEP 15/17: RUN mkdir /config/
--> Using cache fc438f1f6b95cf5977c7d1fbb097451ba4c18bf057228e5327a923cdd6300083
--> fc438f1f6b9
STEP 16/17: COPY eisvogel.latex /config/
--> Using cache 49fadf1ce6c6dfbdbee1f464799a20dfcd32538a6dd885392616a9c4e12e4c1a
--> 49fadf1ce6c
STEP 17/17: ENTRYPOINT pandoc -o output.pdf --from markdown --template=/config/eisvogel.latex input.md
--> Using cache 991d03a9858e80f714f52356ba5082b8adf17358af6942a0493d5ce3bf46baa7
COMMIT eisvogel
--> 991d03a9858
Successfully tagged localhost/eisvogel:latest
991d03a9858e80f714f52356ba5082b8adf17358af6942a0493d5ce3bf46baa7
x1carbon ➜  

Make a directory to map into the container and copy your markdown file into it with the name input.md

x1carbon ➜  workdir mkdir data
x1carbon ➜  workdir cp ../input.md ./data 
x1carbon ➜  workdir ll data 
total 8.0K
-rw-r--r--. 1 philip philip 6.4K Sep 27 23:01 input.md
x1carbon ➜  

Run the docker container, it will generate output.pdf into the data directory

x1carbon ➜  workdir docker run --rm -v ./data:/data:z localhost/eisvogel 
x1carbon ➜  workdir ll data
total 188K
-rw-r--r--. 1 philip philip 6.4K Sep 27 23:01 input.md
-rw-r--r--. 1 philip philip 177K Sep 27 23:01 output.pdf
x1carbon ➜  workdir 
mariobaldini commented 2 years ago

Thanks @PhilipWhiteside

I confirm that I can build correctly in a Ubuntu VM. Although it is a workaround, it is not a fix itself for the Fedora env and still would like to attempt that (just need some help because currently I'm lost :)

I want to use it inside an automate build system, so adding the whole overhead of docker to the flow is not reasonable.

Also, it appears to be an issue with more recent versions of tex, so eventually it needs to get fixed anyway, because at some point Ubuntu will also update them.

I can build with this packages:

Ubuntu 20.04 LTS
pandoc 2.5
Compiled with pandoc-types 1.17.5.4, texmath 0.11.2.2, skylighting 0.7.7
TeX 3.14159265 (TeX Live 2019/Debian)
kpathsea version 6.3.1

Anyone know exactly what is breaking the build in these newer tex versions?

PhilipWhiteside commented 2 years ago

No problem @mariobaldini

Personally, I think docker is great for build systems, as they are deterministic binaries. GitLab CICD pipelines is all based around containers. Once the image is pushed to DockerHub/GitHub/GitLab registry you don't have to build it ever again and can treat it like a binary.

Either way, best of luck with sorting out the issue.

mariobaldini commented 2 years ago

Sure @PhilipWhiteside, for now I will go with your solution (I guess is the only one).

Eventually it needs to get fixed. Let's see if other devs have any permanent solution. Otherwise the template will only be compatible with older tex.

Wandmalfarbe commented 2 years ago

Personally, I think docker is great for build systems, as they are deterministic binaries. GitLab CICD pipelines is all based around containers. Once the image is pushed to DockerHub/GitHub/GitLab registry you don't have to build it ever again and can treat it like a binary.

That is indeed the only way (as it seems for me) to produce reliable LaTeX builds. Currently, I use Travis CI and install TeX Live from scratch to compile all the example files. This breaks all the time because version management and package management in the LaTeX world are absolutely horrible.

Eventually it needs to get fixed. Let's see if other devs have any permanent solution. Otherwise the template will only be compatible with older tex.

As @PhilipWhiteside has said it: There is likely some package with a specific version that is responsible for the Error. I don't have the time and resources to deal with this kind of problem. My general advice is to install the latest distribution and update all the packages to the latest version. Of course, there may also be a problem in the Eisvogel template itself (including packages in the correct order is very tricky and gives me headaches).

You could also ask the KOMA-Script maintainer for advice. I'm absolutely sure there are tons of errors and antipatterns in the Eisvogel code (because I really don't understand the internals of LaTeX/TeX and only wanted to generate a beautiful PDF with a horrible language)