Use Pandoc's LaTeX image with LuaLaTeX and TeX Gyre Fonts

Skip to first unread message

Vincent Tam

Nov 14, 2020, 1:05:28 PM11/14/20
to pandoc-discuss
I wonder if there's a way to use pandoc's LaTeX image with LuaLaTeX and TeX Gyre Fonts.

I tried setting up this Dockerfile:
FROM pandoc/latex:

RUN apk add --no-cache \
    chromium \
    nss \
    freetype \
    freetype-dev \
    harfbuzz \
    ca-certificates \
    ttf-freefont \
    nodejs \
    yarn \

# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
    PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser \

# Add user so we don't need --no-sandbox.
RUN addgroup -S pptruser && adduser -S -g pptruser pptruser \
    && mkdir -p /home/pptruser \
    && chown -R pptruser:pptruser /home/pptruser \
    && chown -R pptruser:pptruser /data

# Puppeteer v5.1.0 works with Chromium 84.
RUN yarn add eslint puppeteer mermaid-filter

# Install Tex Gyre Termes font
RUN tlmgr install tex-gyre tex-gyre-math

# Install Noto Color Emoji
RUN mkdir -p /usr/share/fonts/truetype/noto \
    && cd /usr/share/fonts/truetype/noto \
    && fc-cache -fv

# Run everything after as non-privileged user.
USER pptruser
WORKDIR /home/pptruser
COPY src/puppeteerConfigFile.json /home/pptruser/.puppeteer.json

When I want to use compile a markdown file to PDF with LuaLaTeX as the PDF engine with mainfont: TeX Gyre Termes at the top, I got the following error.

This is LuaHBTeX, Version 1.12.0 (TeX Live 2020) 
 restricted system commands enabled.
LaTeX2e <2020-10-01> patch level 2

luaotfload | load : FATAL ERROR
luaotfload | load :   × Failed to load "fontloader" module "basics-gen".
luaotfload | load :   × Error message:
luaotfload | load :     × "...dir/texmf-dist/tex/luatex/luaotfload/luaotfload-init.lua:306: system : no writeable cache path, quiting".

stack traceback:
...dir/texmf-dist/tex/luatex/luaotfload/luaotfload-main.lua:174: in local 'load_fontloader_module'
...dir/texmf-dist/tex/luatex/luaotfload/luaotfload-init.lua:308: in upvalue 'init_main'
...dir/texmf-dist/tex/luatex/luaotfload/luaotfload-init.lua:560: in function 'luaotfload-init.lua'
...dir/texmf-dist/tex/luatex/luaotfload/luaotfload-main.lua:298: in field 'main'
[\directlua]:1: in main chunk

...dir/texmf-dist/tex/luatex/luaotfload/luaotfload-init.lua:306: system : no wr
iteable cache path, quiting
stack traceback:
[C]: in function 'error'
...dir/texmf-dist/tex/luatex/luaotfload/luaotfload-init.lua:306: in function '
...dir/texmf-dist/tex/luatex/luaotfload/luaotfload-main.lua:177: in local 'loa
...dir/texmf-dist/tex/luatex/luaotfload/luaotfload-init.lua:308: in upvalue 'i
...dir/texmf-dist/tex/luatex/luaotfload/luaotfload-init.lua:560: in function '
...dir/texmf-dist/tex/luatex/luaotfload/luaotfload-main.lua:298: in field 'mai
[\directlua]:1: in main chunk.
<everyjob> ...ring \\def\string \\encodingdefault{OT1}')end }
                                                  \let \f@encoding \encoding...

  % Options for packages loaded elsewhere

I tried searching for a way to fix this, but I couldn't find a successful example.

In pandoc's LaTeX image, TeXLive 2020 is installed under /opt/texlive/, whose write access requires root privileges.  I wonder if there's a way to use TeX Gyre * fonts with LuaLaTeX as the PDF engine.

Nov 14, 2020, 1:24:10 PM11/14/20
to pandoc-discuss
I think you should better ask on TeX Stack Exchange. This looks like pretty low-level issue on lualatex side.

Dne sobota 14. listopadu 2020 v 19:05:28 UTC+1 uživatel Vincent Tam napsal:

Vincent Tam

Nov 15, 2020, 6:23:54 PM11/15/20
to pandoc-discuss
Thanks for response.  I did type it once on TeX.SE, and after that, I had found the solution that I implemented at commit VincentTam/pandoc-mermaid-docker@d86343f0.  In short, adding

chmod o+w /opt/texlive/texdir/texmf-var

resolves the problem.
Reply all
Reply to author
0 new messages