3

Please see the difference in the style of the caption separator. In the first example the : is typed directly after the word Algorithm 1. In the second MWE with language option german (also french or ngerman) there is a white space between the word Algorithm 1 and the :. Is that the intended behaviour and how can I avoid the white space? Redefining with \SetAlgoCaptionSeparator{:} doesn't work.

MWE (without the package option):

\documentclass{scrartcl}
\usepackage{algorithm2e}
\begin{document}
\begin{algorithm}
\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} 

MWE (with package option)

\documentclass{scrartcl}
\usepackage[german]{algorithm2e}
\begin{document}
\begin{algorithm}
\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} 

1 Answer 1

5

The easiest solution is to define the separator to \unskip whatever space is inserted before it as well:

\SetAlgoCaptionSeparator{\unskip:}
5
  • 1
    I know nothing about German typographical rules, but French rules insert a space before ; : ! ? (what's called in French high punctuation). On an other hand, the traditional separator for French is an endash. I suppose your problem comes from babel's ngerman option.
    – Bernard
    Commented Jul 15, 2014 at 20:31
  • 1
    @Bernard If I look at how e.g. Koma Script sets the captions for figures and tables there shouldn't be any whitespace in german. But thank you for pointing out that there are languages which use a space. In my MWEs there is no babel or is it loaded by algorithm2e? Commented Jul 15, 2014 at 20:34
  • One of the MWE has option german. I suppose it links to babel.
    – Bernard
    Commented Jul 15, 2014 at 20:48
  • One of your MWE has german option. I suppose it links to babel. But maybe it's the scrartcl class?
    – Bernard
    Commented Jul 15, 2014 at 20:51
  • @Bernard I think only ngerman will link to babel (only hint in the documentation about babel). Maybe it's scrartcl, but as Werner's solution works it is not so important. Commented Jul 15, 2014 at 21:23

You must log in to answer this question.

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