Using Emojis in LaTeX

Kaushik Amar Das
3 min readJul 8, 2020

Introduction

I came across a problem while trying to use emojis in LaTeX, specifically in Overleaf. I was writing a paper on detecting hate speech in social media and wanted to give some examples of social media posts. But these examples contained emojis which wouldn’t render.

For instance, if I were to type “I am having a good day!😃😊” in Overleaf’s LaTeX editor, it would show up as “I am having a good day!����”. This is not what we want.

Some answers over StackOverFlow recommend using `LuaLaTeX` or `XeLaTeX`. If switching over to LuaLatex is no issue for you, then you can use HarfBuzz for color emojis in overleaf. Another option is to use “Noto Color Emoji” as mentioned in this answer. You might also try the colormoji latex package.

Using Images as Emojis

Sadly the above did not work for me. Also, changing the compiler might not be possible for people like myself who use styles that are incompatible with other compilers. So the simplest solution is to just use images in place of the emojis. So I will just share that with you.

Step 1

First, we need an emoji resource package which contains the image files for the emojis. You can use any. I will list two below.

  1. Complete Emoji Collection DeviantArt by Dabolus. It is the most up-to-date emojis collection (in PNG) I am currently aware of at the time of writing this article.
  2. Colormoji GitHub repo includes most emojis in PDF format. It is not updated with the latest emojis. But it might just be enough for your needs.

Most of these packages contain the emojis files with their Unicode names for example, `u1F60A.png`. You can use the Official Unicode Chart to find the right emoji’s Unicode name and find the emoji you want.

Step 2

Once you have your emoji resources, its time to put it into LaTeX. Thankfully, it is really simple to use images in latex. You just need to create a new command that puts to use in place of the emoji that you want. In the snippet below I create a command \emojismile for using the smiling face emoji. The command utilizes the scalerel and xparse package.

Alternatively, you can also just use \includegraphics, just remember to scale accordingly.

Creating a command for an emoji image

Now I can just invoke it to use the emoji. As apparant, both of the methods have slightly different results.

Conclusion

In this article, we saw how to use emojis in LaTeX. We switched emojis with their images. Sadly, this method is tedious as you need to create a new command for each emoji that you want to use. So if anyone has a better way, please let me know.

--

--

Kaushik Amar Das

Tech R&D Senior Analyst at Accenture Labs, Bangalore