algorithm2e 有西班牙语版本吗?

algorithm2e 有西班牙语版本吗?

我正在尝试使用西班牙语选项从 TEX.SX 中的另一篇文章中复制此代码,但有些单词出现了英文,例如 WHILE、FOR、... IF、...

可以把这些改成西班牙语吗?

\documentclass[12pt,a4paper,x11names]{article}
%\renewcommand{\baselinestretch}{1.5} % interlineado de 1.5de la normativa del TFG  no usamos esto para poder usar el setspace y que el interlineado no afecte a las notas a íé de página.
\usepackage[top=2.5cm, left=3.5cm, bottom=2.5cm, right=2.5cm]{geometry}  % Margenes de la normativa TFG

\usepackage{setspace} 

\usepackage{lipsum,mwe}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish]{babel}
\usepackage{mathtools,amsmath,amsfonts,amssymb,latexsym}
\usepackage{eurosym}
\usepackage{graphicx}

\usepackage[ruled,vlined,lined,linesnumbered,spanish]{algorithm2e}

\begin{document}
\begin{algorithm}[H]
    \caption{Algoritmo del Enfiramiento Simulado}

    \KwData{la liste $L$ des naturels compris de $2$ à $N$.}
    \KwResult{la liste $P$ des nombres premiers compris entre $2$ et $N$.}
    \BlankLine
    \For{$i = 2$ \KwTo $N$}{
    \If{$i$ n'est pas barré dans la liste $L$}{
        Barrer dans la liste $L$ les mutltiples $ki$ où $k \geq 2$.
    }
    }
    \Return{la liste $P$ des nombres non barrés.}
\end{algorithm}

%\begin{algorithm}[h]
%\SetLine
%\linesnumbered
%\KwData{$\{ T_0,T_1,...,T_{imax}=T_{final}\}$}
%\end{algorithm}
\end{document}

答案1

恐怕开箱即用不支持西班牙语。

这是您应该重新定义的内容;我保留包中的葡萄牙语翻译,以便西班牙人可以进行调整(我将其标记为社区 Wiki)。

\makeatletter
%%% this is from the \DeclareOptions part
\renewcommand{\listalgorithmcfname}{Lista de Algoritmos}%
\renewcommand{\algorithmcfname}{Algoritmo}%
\renewcommand{\algorithmautorefname}{algoritmo}%
\renewcommand{\algorithmcflinename}{linha}%
\renewcommand{\algocf@typo}{}%
\renewcommand{\@algocf@procname}{Procedimento}%
\renewcommand{\@algocf@funcname}{Fun\c{c}\~{a}o}%
\renewcommand{\procedureautorefname}{procedimento}%
\renewcommand{\functionautorefname}{fun\c{c}\~{a}o}%
\renewcommand{\algocf@languagechoosen}{portuguese}%
%%% this is from the switches further in the package
\SetKwInput{KwIn}{Entrada}%
\SetKwInput{KwOut}{Sa\'{i}da}%
\SetKwInput{KwData}{Dados}%
\SetKwInput{KwResult}{Resultado}%
\SetKw{KwTo}{at\'{e}}
\SetKw{KwRet}{retorna}%
\SetKw{Return}{retorna}%
\SetKwBlock{Begin}{in\'{i}cio}{fim}%
\SetKwRepeat{Repeat}{repita}{at\'{e}}%
%
\SetKwIF{If}{ElseIf}{Else}{se}{ent\~{a}o}{sen\~{a}o se}{sen\~{a}o}{fim se}%
\SetKwSwitch{Switch}{Case}{Other}{selecione}{fa\c{c}a}{caso}{sen\~{a}o}{fim selec}%
\SetKwFor{For}{para}{fa\c{c}a}{fim para}%
\SetKwFor{ForPar}{para}{fa\c{c}a em paralelo}{fim para}
\SetKwFor{ForEach}{para cada}{fa\c{c}a}{fim para cada}%
\SetKwFor{ForAll}{para todo}{fa\c{c}a}{fim para todo}%
\SetKwFor{While}{enquanto}{fa\c{c}a}{fim enqto}%
\makeatother

为了参考,我还添加了英文翻译

%%% this is from the \DeclareOptions part
\renewcommand{\listalgorithmcfname}{List of Algorithms}%
\renewcommand{\algorithmcfname}{Algorithm}%
\renewcommand{\algorithmautorefname}{algorithm}%
\renewcommand{\algorithmcflinename}{line}%
\renewcommand{\algocf@typo}{}%
\renewcommand{\@algocf@procname}{Procedure}%
\renewcommand{\@algocf@funcname}{Function}%
\renewcommand{\procedureautorefname}{procedure}%
\renewcommand{\functionautorefname}{function}%
\renewcommand{\algocf@languagechoosen}{english}%
%%% this is from the switches further in the package
\SetKwInput{KwIn}{Input}%
\SetKwInput{KwOut}{Output}%
\SetKwInput{KwData}{Data}%
\SetKwInput{KwResult}{Result}%
\SetKw{KwTo}{to}
\SetKw{KwRet}{return}%
\SetKw{Return}{return}%
\SetKwBlock{Begin}{begin}{end}%
\SetKwRepeat{Repeat}{repeat}{until}%
%
\SetKwIF{If}{ElseIf}{Else}{if}{then}{else if}{else}{end if}%
\SetKwSwitch{Switch}{Case}{Other}{switch}{do}{case}{otherwise}{end switch}%
\SetKwFor{For}{for}{do}{end for}%
\SetKwFor{ForPar}{for}{do in parallel}{end forpar}
\SetKwFor{ForEach}{foreach}{do}{end foreach}%
\SetKwFor{ForAll}{forall the}{do}{end forall}%
\SetKwFor{While}{while}{do}{end while}%

答案2

为了更改关键字,您必须使用选项一种语言。 例如:

\usepackage[ruled,vlined,lined,linesnumbered,spanish, onelanguage]{algorithm2e}

相关内容