如何通过captionsetup控制algorithm2e的标题?

如何通过captionsetup控制algorithm2e的标题?

algorithm2e我想使用包更改由包编写的算法的标题外观captioncaptionsetup人们可以根据浮点类型轻松自定义标题,无论是表格、图形还是长表,但当我为算法指定标题设置时它不起作用,有什么方法可以将其更改Algorithm 1:Algorithm 1.

MWE 代码:

\documentclass{scrartcl}
\usepackage{caption}
\captionsetup[longtable]{justification=justified} % works fine
\captionsetup[figure]{labelsep=period,format=plain, font={small}} % works fine
\captionsetup[algorithm]{labelsep=period,format=plain} % didn't work!
\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}

输出:
在此处输入图片描述

答案1

你必须使用命令

\SetAlgoCaptionSeparator{.}

平均能量损失

\documentclass{scrartcl}
\usepackage{caption}
\captionsetup[longtable]{justification=justified} % works fine
\captionsetup[figure]{labelsep=period,format=plain, font={small}} % works fine
%\captionsetup[algorithm]{labelsep=period,format=plain} % didn't work!
\usepackage{algorithm2e}
\SetAlgoCaptionSeparator{.}
\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} 

输出:

在此处输入图片描述

PS 软件包文档摘录caption

笔记:某些环境(例如包algorithm提供的环境algorithm2e)可能会对标题标签格式的更改产生过敏反应。

相关内容