删除 algorithm2e 标题中冒号后的空格

删除 algorithm2e 标题中冒号后的空格

我正在使用algorithm2e包来可视化我的论文中的一些算法。如果我使用一些图形或表格,标题如下:“图 x:此处有一些描述”或“表 x:此处有一些描述”。请注意没有冒号前和数字后的空格。

如果我使用该algorithm2e包来处理算法,它只会打印标题,如下所示:“算法 x:此处有一些描述”。请注意冒号前和数字后的空格。

请参阅我的 MWE,它产生以下内容

在此处输入图片描述

有谁能帮我删除标题中冒号前面令人不安的空格吗?

\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}

答案1

嗯,该包代码中对于 option 的定义是错误的ngerman

作为一种解决方法,请将以下三行添加到给定的 MWE 的序言中:

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

您应该联系该软件包的维护者来写一份错误报告...

使用以下更正的 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}

你得到了想要的结果:

由此产生的算法

相关内容