答案1
这是一个开始:
\documentclass{article}
\usepackage[margin = 1in]{geometry}% Just for this example
\usepackage{enumitem}
\newcommand{\IF}[1]{%
\par
\texttt{IF} #1,
\begin{itemize}[nosep, leftmargin = 1em]
\item[]\mbox{}\ignorespaces
}
\newcommand{\ELSE}{%
\end{itemize}
\texttt{ELSE}
\begin{itemize}[nosep, leftmargin = 1em]
}
\newcommand{\LELSE}[1]{%
\end{itemize}
\texttt{ELSE} #1
}
\newcommand{\ENDIF}{%
\end{itemize}
}
\newcommand{\OUTPUT}[1]{\texttt{OUTPUT} #1}
\newcommand{\RETURN}[1]{\texttt{RETURN} #1}
\newcommand{\var}{\textsf}
\newcommand{\procedurefont}{\textsf}
\newcommand{\RES}[1]{\procedurefont{RES}(#1)}
\newcommand{\FWD}[1]{\procedurefont{FWD}(#1)}
\newcommand{\BWD}[1]{\procedurefont{BWD}(#1)}
\newcommand{\ROB}[1]{\procedurefont{ROB}(#1)}
\newenvironment{procedure}[2][t]{%
\begin{minipage}[#1]{\procedurewidth}
\textbf{proc.}\ \textsf{#2} \par
}{%
\end{minipage}
}
\newlength{\procedurewidth}
\setlength{\procedurewidth}{.5\linewidth}% Default procedure width
\newcommand{\assign}{\leftarrow}
\newcommand{\TRUE}{\textsf{true}}
\newcommand{\FALSE}{\textsf{false}}
\begin{document}
\begin{figure}
\setlength{\procedurewidth}{.2\linewidth}%
\fbox{\begin{minipage}{\dimexpr\linewidth-2\fboxsep-2\fboxrule}
\mbox{}\hfill
\begin{procedure}{$\mathcal{D}$-refresh}
$(\sigma, I, \gamma, z) \assign \mathcal{D}(\sigma)$ \\
$S \assign \var{refresh}(S, I)$ \\
$c \assign c + \gamma$
\IF{$c \geq \gamma^*$}
$\var{corrupt} \assign \FALSE$
\ENDIF
\end{procedure}\hfill
\begin{procedure}{next-ror}
$(\mathcal{S}, R_0) \assign \var{next}(S)$ \\
$R_1 \assign \{0, 1\}^{\ell}$
\IF{$\var{corrupt} = \TRUE$}
$c \assign 0$ \\
\RETURN{$R_0$}
\LELSE \OUTPUT{$R_b$}
\end{procedure}\hfill
\begin{procedure}{get-next}
$(\mathcal{S}, R) \assign \var{next}(\mathcal{S})$
\IF{$\var{corrupt} = \TRUE$}
$c \assign 0$
\ENDIF
\OUTPUT{$R$}
\end{procedure}\hfill
\begin{procedure}{get-state}
$c \assign 0$, $\var{corrupt} \assign \TRUE$ \\
\OUTPUT{$S$}
\end{procedure}\hfill
\mbox{}%
\end{minipage}}
\caption{Procedures in games $\RES{\gamma^*}$, $\FWD{\gamma^*}$, $\BWD{\gamma^*}$, $\ROB{\gamma^*}$
for $\mathcal{G} = (\var{setup}, \var{refresh}, \var{next})$}
\end{figure}
\end{document}