3

Question. What do you recommend to have the arc(-arrow) start outside the node (b) and also stop outside the node (c) in

enter image description here

which was created with

 \documentclass{amsart}
 \usepackage{tikz}
 \begin{document}
  \begin{tikzpicture}
   \node (a) at (0pt,0pt)[]{$a$};
   \node (b) at (0pt,101pt)[]{$b$};

   \draw[->] (a)--(b);
   \draw[->] (b) arc [start angle=0, end angle=74, x radius=25pt, y    radius=25pt,line width=4pt] node (c) {$c$};
  \end{tikzpicture}
 \end{document}

?

Do you agree that it is somewhat unsystematic of TikZ to not have the straight arrow also go from center to center by default?

Remarks.

I know more than one way to somehow do this, for example with the option "shorten", but none appears the right way to do this. For example, using functionality like (b.north) is not a good solution, since it does not uniformly work. One then has to keep track of where one should say "north", where "south", etc, especially when some degree of automation is used in a larger TikZ program.

3
  • 3
    The problem is that some path drawing commands interpret node names as "shapes" while others interpret them as dimensionless coordinates. For example \draw[->] (a) -- (b); draws that path only between the boundaries of nodes (a) and (b) (as you can see in your example), while arc consideres (c) a dimensionless coordinate at the center of node c. You should better define your nodes before connecting them and later use only to to connect them, which allows you to have some control on the shape of the connection (straight, curved, etc.)
    – JLDiaz
    Jul 22 '17 at 13:08
  • 1
    Please always add a minimal working example (MWE), its much easier to help when we see compilable code, starting with \documentclass and ending with \end{document}.
    – Bobyandbob
    Jul 22 '17 at 13:11
  • 1
    @Bobyandbob: thanks for pointing out, just forgot, will be edited. Jul 22 '17 at 13:37
10

I do not like to use arc, except when necessary, I prefer to use to [out = xx, in = xx]. It is also necessary that the node exists before joining it, otherwise, the coordinate is reached directly.

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
 \node (a) at (0pt,0pt){$a$};
 \node (b) at (0pt,101pt){$b$};

 \draw[->] (a)--(b);
 \path  (b)  arc (0:90:25pt) node (c) {$c$};
  \draw[->]  (b)   to [out=90,in=0] (c);

\end{tikzpicture}
\end{document}

enter image description here

another solution in 3 lines!

All nodes are defined in a path It remains only to trace the arcs and segments with [rounded corners]

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}

 \path  node(a) {$a$} --++ (0,101pt)node(b){$b$}   |-++  (-1,1) node (c) {$c$};
\draw[rounded corners=0.5cm,->] (a) -- (b) ;
\draw[rounded corners=0.5cm,->]   (b)|- (c);

\end{tikzpicture}
\end{document}
3
  • Well, many thanks for this solution. It works. However, I still find it unsatisfactory because this way four pieces of data have to be written twice: (0) the name (b), (1) the name (c), (2) the angle 0, (3) the angle 90. I could write a custom macro wrapping your solution into a custom command, making it possible to write the aforementioned data only once. But does anyone have a native TikZ solution? This would be useful, it seems. Jul 22 '17 at 13:49
  • look at the other solution
    – rpapa
    Jul 22 '17 at 16:58
  • 3 lines ? or a single line \tikz\draw[rounded corners=0.5cm,->]node(a){$a$}(0,101pt)node(b){$b$}++(-1,1)node (c){$c$}(a)edge(b)(b)|-(c); ;)
    – Kpym
    May 17 '18 at 12:06
3

When you write

\draw (a) -- (b);

TikZ actually tries to help you by shortening the line such that you don't have the same problem with lines. But notice that it is trying to help.

Unfortunately, this is not the case for arcs because arcs are geometrically constrained much more strictly and their start and end points are not available at the time of parsing. Hence, TikZ cannot offer the same help and just assumes the center anchor. Emphasis on cannot offer not a missing feature. For such use, TikZ offer to paths using Bezier curves with specifying in, out angles.

For arcs that are specified with their start/end points you might want to use \pgfpatharcto or other arc variants specified in the manual.

The other crossing of c is because you placed the node at the end of the path so it is not relevant to the problem stated above, just use any anchoring directions and it will be put away from the end point.

2
  • Thanks. Re \pgfpatharcto: looking at the manual closely, it seems that pgfpatharcto does not offer a possibility to have the arc end in an arrowhead. Is this true? Jul 22 '17 at 14:17
  • @PeterHeinig You need extra \pgfsetarrowsstart and \pgfsetarrowsend macros at thhe low level to set arrow heads
    – percusse
    Jul 22 '17 at 14:21

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.