\draw (20,12) -- ++(2,0) -- ++(0,2) -- ++(-3,0) -- ++(45:3);
Use ++
before each new incremental coordinate to make it relative to the last one and put the pencil there.
Here's a complete example:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikz\draw (20,12) -- ++(2,0) -- ++(0,2) -- ++(-3,0) -- ++(30:3) {[rounded corners=10pt]-- ++(5,0) -- ++(0,-6)} -- ++(-7,0) -- cycle;
\end{document}
Of course, combining this with the -| or |- path operators can simplify the code even further; the following two pieces of code produce the same result:
\tikz\draw (20,12) -- ++(2,0) -- ++(0,2) -- ++(3,0) -- ++(0,1) -- ++(1,0) -- ++(0,-3) -- ++(2,0);\par\bigskip
and
\tikz\draw (20,12) -| ++(2,2) -| ++(3,1) -- ++(1,0) |- ++(2,-3);
I don't think that defining commands in this case adds anything; in fact, I think it reduces the functionality of the existing syntax (which is already simple). The example demonstrates that you can use, for example, polar coordinates and modify (up to TikZ limitations) the path attributes midways; even if the current question doesn't require this, it's a good thing to have the possibility to do those kind of modification if they are required.
To obtain west anchor for node long node name
you can use right anchor=west
.
Code
\documentclass[tikz]{standalone}
\usetikzlibrary{graphs}
\begin{document}
\tikz \graph[grow right sep=20,nodes={draw,rectangle},right anchor=west] { a -> {b, long node name} };
\end{document}
Result
Best Answer
This has to do with the fact that you are using
\draw
, whileedge
is usually used in conjunction with\path
.What happens when you use the
edge
operation is that TikZ first draws everything up to theedge
keyword, and then starts a new path with theevery edge
style between the nodes/coordinates specified in youredge
operation. So usingedge
essentially splits your\draw
command in two:is the same as saying
The first line will just create the arrowhead pointing up, while the second line creates the actual line with the arrow head.
Your example can be corrected like this: