[Tex/LaTex] How to control the caption of algorithm2e by captionsetup

algorithm2ecaptions

I want to change the appearance of the caption for algorithms written by algorithm2e package using the caption package.
In captionsetup one can easily customize the caption depending on the float type, whether a table, a figure, or a longtable even, but when I specified a captionsetup for algorrithms it didn't work, is there any way to change the Algorithm 1: to Algorithm 1.?

MWE Code:

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

Output:
enter image description here

Best Answer

You have to use the command

\SetAlgoCaptionSeparator{.}

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

Output:

enter image description here

P.S. An extract from the caption package documentation:

Note: Some environments, e.g. the algorithm environment offered by the algorithm2e package, might react allergic to a change of the caption label format.

Related Question