Search code examples
dockerlatexpandocalpine-linux

Docker Alpine Latext texmf-dist styles not found


I'm attempting to add some necessary latext style files to the pandoc/latex docker container (which itself is built over Alpine) and the underlying latex to pdf conversion does is unable to find some of the style files I've added. Here's my Dockerfile, which adds the packages I need.

FROM pandoc/latex:latest
RUN apk --no-cache add texlive-xetex texmf-dist-pictures texmf-dist-latexextra poppler-utils && texhash

I can see that the style file I need is installed.

$ docker run --rm -it --entrypoint /bin/sh -v $PWD:/data mypandoc:latest 
/data # find / -name tikzpagenodes.sty
/usr/share/texmf-dist/tex/latex/tikzpagenodes/tikzpagenodes.sty

But, when I try to do the actual build, I get the following error.

Error producing PDF.
! LaTeX Error: File `tikzpagenodes.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name: 
! Emergency stop.
<read *> 
         
l.103 \usepackage

I had hoped that the call to texhash in the container build would fix this, but it did not. Is there some trick to getting the texmf-dist directories into the search path? The problem appears to be with all of the styles I've added from texmf-dist, not just this one. Thanks.


Solution

  • Use the tlmgr from TeXLive to install more packages. The pandoc/latex Docker container does not use the TeX installation from Alpine in order to give users more flexibility and to reduce image size – the Alpine packages are far less fine-grained.

    Usually, one will add the following to the Dockerfile

    # Install additional LaTeX packages
    RUN tlmgr update --self && tlmgr install \
      pgf # <list of packages goes here>
    

    Alternatively, you could use the pandoc/core image and build your own LaTeX container using the Alpine system packages.