I’ve been working on my LaTeX skills for some time. The goal is to move towards an all-latex solution for writing research papers, slide sets and other documents. I’m almost there. An important goal was to be able to create all sorts of figures within LaTeX. (Well, originally, the goal was to use open source softwares to create them but it turns out that LaTeX is really good at this stuff.) The package that I’m using for graphics creation is TikZ. Here we’ll cover how we can create sequence diagrams using TikZ and a plugin package.

Here’s what we’re planning on creating.

Sequence Diagram using TikZ (click to enlarge)

First, you need to get the pgf-umlsd.sty file from over here and put it in a folder. Then, create your minimal working example (main document) using the following code.

\documentclass{article}
\usepackage{tikz}
\usepackage{pgf-umlsd}

\begin{document}

\begin{sequencediagram}
\newinst[3]{b}{Browser}
\newinst[3]{t}{TPM}
\newinst[3]{p}{TTP}

\begin{call}{u}{Init()}{b}{}
\end{call}

\begin{call}{u}{AIKAuthSecret}{b}{}

\mess{b}{verifyAIKAuthSecret}{t}

\begin{call}{b}{get AIK$_{pub}$}{t}{AIK$_{pub}$}
\end{call}

\end{call}
\begin{sdblock}{Loop}{}

\begin{call}{u}{Do Something}{p}{AIK$_{pub}$}
\end{call}
\end{sdblock}
\end{sequencediagram}

\end{document}


As you can see, the pgf-umlsd package is really awesome. You first create a new thread using the syntax \newthread[color]{variable}{ClassName}. Then, you create instances using \newinst[distance]{variable}{InstanceName}. Afterwards, use call environment to specify calls. All you need to do is specify the caller, the message label, recipient and return label. Messages are similar and can be done through the \mess command. You can insert blocks using the sdblock environment. All it needs is a label and a description. A block will automatically surround everything within this environment. Oh, and calls can be nested.

If you’re like me and don’t like your object names underlined, you can pass the [underline=false] option to the pgf-umlsd package.

p.s. Your output may be a little bit different from mine because I modified the package file to suit my personal liking — just a bit though.

1. Really nice. How is the back call (dotted one) done. I’ll try it soon.

2. recluze

November 25, 2011 at 9:13 am

It’s automatically done. The last parameter of the call environment is the text of the return message.

3. Nice! What are your modifications to the package code? I recommend to make redefinitions in your preamble or in your own .sty file, using \renewcommand etc. instead of changing the original package file, so that a LaTeX document looks the same on all computers, with all TeX distributions and on all operating systems.

4. recluze

November 26, 2011 at 2:32 pm

Thanks Stefan. You are absolutely right. Unfortunately, my skills with LaTeX are well below the level required to fully understand the pgf-umlsd package code. So, I only managed to change some parts of the code that I could understand. It includes some stuff like manually positioning the labels to ‘near end’ or ‘near start’ instead of the default ‘midway’. However, the changes are kind of unstable.

5. Nice blog right here! Additionally your site quite a bit up fast! What host are you using? Can I get your associate hyperlink to your host? I want my web site loaded up as fast as yours lol

6. Rattling nice style and design and wonderful content , nothing else we want : D.

7. Hi everyone, it’s my first pay a visit at this web site, and post is in fact fruitful in favor of me, keep up posting these types of articles.

8. Hi,
nice intro in this package, thanks. Do you know how to disable the shadows, too?

9. recluze

January 14, 2014 at 3:40 am

I added the shadows myself. If you use the default package, there will be no shadows.

10. Me encantará escucharlos en la sección de comentarios, la tienes más abajo.

11. Podemos decorar superficies con papel usando la técnica del decoupage, que tratamos extensamente en su sección correspondiente.

12. I noticed your page’s ranking in google’s search results is very low.
You are loosing a lot of traffic. You need hi
authority backlinks to rank in top 10. I know – buying
them is too expensive. It’s better to own them. I know how to do that,