6

I am trying to generate PDF documentation out of Pandoc Markdown README document. Here is MWE:

\documentclass[english,]{article}
\usepackage[T1]{fontenc}
\usepackage{ifxetex,ifluatex}

\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[utf8]{inputenc}
\else % if luatex or xelatex
  \ifxetex
    \usepackage{mathspec}
    \usepackage{xltxtra,xunicode}
  \else
    \usepackage{fontspec}
  \fi
\fi

\defaultfontfeatures{Ligatures=TeX}
\setmonofont[Scale=MatchLowercase]{DejaVu Sans Mono}

\begin{document}
\texttt{-{}-enable-debugging}
\end{document}

When I generate a PDF using lualatex (beta-0.76.0-2013070111 (TeX Live 2013/Debian) (rev 4627)) it creates a en-dash instead of typesetting --:

unwanted en-dash picture

The en-dash is unwanted. XeLaTeX does not do that. I want two dashes.

UPDATE

In the end, I have created a patch that makes Pandoc use -\/- instead of -{}- to avoid the ligature.

7
  • 1
    Don't use \defaultfontfeatures{Ligatures=TeX} before declaring the mono font.
    – egreg
    Feb 6, 2014 at 22:34
  • 2
    Note also that inserting {}, i.e., an "empty TeX group", does not work as a ligature-suppressing method under Lua(La)TeX, though it does so under Xe(La)TeX and pdf(La)TeX.
    – Mico
    Feb 6, 2014 at 22:40
  • 2
    So how would you break a single ligature in Lua(La)TeX? That is, if you want ligatures generally but need -- or ff without ligaturing in a particular case?
    – cfr
    Feb 6, 2014 at 23:10
  • @cfr - Under LuaLaTeX, I would suggest loading the selnolig package. Specify either the english or ngerman option to load language-specific selective ligature suppression rules, or provide your own homemade ligature suppression rules -- say, \nolig{--}{-|-} -- to suppress certain ligatures on a document-wide basis. To suppress a single instance of a ligature, one could issue the command \breaklig, e.g., \breaklig{pdf|latex}.
    – Mico
    Feb 6, 2014 at 23:28
  • @Mico Interesting. So there's a solution for English and German but maybe not for other languages. (I don't know if it is an issue in other languages, though. To be honest, I'm not sure of the rules even for English and certainly never use them!)
    – cfr
    Feb 6, 2014 at 23:39

1 Answer 1

5

The error is in declaring

\defaultfontfeatures{Ligatures=TeX}

before loading the mono font. This will add the common TeX ligatures to the normal set, in particular turns -- into an en-dash.


By the way, you shouldn't load either xltxtra or xunicode; xltxtra has some features, but it's quite improbable you really need them. It used to be recommended when fontspec was in its older versions. Now it does the main things xltxtra was used for and also loads xunicode. Since mathspec loads fontspec just that package is sufficient.

Also avoid fontenc for XeLaTeX and LuaLaTeX. Put it in the pdflatex specific part.

3
  • This MWE is derived from Pandoc generated LaTeX document. It adds those bits of its own.
    – wilx
    Feb 6, 2014 at 23:14
  • 2
    @wilx Not the best code, to tell you the truth. Besides, thinking that the same document can be processed with the three engines using that preamble is just a dream: you can't emulate mathspec with LuaTeX and you can't use a document using specific mathspec features with pdflatex.
    – egreg
    Feb 6, 2014 at 23:24
  • Pandoc's conversion is best effort. Feel free to improve Pandoc's LaTeX template.
    – wilx
    Feb 6, 2014 at 23:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.