5

I would like to use algorithm2e with translated keywords option (e.g. frenchkw), which should be working according to the documentation, but it doesn't do nothing for me.

\usepackage[vlined, lined, french, frenchkw]{algorithm2e}

\begin{algorithm}[H]
    \KwData{this text}
    \KwResult{how to write algorithm with \LaTeX2e }
    initialization\;
    \While{not at end of this document}{
        read current\;
        \eIf{understand}{
            go to next section\;
            current section becomes this one\;
        }{
        go back to the beginning of current section\;
    }
}
\caption{How to write algorithms}
\end{algorithm}

Result, notice how Algorithm caption is correctly translated, but keywords are not.

enter image description here

1 Answer 1

8

You have to specify that you'll be using only onelanguage for this to work:

enter image description here

\documentclass{article}

\usepackage[vlined, french, onelanguage]{algorithm2e}

\begin{document}

\begin{algorithm}[H]
  \KwData{this text}
  \KwResult{how to write algorithm with \LaTeX2e }
  initialization\;
  \While{not at end of this document}{
    read current\;
    \eIf{understand}{
      go to next section\;
      current section becomes this one\;
    }{
      go back to the beginning of current section\;
    }
  }
  \caption{How to write algorithms}
\end{algorithm}

\end{document}

While algorithm2e does provide options for the use of different languages, without onelanguage it requires the user to specify different inputs for these. So, instead of \KwData - an english/default definition - one would need use \Donnees - the french definition.

\documentclass{article}

\usepackage[vlined, french]{algorithm2e}

\begin{document}

\begin{algorithm}[H]
  \Donnees{this text}
  \Res{how to write algorithm with \LaTeX2e }
  initialization\;
  \Tq{not at end of this document}{
    read current\;
    \eSi{understand}{
      go to next section\;
      current section becomes this one\;
    }{
      go back to the beginning of current section\;
    }
  }
  \caption{How to write algorithms}
\end{algorithm}

\end{document}
1
  • 1
    Thanks! It worked like a charm. Documentation should be more clear about this.
    – Xoyce
    Commented Mar 4, 2017 at 0:11

You must log in to answer this question.

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