2

I’m using Pandoc for an initial conversion of Markdown files into LaTex. I have two questions:

  1. I use UTF-8 in all my documents without any issues, and can output PDFs from LaTeX with either/both UTF-8 and escaped characters (see example input and output below). Is there any reason to use escaped characters in my LaTex source text when the equivalent UTF-8 characters above appear fine in the output?

  2. When generating LaTeX, Pandoc converts all the UTF-8 characters in my Markdown to LaTeX escapes. I've tried the standalone -s flag to no avail. If anyone else using Pandoc Markdown to LaTeX conversions knows a way to prevent this, I'd be grateful (but see update below).

I'd like this test input to remain unconverted in the .text output file:

Some UTF-8 ‘characters’ in “this document” are ellipsis… plus—emdash—and en–dash.

but the Pandoc output gives me:

Some UTF-8 `characters' in ``this document'' are ellipsis\ldots{} plus---emdash---and en--dash.

UPDATE: the Pandoc -smart extension handles everything except , which still generates \ldots{}:

Some UTF-8 ‘characters’ in “this document” are ellipsis\ldots{} plus—emdash—and en–dash.
9
  • 2
    doesn't make a lot of difference to latex. essentially if you are using pdflatex the unicode character will expand to the classic ascii markup, and if you are using lulatex or xelatex the classic ascii markup will expand to the unicode character, so either way they end up being the same. Nov 5, 2021 at 22:16
  • 1
    @DavidCarlisle "if you are using lulatex or xelatex the classic ascii markup will expand to the unicode character" ... isn't that only if unicode-math or similar is used?
    – user202729
    Nov 6, 2021 at 2:48
  • 2
    @user202729 No, in LuaLaTeX Unicode based text handling and OpenType fonts are enabled by default, only maths use the legacy system unless unicode-math get loaded. Nov 6, 2021 at 3:05
  • 2
    It's worth noting that in some fonts the sequence …. (ellipsis plus period) has uneven spacing while \ldots. will have even spacing (unless of course, LaTeX is being clever and replaces \ldots with .
    – Don Hosek
    Nov 6, 2021 at 6:37
  • 1
    @DonHosek \DeclareRobustCommand{\dots}{% \ifmmode\mathellipsis\else\textellipsis\fi} \DeclareTextSymbol{\textellipsis} \UnicodeEncodingName{"2026} Nov 6, 2021 at 7:56

1 Answer 1

1

It doesn't make a lot of difference to latex.

Essentially if you are using pdflatex the unicode character will expand to the classic ascii markup, and if you are using lulatex or xelatex the classic ascii markup will expand to the unicode character, so either way they end up being the same.

Of course not all commands in latex expand to Unicode characters but you can look at the list in tex/latex/base/tuenc.def which shows around 500 commands for accents and composites that are defined by default, for example: \c{c} ends up as ç with lualatex because of

 \DeclareUnicodeComposite{\c}             {c}{"00E7}

Conversely not all of unicode is mapped to commands in pdflatex, but most of the common European accents are, and you can add more as needed. ç expands to \c{c} in pdflatex because of the definition in utf8enc.dfu

\DeclareUnicodeCharacter{00E7}{\c c}
1

You must log in to answer this question.

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