0

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.

0

1 Answer 1

1

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}
2
  • 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. Apr 19, 2020 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 @). Apr 19, 2020 at 14:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .