0

EDIT1

I have a markdown with inline code with curly quotes and I use pandoc to generate a PDF.

The markdown is

Fancy Unicode quotes inlined `“”`.

The resulting latex is :

Fancy Unicode quotes inlined \lstinline!“”!.

xelatex fails to build the PDF.

Is it a normal behavior ?

EDIT2

First of all, thanks for you response. I should have mentioned that I am quite new with latex. I may write some wrong statement.

I use pandoc to convert my markdown into PDF with xelatex with the command pandoc FOO.md -o FOO.pdf --listings --latex-engine xelatex

I do not think listing does not handle unicode because the following markdown is working.

```bash
FOO=“”
```

The corresponding latex is:

\begin{lstlisting}[language=bash]
FOO=“”
\end{lstlisting}

EDIT 3

I just tried another test which let me think that this looks like a bug.

The following markdown example fails:

Inline code `“”`

Corresponding latex:

Inline code \lstinline!“”!

Console:

$ pandoc FOO.md -o FOO.pdf --listings --latex-engine xelatex
! File ended while scanning use of \lst@temp.
<inserted text>
                \par
<*> /tmp/tex2pdf.14686/input.tex

No pages of output.
Transcript written on /tmp/tex2pdf.14686/input.log.

pandoc: Error producing PDF

While the following markdown example succeeds:

Inline code `FOO=“”`

Corresponding latex:

Inline code \lstinline!FOO=“”!
2
  • 2
    What's the error you're getting? Can you provide a minimum working example of your file that you're feeding to xelatex?
    – Don Hosek
    Mar 12, 2020 at 15:39
  • 1
    As far as I know listings does not support unicode so it cannot handle those. If those are the only non-ascii you use, then you could add support for it manually using the literal feature, search the site for listings literal
    – daleif
    Mar 12, 2020 at 15:53

1 Answer 1

2

If you want to use chars outside the 0-255 range with listings you have to declare them first:

\documentclass{article}
\usepackage{listings}
\makeatletter %for xelatex:
\lst@InputCatcodes
\def\lst@DefEC{%
 \lst@CCECUse \lst@ProcessLetter
  ^^80^^81^^82^^83^^84^^85^^86^^87^^88^^89^^8a^^8b^^8c^^8d^^8e^^8f%
  ^^90^^91^^92^^93^^94^^95^^96^^97^^98^^99^^9a^^9b^^9c^^9d^^9e^^9f%
  ^^a0^^a1^^a2^^a3^^a4^^a5^^a6^^a7^^a8^^a9^^aa^^ab^^ac^^ad^^ae^^af%
  ^^b0^^b1^^b2^^b3^^b4^^b5^^b6^^b7^^b8^^b9^^ba^^bb^^bc^^bd^^be^^bf%
  ^^c0^^c1^^c2^^c3^^c4^^c5^^c6^^c7^^c8^^c9^^ca^^cb^^cc^^cd^^ce^^cf%
  ^^d0^^d1^^d2^^d3^^d4^^d5^^d6^^d7^^d8^^d9^^da^^db^^dc^^dd^^de^^df%
  ^^e0^^e1^^e2^^e3^^e4^^e5^^e6^^e7^^e8^^e9^^ea^^eb^^ec^^ed^^ee^^ef%
  ^^f0^^f1^^f2^^f3^^f4^^f5^^f6^^f7^^f8^^f9^^fa^^fb^^fc^^fd^^fe^^ff%
  ^^^^201c^^^^201d% quotes for xelatex
  ^^00}
\lst@RestoreCatcodes
\begin{document}
Fancy Unicode quotes inlined \lstinline!“”!.
\end{document}
2
  • Why not using literate? Thanks!
    – manooooh
    Mar 12, 2020 at 17:55
  • 1
    @manooooh presumably in this case it is assumed that xelatex is already using a font that covers the necessary fonts, so you just need the extra chars. Literate will map the char to larex symbol commands
    – daleif
    Mar 13, 2020 at 7:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .