TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this little algorithm with two For statements and one if-else. I'm using the option portuguese on the preamble and here's the problem: instead of displaying the words "faça" and "fim" (do and end, respectively), I get "hacer" and "fin".

Here's my preamble:


And here's the code:

\Dados{audio, tamanho, nivel, filtro, ch}
\Entrada{i, j, inicio, comprimento}
$inicio \leftarrow 0$\;
  $comprimento \leftarrow tamanho$\;
\Para{$i \leftarrow 0$ \Ate $i<nivel$}{
    $inicio \leftarrow 0$\;
$comprimento \leftarrow tamanho/2^{i-1}$\;
\Para{$j \leftarrow 0$ \Ate $j<2^{i-1}$}{
        \eSe{j é par}{
                transformada\_wavelet(audio[inicio],comprimento, 1,'n', filtro, ch)\;
                transformada\_wavelet(audio[inicio],comprimento, 1,'i', filtro, ch)\;
\caption{A DWT-packet}

The result (i'm using pdfLaTeX on Windows):

para i ← 0 até i < nível hacer
para j ← 0 até j < 2^(i-1) hacer

If I put \SetKwFor{Para}{para}{fa\c{c}a}{fim para} on the TeX file, I get the right output. But this command is on the package already. Why doesn't it work?

share|improve this question
Hi Luan, welcome to TeX.SX! :) Interesting question. I suspect something related to the later expansion of \Para, since both spanish and portuguese share the same macro name for it. – Paulo Cereda May 9 '13 at 1:25
I get "faça" out of the box. – egreg May 9 '13 at 11:00
I also get hacer (algorithm2e 2013/01/06 v5.00). It seems to be version dependent. – Nicola Talbot May 9 '13 at 20:02
I checked and my system is using an old version: Package `algorithm2e' Release 4.01 -- december 14 2009, and I do not get hacer with the old version. – Sergio Parreiras May 9 '13 at 21:33
@NicolaTalbot, I get the correct output using ShareLaTeX: the version used there is 3.10, according to the log. – Luan Resende May 10 '13 at 18:01

This is a nasty bug in algorithm2e. The setting of the "localized keywords" is not language dependent and the same keyword Para is defined for Portuguese and Spanish. The latter has been added in the last revision of the package and

\SetKwFor{Para}{para}{hacer}{fin para}

appears later than the similar definition in the Portuguese section, thus overriding it.

Solving such a bug requires a different treatment of keywords, that keeps track of the language option, which presently the package doesn't do.

The only solution is what you found: issuing

\SetKwFor{Para}{para}{fa\c{c}a}{fim para}

after loading algorithm2e.

Please, mention this to the package author.

share|improve this answer

Try to use an old version of the package. With algorithm2e Release4.01, december 14, 2009, I do not have this problem as you can see:

LaTeX output

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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