When I render the following document with xelatex...


\emojifont{The emoji end up in front of the punctuation: \lstinline`<😀,🤔/🎨+`}

I end up with the content of the inline code span looking like 😀🤔🎨<,/+—the Emoji are moved across the punctuation, to the start of the span. This doesn't happen (or at least happens differently) with non-punctuation characters.

The same happens in code listing blocks, and since I have to typeset some programs with emoji in them, this is rather disruptive. Any ideas on why this is happening and whether there's a way to work around it?

Using \texttt instead of \lstinline removes the issue, but I really prefer to keep using listings, since it does several things that I need.

  • 1
  • That means I have to manually add every Unicode character I want to use in my listings in to cryptic list? That's beyond terrible. – Marijn Feb 2 '18 at 22:12
  • That doesn't seem to have been it—even with the extra invocations (with appropriate character codes) shown in that answer, the rearranging still happens. – Marijn Feb 2 '18 at 22:33
  • @Marijn Unless you want a gigantic macro to be executed each time listings is processed… – egreg Feb 3 '18 at 10:34

The method shown in The 'listings' package and UTF-8 works here fine for me too (I had to use another emoji font as I don't have yours installed). I tested both with xelatex and lualatex on a current texlive 2017:

 \lst@CCECUse \lst@ProcessLetter
% ^^^^^1f600^^^^^1f914^^^^^1f3a8%alternative for xelatex, doesn't work in lualatex 


\emojifont{The emoji end up in front of the punctuation: \lstinline`<😀,🤔/🎨+`}

enter image description here

  • I think that in LuaTeX you have to use six hats, with a padding 0 (it should also work in XeTeX). – egreg Feb 3 '18 at 10:21
  • @egreg Yes, thanks David just told me in the chat too, I will correct the example later. – Ulrike Fischer Feb 3 '18 at 10:43
  • Thank you, it really does work (not sure what I did wrong when testing). I'm still sad to have to include a hack like this to get basic Unicode support, but I can automate the extraction of characters used so I guess I'll survive. – Marijn Feb 3 '18 at 20:59
  • As egreg already commented: Do you really expect listings to add support for over 100.000 symbols by default? And even if it would extend the range of supported symbols why on earth should it add emojis? – Ulrike Fischer Feb 3 '18 at 23:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.