2

It it difficult to create a question for this. I want to tex source code like here. Is this with listings? Which package do they use? How do I get the separate procedures in one line? And how do I get the borderline?

Source code

Sorry, if the question is bad. The source is this paper.

2
  • This looks like a table with four columns, or maybe four minipages side by side. The code itself I'm not sure, but it might have been entered manually, with a combination of \textbf, \textsf (sans serif), \texttt (teletype) and math mode.
    – Marijn
    Commented Aug 24, 2018 at 13:53
  • I'm not an expert but this looks like pseudocode. Have a look at this introduction to algorithms.
    – Max
    Commented Aug 24, 2018 at 13:53

1 Answer 1

3

Here is a start:

enter image description here

\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}
0

You must log in to answer this question.

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