Solution
Do not mix lst:
with Algorithm floats. The previous solution used \newcommand{\algorithmname}{Listing}
, but this could result in LaTeX Error: Command \algorithmname already defined. Instead, apply the following changes:
- Rename
lst:
to alg:
.
- Change the preamble to:
\usepackage{float}
\floatname{algorithm}{Listing}
\renewcommand{\algorithmname}{Listing}
This does not change the "List of Algorithms" to "List of Listings". The text is found in "stdfloats.inc":
Float
Type algorithm
GuiName Algorithm
Placement tbp
Extension loa
NumberWithin none
Style ruled
ListName "List of Algorithms"
LaTeXBuiltin false
End
The improper way to fix this is:
- Edit stdfloats.inc.
- Change "List of Algorithms" to "List of Listings".
- Click Tools >> Reconfigure.
- Restart LyX.
At this point, "List of Algorithms" will read "List of Listings".
With the algorithmic
environment, you're probably using the algorithms
bundle or possibly the algorithmicx
package (both provide that environment). The algorithm
environment's name is stored in \ALG@name
that you can modify using \renewcommand
.
Here's a way to modify the default Algorithm
to your liking:
\documentclass{article}
\usepackage{algorithm}% http://ctan.org/pkg/algorithms
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
\makeatletter
\renewcommand{\ALG@name}{Algoritme}% Afrikaans
\makeatother
\begin{document}
\begin{algorithm}
\caption{Hierdie is 'n algoritme.}
\begin{algorithmic}[1]
\State Iets
\State Iets anders
\end{algorithmic}
\end{algorithm}
\end{document}
Note that this is actually independent of the algorithmic
environment.
The algorithm2e
package is a more complete package in the sense that it provides its own algorithm
environment. It also supports a number of language options by default, including english
, french
, czech
, german
, portuguese
, italiano
, and slovak
. For example, using (from the algorithm2e
documentation):
\documentclass{article}
\usepackage[portuguese]{algorithm2e}% http://ctan.org/pkg/algorithm2e
\begin{document}
\begin{algorithm}[H]
\SetAlgoLined
\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}
produces
These language options set a number of commands other than just the algorithm name (stored in \algorithmcfname
). Here's an extract for the portuguese
language option:
\DeclareOption{portuguese}{%
\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}%
}%
If your language is not supported here, you can perform the manual redefinitions yourself using a similar setup to the language settings above. If you just have a couple of changes that doesn't affect many components of your document, using
\renewcommand{\algorithmcfname}{Algoritme}% Afrikaans "Algorithm"
should work. You may also want to define your keywords accordingly.
Best Answer
\SetAlgorithmName
requires three arguments:such as
You could also directly redefine the macros of the
algorithm2e
package: