I'm using cryptocode to display some crypto-related things in a memoir
document, but I'd like to decrease the default spacing, which is huge (especially when using one half spacing in the rest of the document):
I managed to make everything smaller but I still have a few issues, sometimes I've too much spacing (in red squares, sometimes it's even sometimes more than in the original picture), sometimes I've not enough (in green circles):
Any idea how to fix that?
MWE
\documentclass{memoir}
\checkandfixthelayout
%% Configure 1.5 spacing between lines
\OnehalfSpacing
% even if not documented, one must use checkandfixthelayout not to break the title template
% https://tex.stackexchange.com/questions/601273/memoir-checkandfixthelayout-required-for-single-onehalfspacing
\checkandfixthelayout
\usepackage [
lambda,
advantage,
operators,
sets,
adversary,
landau,
probability,
notions,
logic,
ff,
mm,
primitives,
events,
complexity,
asymptotics,
keys
] {cryptocode}
\createprocedureblock{interactGame}{center,boxed}{}{}{}
\begin{document}
What I managed to have (problem: still too much space between two arrows):
\NewExpandableDocumentCommand{\mysendmessageleft}{m}{\sendmessage{<-,inner sep=0pt}{topstyle={inner sep=2pt},top={$#1$}}}
\NewExpandableDocumentCommand{\mysendmessageright}{m}{\sendmessage{->,inner sep=0pt}{topstyle={inner sep=2pt},top={$#1$}}}
\NewDocumentEnvironment{gameInteract}{mb}{
\begin{Spacing}{0}%
\interactGame[linenumbering]{#1}{#2\vspace{5mm}}
\end{Spacing}\par\vskip\baselineskip % Seems required or the next line will be eated up.
}{}
\begin{gameInteract}{My protocol}
\textbf{Challenger} \> \> \textbf{Adversary} \\
\> \mysendmessageleft{(m^{(0)},m^{(1)})} \> \text{Compute $m^{(0)}$ and $m^{(1)}$} \\
c \sample \bin \> \> \\
(k, t_k) \gets \textsf{Gen}(1^\lambda, m^{(c)}) \> \> \\
\> \mysendmessageright{k} \> \\
\> \mysendmessageleft{\tilde{c}} \> \\
\pcreturn \tilde{c} = c \> \>
\end{gameInteract}
What I have by default:
{\normalfont \interactGame[linenumbering]{My protocol}{
\textbf{Challenger} \> \> \textbf{Adversary} \\
\> \sendmessageleft*{(m^{(0)},m^{(1)})} \> \text{Compute $m^{(0)}$ and $m^{(1)}$} \\
c \sample \bin \> \> \\
(k, t_k) \gets \textsf{Gen}(1^\lambda, m^{(c)}) \> \> \\
\> \sendmessageright*{k} \> \\
\> \sendmessageleft*{\tilde{c}} \> \\
\pcreturn \tilde{c} = c \> \>
}}
\end{document}
Best Answer
The body of
\gameInteract
is not typeset with much attention to line spacing. You can get a uniform distance by settingSpacing
to 1.2 and by smashing the labels above the arrows. I also reduced their size with\scriptstyle
. Remove it if you don't like the style.