带有语言包选项的 Algorithm2e 标题分隔符

带有语言包选项的 Algorithm2e 标题分隔符

请查看标题分隔符样式的差异。在第一个示例中,:在单词 之后直接输入。在语言选项为 german(也可以是 french 或 ngerman)的第二个 MWE 中,单词和Algorithm 1之间有一个空格。这是预期的行为吗?我该如何避免出现空格?重新定义不起作用。Algorithm 1:\SetAlgoCaptionSeparator{:}

MWE(无包装选项):

\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(带封装选项)

\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

最简单的解决方案是将分隔符定义为在\unskip其之前插入的任何空格:

\SetAlgoCaptionSeparator{\unskip:}

相关内容