I have this algorithm:
\begin{algorithm}
\captionsetup[algorithm]{name=MegaAlgorithm}
\DontPrintSemicolon
\KwData{$G=(X,U)$ such that $G^{tc}$ is an order.}
\KwResult{$G’=(X,V)$ with $V\subseteq U$ such that $G’^{tc}$ is an
interval order.}
\caption{\textsc{Fast}SLAM\label{IR}}
\end{algorithm}
Using these packages:
\usepackage{caption}
\usepackage[ruled,vlined]{algorithm2e}
But the label name of my algorihm is still 'Algorithm 1: FastSLAM' instead of 'MegaAlgorithm 1: FastSLAM'. How to do that?
Best Answer
For the sake of consistency, define a new environment that uses the
MegaAlgorithm
caption style. Not sure whether you will intermix regularAlgorithm
s andMegaAlgorithm
s, which this solution is geared towards:The new
megaalgorithm
environment redefines\algorithmcfname
- the macro used to print the caption type - just before calling the regularalgorithm
environment. Since the redefinition is within the scope ofmegaalgorithm
, it is localized and reverts back to the default afterwards. This allows you to intermix the different kinds of algorithm types.If you wish to have a separate counter for MegaAlgorithm and Algorithm, you can use the following definition of
megaalgorithm
in your preamble: