我正在用 cryptocode 的伪代码编写一个双人协议,并且有一个适用于两个玩家的一段时间条件。由于条件while
很长,它会将其他列向右移动很远,这看起来不太好看。有没有办法让列缩进格式忽略行while
宽?
代码:
\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}
答案1
肮脏的黑客:使用\makebox
隐藏文本的宽度
\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}