1

I am adapting an example of a sequence diagram I took form texample.net. http://www.texample.net/tikz/examples/sequence-diagram/

Unfortunately I am having some difficulties.

How would I draw a self referencing arrow? I have attached a picture with a red arrow to symbolize what I am talking about.

How would I do that in Tex?enter image description here

3
  • You could use \draw [->] (start-coordinate) -| (1,-.5) --++ (-1,0);. Change the values to your need.
    – moospit
    Aug 6, 2014 at 10:10
  • Thank you for your answert. I still have the problem that the arrow is too long an I don't get it shorter. \draw [->] (start-coordinate) -| (1,0.001) --++ (-0.74,0); Aug 6, 2014 at 11:06
  • I don't completely understand which part of the arrow is too long and needs to get shorter. Can you please clarify this problem. To correct my above code a little, you could use relative coordinates for the second point too: \draw [->] (start-coordinate) -| ++(1,-.5) --++(-1,0). Hope this helps
    – moospit
    Aug 6, 2014 at 11:24

1 Answer 1

2

Here now everything summed up as answer not as comment. Saw you got it with the relative coordinates.

Arrowheads:

For changing the arrowhead, you have to use

\usetikzlibrary{arrows}

in your preamble. See the following code example for the most arrow types

\documentclass[border=5mm, tikz]{standalone}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}
% All arrows also possible with 'reversed'
 \foreach \x [count=\i] in {to,
                            to reversed,
                            latex,
                            latex',
                            stealth,
                            stealth',
                            triangle 90,
                            triangle 60,
                            triangle 45,
                            open triangle 90,
                            open triangle 60,
                            open triangle 45,
                            angle 90,
                            angle 60,
                            angle 45,
                            hooks,
                            ),
                            ],
                            |,
                            *,
                            o,
                            diamond,
                            open diamond,
                            square,
                            open square,
                            left to,
                            right to,
                            left hook,
                            right hook} {
  \draw [<->, >=\x] (0,-\i/2) -- ++(1,0) node (2.5,-\i/2) [anchor=west, align=left] () {\scriptsize{\x}};
 }

 \foreach \x [count=\i] in {round cap,
                            butt cap,
                            triangle 90 cap,
                            triangle 90 cap reversed,
                            fast cap,
                            fast cap reversed} {
  \draw [<->, >=\x, line width=1ex] (4,-\i/2) -- ++(1,0) node (6.5,-\i/2) [anchor=west, align=left] () {\scriptsize{\x}};
 }
\end{tikzpicture}
\end{document}

TikZ Arrow Types

Labels:

For setting labels on paths you can use the following code:

 \draw (0,0) -- (2,0) node [midway, rotate=45, above] {Text goes here};

For your code you have to look where you want to place your label and possibly adjust your path definition. Example code to fit your problem:

\documentclass[border=5mm, tikz]{standalone}
\begin{document}
\begin{tikzpicture}
 \coordinate (start-coordinate) at (0,0);
 \draw [->] (start-coordinate) %
    --++ (1,0)   node [midway, above] {Text above} %
    --++ (0,-.6) node [midway, right] {Text right} %
    --++ (-.74,0) node [midway, below] {Text below};
\end{tikzpicture}
\end{document}

enter image description here

Hope this answers your questions.

3
  • Thank you for this very helpfull answer. One last question. How would I let one of those arrows point to another node? Aug 7, 2014 at 11:00
  • You could do it the standard way via (minimal example): \draw (end-point-of arrow) -- (node-name). Here you could use -| or |- to preserve 90-degreed angles.
    – moospit
    Aug 7, 2014 at 12:13
  • Thank you very much for your help! The folowing did it for me: \draw [-latex] (startnode) -| ++(1,-0.6) -| (-0.74,0) |- (endnode); Aug 7, 2014 at 12:47

You must log in to answer this question.

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