algorithm2e
我想使用包更改由包编写的算法的标题外观caption
。captionsetup
人们可以根据浮点类型轻松自定义标题,无论是表格、图形还是长表,但当我为算法指定标题设置时它不起作用,有什么方法可以将其更改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
)可能会对标题标签格式的更改产生过敏反应。