[Tex/LaTex] How to create protocol flows inside a centred box

floatsframed

Could you please give some directions how to create the following figure in latex? It is the situation of describing a two parties protocol centered in a box.
It is like a 3X4 table but i have difficulties with the alignment. Tikz is the only way for drawing this?
figure 3

Best Answer

A simple way to add new float or caption types ("Scheme" in this case) is the newfloat package which is part of the caption bundle. There is also the float package which also provides the H (for: place really Here!). The box can be produced by using \fbox{\begin{minipage}{<width>}..\end{minipage}} or, more simpler, using the adjustbox package.

The actual content seems to be best made using a tabular, if you want the same format as in the PDFs.

\documentclass{article}

\usepackage{float}
\usepackage{newfloat}
\DeclareFloatingEnvironment[
    fileext=los,
    listname=List of Schemes,
    name=Scheme,
    placement=H,
    within=section,
]{scheme}

\usepackage{adjustbox}
\usepackage{blindtext}
\begin{document}

\section{Test}
\blindtext

\begin{scheme}
\begin{adjustbox}{minipage=.6\linewidth,fbox,center}
\begin{tabular}{rl}
  \bfseries Encryption:  & .... \\
                         & .... \\
  \bfseries Deccryption: & .... \\
                         & .... \\
            something    & .... \\
                         & .... \\
\end{tabular}
\end{adjustbox}
\caption{Some scheme}
\end{scheme}

\blindtext

\end{document}

Result


Or, using adjustbox v0.9 from 2012/05/16 (available on CTAN and on Bitbucket.org):

\documentclass{article}

\usepackage{newfloat}
\DeclareFloatingEnvironment[
    fileext=los,
    listname=List of Schemes,
    name=Scheme,
    within=section,
]{scheme}

\usepackage{adjustbox}[2012/05/16]
\usepackage{blindtext}
\begin{document}
\listofschemes

\section{Test}
\blindtext

\begin{adjustbox}{tabular={rp{.4\linewidth}},fbox,center,caption={Some scheme},nofloat=scheme}
  \bfseries Encryption:  & .... \\
                         & .... \\
  \bfseries Deccryption: & .... \\
                         & .... \\
            something    & .... \\
                         & .... \\
\end{adjustbox}

\blindtext

\end{document}

Change the nofloat to float if you want the scheme to float. You can of course create a new environment for this if you need it more often.

\newenvironment{xscheme}{\adjustbox{tabular={rp{.4\linewidth}},fbox,center,caption={Some scheme},nofloat=scheme}\bgroup}{\egroup}

Don't call it scheme because that environment is used internally.