Emoji don't knit to PDF

Viewed 1005

If I run cat("\U001F615") on the command line in RStudio on my Mac, it shows the emoji. But if I knit it (Rmd) into a pdf, I get this error message:

! Package inputenc Error: Unicode char \u8: not set up for use with LaTeX.

See the inputenc package documentation for explanation. Type H for immediate help. ...

l.144 \end{verbatim}

Try running pandoc with --latex-engine=xelatex. pandoc:

Error producing PDF Error: pandoc document conversion failed with error 43 Execution halted

But if I do latex_engine: xelatex, I don't get an error message, but the knitted pdf still doesn't show the emoji. Can someone help me in how I can knit to PDF with Emoji displaying?

1 Answers

There is a LaTeX package that adds support for emoji here: https://github.com/alecjacobson/coloremoji.sty

I haven't had any luck installing it though, because it's not on CTAN yet and I'm a LaTeX noob!

Once it's installed, you can add something like this to your YAML header:

---
title: "Title"
author: "Me"
header-includes:
   - \usepackage{coloremoji}
output:
    pdf_document
---
Related