11

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?

2 Answers 2

5

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"
4
  • 2
    I think there is a typo in your answer, shouldn't the parameter be mainfont, as in -V mainfont="DejaVu Sans"?
    – jpnadas
    Commented Oct 7, 2019 at 10:20
  • 1
    @jpnadas: You are right. Thanks for noticing. I'll fix it. Commented Oct 7, 2019 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" Commented Mar 10, 2020 at 20:58
  • 2022, pandoc respond with ! Package fontspec Error: The font "DejaVu Sans" cannot be found.. Any idea's to fix?
    – Mar Tin
    Commented Aug 9, 2022 at 7: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"/>
1
  • 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. Commented Oct 22, 2018 at 23:36

You must log in to answer this question.

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