2

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

4
  • 1
    See: Trying to put a box around a collection of subfigures The basic command is \fbox. May 21, 2012 at 16:59
  • 3
    In my opinion your question is really bad. Why don't you upload some images to demonstrate your request? In the moment I only see links where the helper must scroll. May 21, 2012 at 17:32
  • Yes, and if you have to add PDF links please in the form [<title>](<url>) which is much more readable. May 21, 2012 at 17:58
  • 2
    It would be nice if you would add an example image. Please make sure that all images are uploaded using the official stackexchange interface, i.e. the image icon on top of the text field (shortcut: CTRL+G). This ensures that all images are always accessible and do not expire. As new user without image posting privileges simply include the image as normal and remove the ! in front of it to turn it into a link. A moderator or another user with edit privileges can then reinsert the ! to turn it into an image again. May 21, 2012 at 18:07

2 Answers 2

3

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.

7
  • How can i install the newfloat package? i am working on kile.
    – curious
    May 21, 2012 at 21:49
  • 2
    @curious: Kile is just the frontend/editor. Can I assume you are using Ubuntu? Maybe with the standard Ubuntu TeX Live 2009 installation? In this case you should install TeX Live 2011 manually: How to install “vanilla” TeXLive on Debian or Ubuntu? or see How do I update my TeX distribution? May 22, 2012 at 6:18
  • I successfully installed tex live 2011 from here running the install-tl script. I then exported the path using export PATH=/usr/local/texlive/2011/bin/x86_64-linux:$PATH i re-opened kile but i am getting the same error: ! LaTeX Error: File `newfloat.sty' not found. when i run pdflatex. How am i sure the kile is compliant with the new installed packages?
    – curious
    May 22, 2012 at 11:14
  • @curious: Kile is just the editor, it isn't affected by the (not) installed packages. Check if you installed the package: tlmgr install newfloat or maybe tlmgr install caption. Also make sure that the right pdflatex is used. Maybe Kile is configured to use absolute paths? May 22, 2012 at 12:03
  • 1
    TeX Live 2011 is currently frozen because of the upcoming 2012 release. However, newfloat is part of it and should be still installable. Just ignore the message. Check if newfloat.sty is under /usr/local/texlive/2011, e.g. use find /usr/local/texlive/2011 -name newfloat.sty. If it is there and it still doesn't work then Kile is still using the wrong PATH. Try setting it in a command line window and start Kile from the same window afterwards. May 22, 2012 at 12:48
0

I was also interested in creating protocol flow diagrams (also known as ladder diagrams, or sequence diagrams). I found this to be the closest to what I wanted:

http://www.texample.net/tikz/examples/sequence-diagram/

But it was far over-complicated and the code was ugly. Here's my go at a more simple form:

% Agents
\def\Client          {Client}
\def\MasterController{Master Controller}
\def\FeatureCtlr     {Feature Controller}

% Drawing centred nodes macro.
\newcommand{\nd}{\node(0, 0)}

% Diagram
\begin{tikzpicture}[every node/.style={font=\normalsize,
                                       minimum height=0.5cm,
                                       minimum width=0.5cm}]

  % Matrix
  \node[matrix, very thin, column sep=1.3cm, row sep=0.5cm](matrix) at (0,0)
  {
    \nd (\Client)   {}; &          & \nd (\MasterController)   {}; &         & \nd (\FeatureCtlr)   {}; \\
    \nd (\Client 0) {}; &          & \nd (\MasterController 0) {}; &         & \nd (\FeatureCtlr 0) {}; \\
    \nd (\Client 1) {}; & \nd {};  & \nd (\MasterController 1) {}; &         & \nd (\FeatureCtlr 1) {}; \\
    \nd (\Client 2) {}; & \nd {};  & \nd (\MasterController 2) {}; &         & \nd (\FeatureCtlr 2) {}; \\
    \nd (\Client 3) {}; &          & \nd (\MasterController 3) {}; & \nd {}; & \nd (\FeatureCtlr 3) {}; \\
    \nd (\Client 4) {}; & \nd {};  & \nd (\MasterController 4) {}; &         & \nd (\FeatureCtlr 4) {}; \\
    \nd (\Client 5) {}; & \nd {};  & \nd (\MasterController 5) {}; &         & \nd (\FeatureCtlr 5) {}; \\
    \nd (\Client 6) {}; &          & \nd (\MasterController 6) {}; & \nd {}; & \nd (\FeatureCtlr 6) {}; \\
  };

  % Agents labels
  \fill
    (\Client)           node[draw,fill=white] {\Client}
    (\MasterController) node[draw,fill=white] {\MasterController}
    (\FeatureCtlr)      node[draw,fill=white] {\FeatureCtlr};

  % Vertical lifelines
  \draw [dotted]
    (\Client)           -- (\Client           6)
    (\MasterController) -- (\MasterController 6)
    (\FeatureCtlr)      -- (\FeatureCtlr      6);

  % Blocks (Budget constraints)
  \filldraw[fill=black!17]
    (\Client           0.north west) rectangle (\Client           5.south east)
    (\MasterController 0.north west) rectangle (\MasterController 3.south east)
    (\FeatureCtlr      1.north west) rectangle (\FeatureCtlr      2.south east)
    (\FeatureCtlr      4.north west) rectangle (\FeatureCtlr      5.south east);

  % Horizontal flows (inter-process).
  \draw [-latex]        (\Client           0) -- node [midway,above]{$request$}  (\MasterController 0);
  \draw [-latex]        (\MasterController 1) -- node [midway,above]{$validate$} (\FeatureCtlr      1);
  \draw [-latex,dashed] (\FeatureCtlr      2) -- (\MasterController 2);
  \draw [-latex,dashed] (\MasterController 3) -- (\Client           3);
  \draw [-latex]        (\Client           4) -- node [midway,above]{$access$}   (\FeatureCtlr      4);
  \draw [-latex,dashed] (\FeatureCtlr      5) -- (\Client           5);
\end{tikzpicture}

Sample Protocol Flow Diagram

You must log in to answer this question.

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