2

A standard diagram produced by pgf-umlsd uses only basic arrows, for example:

\documentclass{article}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{positioning, fit, calc, shapes, arrows}
\usepackage[underline=false]{pgf-umlsd}
\begin{document}

\begin{figure}[H]
    \centering
    \begin{sequencediagram}
        \newinst{c}{Client}
        \newinst[6]{s}{Server}

        \mess[1]{c}{Longer label}{s}
        \mess[1]{s}{label}{c}
        \mess[1]{c}{label}{s}
        \mess[1]{s}{Longer label}{c}
    \end{sequencediagram}
    \caption{Client-Server messaging}
\end{figure}
\end{document}

enter image description here

I would like to adjust the length and the tip of any given arrow. For example, being able to draw something like:

enter image description here

Can this be done by applying local changes to a figure?

  • Is the application of e.g. tikzpicture a valuable alternative to sequencediagram because then you can/have to draw everything by hand. You are including the package tikz anyway. Are you interested in such a solution? – strpeter Jan 21 '14 at 21:54
4

Yes, it can be done by a redefinition of \mess; in the following example I used xparse to easily add a fifth optional argument allowing you some control over the \draw command used for the arrow; this, in particular, allows you to specify different arrow tips and to use the shorten key:

\documentclass{article}
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{positioning, fit, calc, shapes, arrows}
\usepackage[underline=false]{pgf-umlsd}

\RenewDocumentCommand{\mess}{O{0}mmmO{>=angle 60}}{%
  \stepcounter{seqlevel}
  \path
  (#2)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (mess from) {};
  \addtocounter{seqlevel}{#1}
  \path
  (#4)+(0,-\theseqlevel*\unitfactor-0.7*\unitfactor) node (mess to) {};
  \draw[->,#5] (mess from) -- (mess to) node[midway, above]
  {#3};

  \node (#3 from) at (mess from) {};
  \node (#3 to) at (mess to) {};
}

\begin{document}

\begin{figure}
    \centering
    \begin{sequencediagram}
        \newinst{c}{Client}
        \newinst[6]{s}{Server}

        \mess[1]{c}{Longer label}{s}[{-]},shorten >=20pt]
        \mess[1]{s}{label}{c}[>=hooks,shorten >=10pt]
        \mess[1]{c}{label}{s}
        \mess[1]{s}{Longer label}{c}
    \end{sequencediagram}
    \caption{Client-Server messaging}
\end{figure}

\end{document}

enter image description here

To produce the exact tip arrow you showed in your question, you need, for example, to have the CVS version of pgf, then you already have this kind of arrow in arrows.meta library.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.