Rendering PDF from Markdown file with literal emoji characters using Pandoc
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?
Solution 1:
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"