Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have to write an algorithm in Hungarian, where the caption must look like:

1.3. Algoritmus: caption of alg

instead of the usual style

Algorithm 1.3: caption of alg.

Until now I had no problem as the package babel was doing all the work, but changing from algorithm-algorithmic to the algorithm2e package, it fails.

Anyone know the way to do so?

share|improve this question
    
Welcome to TeX.SX. –  Claudio Fiandrino Jan 23 '13 at 15:35

1 Answer 1

up vote 2 down vote accepted

You can redefine an internal macro of algorithm2e, namely \fnum@algocf. Put

\makeatletter
\renewcommand{\fnum@algocf}{\AlCapSty{\AlCapFnt\thealgocf\nobreakspace\algorithmcfname}}
\makeatother

into your preamble. Complete example:

\documentclass{article}
\usepackage{algorithm2e}

\makeatletter
\renewcommand{\fnum@algocf}{\AlCapSty{\AlCapFnt\thealgocf\nobreakspace\algorithmcfname}}
\makeatother

\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}
share|improve this answer
    
Thanks a lot, it does the job. To be perfect I corrected it by adding the dot after the numbering: \renewcommand{\fnum@algocf}{\AlCapSty{\AlCapFnt\thealgocf.\nobreakspace\algorit‌​hmcfname}} –  Boglárka G.-Tóth Jan 23 '13 at 16:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.