11

I use

\usepackage[section]{algorithm}  
\usepackage{algorithmic}

to create an algorithm, I'd like to change "algorithm, begin, end while ..." to French. Is that possible?

This is my example with the package \usepackage{algorithmic}:

\newcommand{\algorithmicfor}{\textbf{Pour}}
\begin{algorithm}[H] 
\Begin{ \For{$x\in X$}{ $NbSuccInS(x) 
\longleftarrow 0$\; $NbPredInMin(x) 
\longleftarrow 0$\; $NbPredNotInMin(x) 
\longleftarrow |ImPred(x)|$\; 
} } 
\caption{My Algorithm} \label{alg:test} 
 \end{algorithm} 

I have these errors: undefined control sequence \Begin \for, \newcommand ....

13
  • please make this a complete document showing all packages used Commented Sep 30, 2012 at 18:01
  • Those errors are unrelated to the translation to French problem, you wuld get them even without the redefinition from For to Pour (which would need to be \renewcommand not \newcommand . It is much easier to answer questions if they contain a single code section starting \documentclass and ending \end{document} If your question had a working document using english keywords someone could show you how to redefine the commands to make it use French keywords. algorithmic appears to define \FOR not \For and doesn't define \Begin as far as I can see. Commented Sep 30, 2012 at 21:33
  • thank you for answer but i can't find in the list Algorithm --> Algorithme have you an idea please ?
    – researcher
    Commented Sep 30, 2012 at 22:01
  • That's from algorithm.sty not algorithmic \newcommand{\ALG@name}{Algorithm} \newcommand{\listalgorithmname}{List of \ALG@name s} to rename \ALG@name you need \makeatletter \makeatother but please post a _complete_example that works in English then it is easy to post an answer using French.then Commented Sep 30, 2012 at 22:04
  • i add this \renewcommand{\ALG@name}{Algorithm} \renewcommand{\listalgorithmname}{List of \ALG@name s} \makeatletter \makeatother in \begin{document} ?
    – researcher
    Commented Sep 30, 2012 at 22:15

3 Answers 3

14

The package defines all the fixed text words using simple macros that you can redefine with \renewcommand so for example

\newcommand{\algorithmicrequire}{\textbf{Require:}}
\newcommand{\algorithmicensure}{\textbf{Ensure:}}
\newcommand{\algorithmiccomment}[1]{\{#1\}}
\newcommand{\algorithmicend}{\textbf{end}}
\newcommand{\algorithmicif}{\textbf{if}}
\newcommand{\algorithmicthen}{\textbf{then}}
\newcommand{\algorithmicelse}{\textbf{else}}
\newcommand{\algorithmicelsif}{\algorithmicelse\ \algorithmicif}
\newcommand{\algorithmicendif}{\algorithmicend\ \algorithmicif}
\newcommand{\algorithmicfor}{\textbf{for}}
\newcommand{\algorithmicforall}{\textbf{for all}}
\newcommand{\algorithmicdo}{\textbf{do}}
\newcommand{\algorithmicendfor}{\algorithmicend\ \algorithmicfor}
\newcommand{\algorithmicwhile}{\textbf{while}}

if you change \newcommand to \renewcommand and change the English words to French to redefine these commands after loading the package it should all work I think.

2
  • have you an idea please ?
    – researcher
    Commented Sep 30, 2012 at 17:50
  • Please edit the question to have a complete document that shows the problem. Commented Sep 30, 2012 at 17:52
7

Pour avoir “algorithme” au lieu de “algorithm” et “Liste des algorithmes” au lieu de “List of algorithms”, ajouter juste french comme option dans use packages comme suit:

In order to get “algorithme” in place of “algorithm” and “Liste des algorithmes” in place of “List of algorithms”, just add french as option for the package as follows:

\usepackage[lined,boxed,commentsnumbered, ruled,vlined,linesnumbered, french]{algorithm2e}
1
  • 1
    Welcome to SE! You will have more lack if you ask in English language :-)
    – Zarko
    Commented Mar 5, 2016 at 11:38
6

With

\usepackage{algorithm}  
\usepackage{algpseudocode}

My humble contribution to the French translation (thanks @David-Carlisle):

\renewcommand{\listalgorithmname}{Liste des algorithmes}
\floatname{algorithm}{Algorithme}
\renewcommand{\algorithmicreturn}{\textbf{retourne}}
\renewcommand{\algorithmicprocedure}{\textbf{procédure}}
\renewcommand{\Not}{\textbf{non}\ }
\renewcommand{\And}{\textbf{et}\ }
\renewcommand{\Or}{\textbf{ou}\ }
\renewcommand{\algorithmicrequire}{\textbf{Entrée:}}
\renewcommand{\algorithmicensure}{\textbf{Sortie:}}
%\renewcommand{\algorithmiccomment}[1]{\{#1\}}
\renewcommand{\algorithmicend}{\textbf{fin}}
\renewcommand{\algorithmicif}{\textbf{si}}
\renewcommand{\algorithmicthen}{\textbf{alors}}
\renewcommand{\algorithmicelse}{\textbf{sinon}}
\renewcommand{\algorithmicfor}{\textbf{pour}}
\renewcommand{\algorithmicforall}{\textbf{pour tout}}
\renewcommand{\algorithmicdo}{\textbf{faire}}
\renewcommand{\algorithmicwhile}{\textbf{tant que}}
\newcommand{\algorithmicelsif}{\algorithmicelse\ \algorithmicif}
\newcommand{\algorithmicendif}{\algorithmicend\ \algorithmicif}
\newcommand{\algorithmicendfor}{\algorithmicend\ \algorithmicfor}

You must log in to answer this question.

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