4

I'm trying to highlight a couple of keywords which contain non-ASCII characters using the listingsutf8 package. This is the relevant part of my document:

\usepackage[brazilian]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage{listingsutf8}
\lstset{
    extendedchars=true,
    inputencoding=utf8x,
    keywords={Funcionalidade, Para, Como, Eu, Contexto, Cenário, Dado, Quando, Então},
    literate=%
{á}{{\'a}}1
{ã}{{\~a}}1
{ç}{{\c{c}}}1
{é}{{\'e}}1
{ê}{{\^e}}1
{õ}{{\~o}}1
{ó}{{\'o}}1
}

The ASCII only keywords are being highlighted correctly, but the Cenário and Então keywords are not. I have also tried with emph and changing inputencoding, but it doesn't work either:

\lstset{
    inputencoding=utf8/latin1,
    emph={Cenário, Cen\'ario, Cenario},emphstyle={\bfseries}
}

If it's relevant, the listing I'm trying to highlight comes from a separate file, using the \lstinputlisting command. If I had to guess, I would say that it has something to do with the literate params.

lockstep
  • 250,273
  • 1
    The highlight for Cenário will work just fine if you use XeLaTeX -- if it's suitable for your workflow, that is. – imnothere Dec 09 '11 at 15:53
  • The detection of keywords in listings doesn't work well with UTF-8 encoded files. With latin1 encoding, specifying Cenário as keyword does what you want. Please, try providing a minimal example. – egreg Dec 09 '11 at 16:23
  • Unfortunately, I cannot use XeLaTeX right now. I have updated the question with a more concrete example. – Tomas Mattia Dec 10 '11 at 20:26

1 Answers1

2

Try the listingsutf8 package from the oberdiek bundle. It offers a workaround exactly for the \lstinputlisting command.