My question is a follow up of Cryptocode: Cref should link to a game, and write its name : so far, in a memoir document I display some "figures" (typically in a new float environment) representing a cryptographic game:
As the name of the game is already written at the top of the box, I don't want to put any caption. However, I still want to be able to provide the list of all games, using for instance the \listof{floatGame}{List of Games} command provided by the float package.
How could I make sure that the name of the game is printed in the table of content, without adding a visible caption?
MWE:
\documentclass[]{article}
\usepackage{amsmath}
\usepackage [
n,
advantage,
operators,
sets,
adversary,
landau,
probability,
notions,
logic,
ff,
mm,
primitives,
events,
complexity,
asymptotics,
keys
] {cryptocode}
\createprocedureblock{gameProc}{center,boxed}{}{}{}
\usepackage{lipsum}
\usepackage{float}
\newfloat{floatGame}{htb!}{Game}
\floatname{floatGame}{Game}
\makeatletter
% Usage: \begin{mygame}[label][short title]{title} content \end{mygame}
\NewDocumentEnvironment{game}{soomb}{%
\IfBooleanTF{#1}{\begin{floatGame}[htbp]}{\begin{floatGame}[H]}%
\caption{#4}%
\begin{pcimage}%
{\normalfont\gameProc[linenumbering]{#4}{\IfValueTF{#2}{%
%% Add an anchor if a label is present
\raisebox{1em}{\hypertarget{#2}{}}%
%% Create a macro "mygametitle@nameoflabel" to store the title
\IfValueTF{#3}{% If a short title is provided
\expandafter\gdef\csname mygametitle@#2 \endcsname{#3}%%
\write@auxout{\gdef\string\mygametitle@#2{#3}}%
}{%
\expandafter\gdef\csname mygametitle@#2 \endcsname{#4}%%
\write@auxout{\gdef\string\mygametitle@#2{#4}}%
}%
}{} #5 }}%
\end{pcimage}
\end{floatGame}%
}{}
% Usage: \refGame{label}
\NewDocumentCommand{\refGame}{m}{%
\hyperlink{#1}{\csname mygametitle@#1\endcsname}% Do not put a white space after #1!
}
\makeatother
\definecolor{secondaryColor}{RGB}{206,149,0} %% darker orange, looks like gold. <3
\usepackage[
colorlinks,
allcolors=secondaryColor % https://tex.stackexchange.com/a/50754/
]{hyperref}
%\usepackage{hyperref}
\usepackage{cleveref}
\begin{document}
\listof{floatGame}{List of Games}
\section{Content}
I provide a new environment \verb|game|, where you can specify an optional star (to insert it into a floating figure), an optional label (\textbf{WARNING: do not use any number in the label}) if you want to refer to it later, an optional short title (used when citing the game), the real title, and finally the content.
\begin{game}*[myGreatGame][$\indcpa$]{$\indcpa_\enc^\adv(\secpar)$}
b \sample \bin \
(\pk,\sk) \sample \kgen (\secparam) \
(\state,m_0,m_1) \sample \adv(\secparam, \pk, c) \
c \sample \enc(\pk,m_b) \
b' \sample \adv(\secparam, \pk, c, \state) \
\pcreturn b = b'
\end{game}
You can then refer to the game using \verb|refGame|, like \refGame{myGreatGame}.
\end{document}

