2

I am using the algorithm2e package to visualize some algorithms in my thesis. If I use some figures or tables, the caption just goes the following way: "Figure x: some description here" or "Table x: some description here". Note that there is no whitespace before the colon and after the number.

If I use the algorithm2e package for a algorithm, it just prints the caption like the following way: "Algorithm x : some description here". Note that there is whitespace before the colon and after the number.

See my MWE which produces the following

enter image description here:

Is there anybody who can help me to remove that disturbing whitespace in front of the colon in the caption?

\usepackage[ngerman,boxed]{algorithm2e}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{blindtext}

\SetAlCapSkip{1em}
\SetKwInput{KwInput}{Eingabe}
\SetKwInput{KwOutput}{Ausgabe}

\begin{document}

\blindtext

\begin{algorithm}[ht]
\caption{Encryption}
\label{alg:Cipher2encryption}
\KwInput{$e$, $k$}
\KwOutput{$a$}
\tcc{Runden 1 bis 2}
\For{i = 0 to 1}{
    Berechne $e = e \oplus k_i;$ \\
    Teile $e$ in 4 Teilblöcke $b_j$ zu je 4 Bit, sodass $e = b_0  \, || \, b_1  \, || \, b_2  \, || \, b_3$ \\
    Berechne $e = SBox(b_0) \, || \, SBox(b_1) \, || \, SBox(b_2) \, || \, SBox(b_3)$ \\
    Permutiere jedes Bit $e_k$, sodass $e = P_2(e)$ \\
}
\tcc{Letzte Runde}
Berechne $a = e \oplus k_2;$ \\
Teile $a$ in 4 Teilblöcke $b_j$ zu je 4 Bit, sodass $a = b_0  \, || \, b_1  \, || \, b_2  \, || \, b_3$ \\
Berechne $a = SBox(b_0) \, || \, SBox(b_1) \, || \, SBox(b_2) \, || \, SBox(b_3)$ \\
Berechne $a = a \oplus k_3$ \\
\end{algorithm}

\blindtext

\end{document}
2

Well, there is a wrong definition in the code of that package for option ngerman.

As a workaround add the following three lines to your preamble of your given MWE:

\makeatletter 
  \renewcommand{\algocf@typo}{}% <======================================
\makeatother

You should contact the maintainer of that package to write a bug report ...

With the following corrected MWE

\documentclass[%
% ngerman
]{article}

\usepackage[%
  ngerman,
  boxed
]{algorithm2e}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{blindtext}

\SetAlCapSkip{1em}
\SetKwInput{KwInput}{Eingabe}
\SetKwInput{KwOutput}{Ausgabe}
\makeatletter 
  \renewcommand{\algocf@typo}{}% <======================================
\makeatother


\begin{document}

\blindtext

\begin{algorithm}[ht]
\caption{Encryption}\label{alg:Cipher2encryption}
\KwInput{$e$, $k$}
\KwOutput{$a$}
\tcc{Runden 1 bis 2}
\For{i = 0 to 1}{%
    Berechne $e = e \oplus k_i;$ \\
    Teile $e$ in 4 Teilblöcke $b_j$ zu je 4 Bit, sodass $e = b_0  \, || \, b_1  \, || \, b_2  \, || \, b_3$ \\
    Berechne $e = SBox(b_0) \, || \, SBox(b_1) \, || \, SBox(b_2) \, || \, SBox(b_3)$ \\
    Permutiere jedes Bit $e_k$, sodass $e = P_2(e)$ \\
}
\tcc{Letzte Runde}
Berechne $a = e \oplus k_2;$ \\
Teile $a$ in 4 Teilblöcke $b_j$ zu je 4 Bit, sodass $a = b_0  \, || \, b_1  \, || \, b_2  \, || \, b_3$ \\
Berechne $a = SBox(b_0) \, || \, SBox(b_1) \, || \, SBox(b_2) \, || \, SBox(b_3)$ \\
Berechne $a = a \oplus k_3$ \\
\end{algorithm}

\blindtext

\end{document}

you get the wished result:

resulting algorithmn

  • Thank you very much. Exactly what I wanted. – chris000r Aug 26 '19 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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