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?

  • 2
    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. May 9, 2013 at 1:25
  • I get "faça" out of the box.
    – egreg
    May 9, 2013 at 11:00
  • 1
    I also get hacer (algorithm2e 2013/01/06 v5.00). It seems to be version dependent. May 9, 2013 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. May 9, 2013 at 21:33
  • @NicolaTalbot, I get the correct output using ShareLaTeX: the version used there is 3.10, according to the log.
    – latex user
    May 10, 2013 at 18:01

2 Answers 2


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.

  • It worked, they updated the package in 2015 (but I checked again only today lol). There's no more need to add that extra command since version 5.1. Thank you very much.
    – latex user
    Jun 12, 2018 at 15:20

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

You must log in to answer this question.

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