I'm submitting a paper to a journal using LaTeX, and I need to be able to write Unicode symbols into listings. So far, I've been able to get by with the moreverb package. It's listing environment is pretty good in conjunction with the utf8x set on inputenc. However, some symbols, like Σ, just won't work.

Note: I'm using listings because the contents are code-snippets and not traditional math expressions. Here are some minimal examples.

\documentclass[preprint, 11pt]{sigplanconf}

This works:

test = 2 ∈ s

This doesn't work:

sum = Σ(s)

Please help!

  • 3
    First question in such cases is always: can you switch to XeLaTeX/LuaLaTeX or do you have to use pdfLaTeX?
    – Philipp
    Apr 17, 2011 at 14:32

1 Answer 1


Your problem is not really listing related; you’ll get the error outside of a listing as well. The point is that Latex simply does not understand how to display the unicode characters.

With math characters, this would be easy to solve, however, because of the moreverb environment, you cannot use math directly inside the listing. Luckily, the inputenc package gives you a way out. You need to explicitly tell Latex, how it should render unknown utf8 characters.



%% or simply use the newunicodechar package
%% which does the same without the need of remembering numbers:
% \usepackage{newunicodechar}
% \newunicodechar{Σ}{\ensuremath{\Sigma}}
% \newunicodechar{∈}{\ensuremath{\in}}

∈ Σ

test = 2 ∈ s

sum = Σ(s)


Edit: Changed to use \ensuremath instead of $..$

Edit 2: Added code for the newunicodechar package

Note: You are not restricted to use math mode. You may as well change to another font which includes the needed character somewhere and use it directly.

  • 2
    There is also the newunicodechar package; you get the same as with the first \DeclareUnicodeCharacter by saying \newunicodechar{Σ}{\ensuremath{\Sigma}}. This spares the user from searching the code point of the Σ. Disclaimer: I'm the author of the package. :)
    – egreg
    Apr 19, 2011 at 12:28
  • @egreg: Great. I have included the information.
    – Debilski
    Apr 19, 2011 at 14:28

You must log in to answer this question.

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