10

I'd like to convert markdown text like:

This is a smile 

To a PDF with the emoji on it. To be clear, I want to be able to insert the emoji character itself in the source text, not something like :smile:.

How can I do this with Pandoc?

agentofuser
  • 7,247
  • 11
  • 38
  • 34

2 Answers2

4

After initially having read the OP too superficially (overlooking his need to NOT use :smile: & friends in his source Markdown), here is a better answer. Try one of these:

pandoc my.markdown -o emoji.pdf --pdf-engine=lualatex -V mainfont="DejaVu Sans"
pandoc my.markdown -o emoji.pdf --pdf-engine=xelatex  -V mainfont="DejaVu Sans"

If you use the default pdf-engine (pdflatex), you'll not succeed, but get an error like

 ! Package inputenc Error: Unicode character  (U+1F600)
 (inputenc)                not set up for use with LaTeX.

If you do not specify the mainfonts mainfont param, you'll get an warning message of

 [WARNING] Missing character: There is no  (U+1F604) in font [lmroman10-regular]:+tlig;

for XeLaTeX and of

 [WARNING] Missing character: There is no  in font [lmroman10-regular]:mapping=tex-text;!

Update

Thanks to @jpnadas for noticing a typo in my answer. The parameter should be -V mainfont=... (not -V mainfonts!).

I leave it to the reader(s) to test the correct commands and look at their results:

pandoc -o emoji.pdf --pdf-engine=lualatex -V mainfont="DejaVu Sans"
pandoc -o emoji.pdf --pdf-engine=xelatex  -V mainfont="DejaVu Sans"
Kurt Pfeifle
  • 12,411
  • 2
  • 54
  • 71
  • 2
    I think there is a typo in your answer, shouldn't the parameter be `mainfont`, as in `-V mainfont="DejaVu Sans"`? – jpnadas Oct 07 '19 at 10:20
  • 1
    @jpnadas: You are right. Thanks for noticing. I'll fix it. – Kurt Pfeifle Oct 07 '19 at 13:45
  • 3
    Is there another font I could try? I'm using MacTex 2019 Distribution on a Mac. I just get an error with xelatex: "kpathsea:make_tex: Invalid filename `DejaVu Sans', contains ' '" and "! Package fontspec Error: The font "DejaVu Sans" cannot be found." With lualatex I'm getting the warning message you list above: "[WARNING] Missing character: There is no (U+1F316) (U+1F316) in font DejaVuSans:mode=node;scrip". I see that the space was removed. Not sure what did that. I specified the font as "DejaVu Sans" – Michael Welch Mar 10 '20 at 20:58
  • 2022, pandoc respond with `! Package fontspec Error: The font "DejaVu Sans" cannot be found.`. Any idea's to fix? – Mar Tin Aug 09 '22 at 07:38
0

Try replacing the :smile: with HTML like so:

This is a smile <img src="https://github.com/images/icons/emoji/unicode/1f604.png"/>
Reincoder
  • 3
  • 3
Adam J Limbert
  • 266
  • 2
  • 4
  • 17
  • 1
    Thing is I have sources with literal emoji already and I'm specifically trying to not have to replace them with anything, but have the unicode characters be properly rendered directly. – agentofuser Oct 22 '18 at 23:36