pandoc convert to pdf fails when € is in a header

493 Views Asked by At

Windows 10 \euro in LaTeX

I have MiKTeX 2.9.6300 64-bit, and I can xelatex eurosym where eurosym.tex contains the following LaTeX code:

\documentclass{article}

\usepackage{eurosym}

\begin{document}

\section{2\euro{}}    % (this line fails if eurosym package isn't called)

2€    % (this € symbol is lost if compiled with pdflatex instead of xelatex)

\end{document}

- output is as expected:

Pandoc on Win10 eurosym call fails

My local copy of pandoc-templates/default.latex correctly contains the call:

$if(euro)$
  \usepackage{eurosym}
$endif$

And I have pandoc v1.19.2.1 installed, so I would expect pandoc eurosym.md -o eurosym.pdf --latex-engine=xelatex to work when eurosym.md contains just:

# 2€
2€

- but in fact I get:

! Improper alphabetic constant.
<to be read again>
                   \euro
l.70 \section{2\euro{}}

pandoc.exe: Error producing PDF

- why is the command \euro{} failing here in Pandoc?

same with Pandoc on Arch Linux

pandoc 1.19.2.1-90, calling texlive-bin 2016.41290-12, and using jgm's default.latex I get:

! Improper alphabetic constant.
<to be read again>
                   \euro
l.35 \section{2\euro{}}

pandoc: Error producing PDF

But I can get it to work as expected by commenting out line 76, \usepackage[unicode=true]{hyperref} (and then lines 80-98 and line 253, both \hypersetup{...} clauses, and line 99, \urlstyle{same} which require hyperref) of jgm's default.latex.

Discovering that there is a more current default.latex, I tried with that one, and Pandoc failed on \euro again.

Conclusion appear to be that somehow eurosym & hyperref are mutually incompatible in Pandoc

So I've created a New Issue: eurosym in Pandoc seems to be incompatible with hyperref #3801.

1

There are 1 best solutions below

6
On

You must use \usepackage{eurosym} only with pdflatex. XeLaTeX is unicode-aware and you can just use the euro symbol directly.

The default pandoc template therefore wraps is in a an "if pdftex", which you might have missed when modifying your template:

\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex

...

$if(euro)$
  \usepackage{eurosym}
$endif$
...

\fi