1

I'm writing a 2-player protocol with cryptocode's pseudocode, and have a while condition which applies to both players. Since the while condition is long it shifts the other columns far to the right, which doesn't look nice. Is there a way to make the columns indentations formatting ignore the while line's width?

Code:

\documentclass{article}
\usepackage{algorithm,algpseudocode}
\usepackage[
    n,
    operators,
    advantage,
    sets,
    adversary,
    landau,
    probability,
    notions,    
    logic,
    ff,
    mm,
    primitives,
    events,
    complexity,
    asymptotics,
    keys]{cryptocode}

\begin{document}
\begin{algorithm}
\caption{2-player protocol}
\pseudocode{%
 \textbf{Alice} \<\< \textbf{Bob} \\
 x\sample\left\{0,1\right\}^{N} \<\< y \gets W \left( x \right) \\
 {done}_A = \text{False} \<\< {done}_B = \text{False} \\
 \pcwhile {done}_A \neq \text{True} \textbf{ and } {done}_B \neq \text{True} \pcdo \\
 \pcind m \gets M \<\< \\
 \< \sendmessageright*[2cm]{m} \< \\
 \<\< \hat X \gets \text{Update}\left(m\right) \\
 ...}
\end{algorithm}
\end{document}

Output: The current output

Desired output (sketch): The desired output

1 Answer 1

1

Dirty hack: use a \makebox to hide the width of the text

\documentclass{article}
\usepackage{algorithm,algpseudocode}
\usepackage[
    n,
    operators,
    advantage,
    sets,
    adversary,
    landau,
    probability,
    notions,    
    logic,
    ff,
    mm,
    primitives,
    events,
    complexity,
    asymptotics,
    keys]{cryptocode}

\begin{document}
\begin{algorithm}
\caption{2-player protocol}
\pseudocode{%
 \textbf{Alice} \<\< \textbf{Bob} \\
 x\sample\left\{0,1\right\}^{N} \<\< y \gets W \left( x \right) \\
 {done}_A = \text{False} \<\< {done}_B = \text{False} \\
 \makebox[0pt][l]{$\pcwhile {done}_A \neq \text{True} \textbf{ and } {done}_B \neq \text{True} \pcdo$} \\
 \pcind m \gets M \<\< \\
 \< \sendmessageright*[2cm]{m} \< \\
 \<\< \hat X \gets \text{Update}\left(m\right) \\
 ...}
\end{algorithm}
\end{document}

enter image description here

You must log in to answer this question.

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