Captions in Algorithm2e

Hey guys,

these days I came across the algorithm2e package of LaTeX, which I prefer to the classic packages algorithm and algorithmic. Unfortunately, it has a weird behaviour concerning captions. One can set the caption font with \SetAlCapFnt, but then the complete caption (including caption label and caption text) will be changed. I can provide the following workaround:

\usepackage[algochapter,boxed,longend,linesnumbered]{algorithm2e}
\newcommand{\myalgofont}[1]{\textbf{\sffamily{#1}}}
\SetKwSty{myalgofont}
\SetAlCapFnt{\normalfont}

% fix for captions in algorithms
\makeatletter
% org: \newcommand{\algocf@captiontext}[2]{#1\algocf@typo: \AlCapFnt{}#2}
\renewcommand\algocf@captiontext[2]{\usekomafont{captionlabel}#1\algocf@typo:
\usekomafont{caption}#2}
\makeatother

You can replace the \usekomafont stuff with whatever font-setting you prefer. If, however, you are using a koma document class, then I suggest to use it like that.


Posted

in

by

Tags: