5

I have a markdown document with the ⚠ (U+26A0) symbol in it.

I'm using pandoc 2.11.3.1 on Ubuntu 18.04 as this:

pandoc -f markdown -t pdf -H preamble.tex -c style.css --pdf-engine=xelatex -o file.pdf file.md

Here is the man explaining the options: https://pandoc.org/MANUAL.html

The file preamble.tex contains the following:

\usepackage[french]{babel}

And I encounter this error:

[WARNING] Missing character: There is no ⚠ (U+26A0) in font [lmroman10-regular]:mapping=tex-text;!

I know that I can use \danger from the fourier package, and it actually works, but I need to generate both an HTML5 page (in that case, the \danger is obviously not recognized) out of the markdown document and a PDF file, without touching the markdown content itself each time I have to switch the output formats.

How could I use the direct ⚠ symbol so that it is actually rendered in my pdf using pandoc with --pdf-engine=xelatex? Is there any font with this symbol included?

Notice: if I omit the --pdf-engine=xelatex option, this is the error:

Error producing PDF.
! Package inputenc Error: Unicode char ⚠ (U+26A0)
(inputenc)                not set up for use with LaTeX.

See the inputenc package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.1 ⚠

Try running pandoc with --pdf-engine=xelatex.

Here is the content of file.md:

# Chapter 1    

Hello World ⚠ !
3
  • As the error message states, the glyph is not present in the font you are using. Find a font where it is present and this error will no longer occur. Dec 29, 2020 at 18:28
  • I might be wrong, but I think I found the glyph in Roboto (not sure) and DejaVu Sans (also not sure) when I needed it. Dec 29, 2020 at 18:29
  • Correction: found it in the STIX Two Math font, hence had to use it in math mode only. Dec 29, 2020 at 18:34

1 Answer 1

6

Is there a particular reason for you to use XeLaTeX? If your document can compile with LuaLaTeX, then this can work (--pdf-engine=lualatex).

  1. Install Noto Color Emoji on your system.
  2. Modify your preamble.tex as follows:
\usepackage[french]{babel}
\usepackage{fontspec}
\directlua{luaotfload.add_fallback
   ("emojifallback",
    {
      "NotoColorEmoji:mode=harf;"
    }
   )}

\setmainfont{TeX Gyre Termes}[
  RawFeature={fallback=emojifallback}
]
  1. Compile

This gives: enter image description here

As @ChristophFrings points out, the glyph is present in Dejavu Sans. Therefore, you can change your preamble to (and compile with XeLaTeX/LuaLaTeX)

\usepackage[french]{babel}
\usepackage{fontspec}
\setmainfont{DejaVu Sans}

which gives: enter image description here

You must log in to answer this question.

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