关键词 algorithm2e 翻译

关键词 algorithm2e 翻译

我想使用algorithm2e翻译关键字选项(例如frenchkw),它应该按照文档说明工作,但它对我来说没有任何作用。

\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}

结果,请注意算法标题是如何正确翻译的,但关键字却没有。

在此处输入图片描述

答案1

您必须指定仅使用onelanguage此功能才能工作:

在此处输入图片描述

\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}

尽管algorithm2e确实提供了使用不同语言的选项,而无需onelanguage用户为这些语言指定不同的输入。因此,人们需要使用-定义,而不是\KwData- /default 定义。english\Donneesfrench

\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}

相关内容