# Two captions for algorithm in algorithm2e package

In my thesis, I need to describe both algorithms and cryptographic games. Currently I am using the algorithm2e and the algorithm environment for both.

Is there an option to specify dual captions so that games are captioned with Game and algorithms with Algorithm.

Note: In essence I am asking the question in How to have two separate types of caption labels for algorithms? but with algorithm2e package.

You can use \captionof together with a new float type within a normal algorithm environment.

This shows how to do it with either float or newfloat. Interestingly, algorithm2e does not automatically load either. I recommend newfloat as being more compatible with the caption package.

\documentclass{article}
\usepackage{algorithm2e}
\usepackage{newfloat}
\DeclareFloatingEnvironment[fileext=loga,listname=List of Games,placement=htp]{game}% log already used

\usepackage{float}
\newfloat{Game}{htp}{logm}

\usepackage{caption}

\begin{document}
\listofalgorithms

\listofgames

\listof{Game}{List of Games}

\begin{algorithm}[hp]
\caption{test 1}
\end{algorithm}

\begin{algorithm}[hp]
\captionof{game}{test 2}
\end{algorithm}

\begin{algorithm}[hp]
\captionof{Game}{test 3}
\end{algorithm}
\end{document}

• Thank you, you have been very helpful. Your suggestion is working. Any idea, on how to combine it with autoref in order to reference captionof{game} as Game. – Panagiotis Grontas Apr 19 '20 at 9:45
• IIRC, \captionof{Game}{...} calls \refstepcounter{Game} which should set up \label to save the counter name (Game). If not, \edef\@currentlabelname{Game} (you will need to something about the @). – John Kormylo Apr 19 '20 at 14:33