0

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.

joharr
  • 403
  • 4
  • 12

1 Answers1

1

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
mb21
  • 34,845
  • 8
  • 116
  • 142
  • No, I've just checked my [default.latex](https://github.com/harriott/pandoc-templates/blob/master/default.latex) and code you refer to is (as I thought) exactly as jgm's. In addition, as I stated in the comment to my `LaTeX` code above, `XeLaTeX` only succeeds on `\section{2\euro{}}` if `eurosym` has been called. – joharr May 17 '17 at 19:13
  • mb1 is correct. Your code is different from the default, which wraps the entire conditional in another conditional (see lines 17 and 21 of the [default](https://github.com/jgm/pandoc-templates/blob/master/default.latex) template) – Sergio Correia May 17 '17 at 20:19
  • try outputting to tex with `pandoc -s -t latex -o output.tex` and debug from there. I cannot reproduce your problem with `XeTeX 3.14159265-2.6-0.99996 (TeX Live 2016)` on macOS... – mb21 May 18 '17 at 06:42
  • @SergioCorreia, concerned by your comment that I'd goofed, I've just rechecked and, you're wrong, my `\ifnum ... \fi` clause is, as I stated **unchanged** from jgm's (in fact from his line 2 to line 103 I'm identical), but to be doubly sure, I've just now tried to pandoc with jgm's `default.latex`, and the problem remains. So, my template is good - it's something else going wrong here. – joharr May 31 '17 at 18:24
  • @mb1, following your May 18 suggestion, I reverted to jgm's `default.latex` & `pandoc -s eurosym.md -o eurosym.tex` got me a [standalone eurosym.tex](https://gist.github.com/harriott/b33e254e8118e0c4679f6b06fbe6d3b6) for which `xelatex eurosym` fails exactly as above (... ...) - on my Windows 10 MiKTeX installation **and** on my Arch Linux Tex Live 2016.41290-10 installation! – joharr May 31 '17 at 20:44
  • 1
    I tried to replicate it on my side but couldn't. One idea for debugging is to output it as text `-o eurosym.tex --latex-engine=xelatex --standalone` and then run xelatex on the tex file. You should notice the ` \newcommand{\euro}{€}` line as that's the first point of failure. Then, remove chunks of the tex file until you end up with something as small as possible, as in your first example. Also, try updating miktex just in case. – Sergio Correia Jun 02 '17 at 00:13