4

When I draw a commutative diagram with tikz, I normally use the syntax

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{center}
\begin{tikzpicture}
\node (a) at (0,0) {$A$};
\node (b) at (2,0) {$B$};
\node (c) at (4,0) {$C$};
\path[->]
(a) edge (b)
(b) edge (c)
(a) edge [bend left] (c)
(a) edge [bend right] (c);
\end{tikzpicture}
\end{center}

\end{document}

This time, due to the size of the nodes, I need to use .. controls (2,2) .. to make the arrows avoid the nodes. But when I type

\begin{center}
\begin{tikzpicture}
\node (a) at (0,0) {$A$};
\node (b) at (2,0) {$B$};
\node (c) at (4,0) {$C$};
\draw[->]
(a) edge (b)
(b) edge (c)
(a) .. controls (2,2) ..  (c)
(a) .. controls (2,-2) .. (c);
\end{tikzpicture}
\end{center}

the arrow tip appears only at the last line drawn using the controls syntax (and at the two edges). How can I specify that I want an arrow tip at every line?

  • Wouldn't it be simpler to do with tikz-cd? – Bernard Jun 24 '16 at 13:29
  • @Bernard: I'm used to using the tikzpicture environment. Usually, my diagrams are much larger and more complex. – Stefan Hamcke Jun 24 '16 at 13:31
  • You can use edge[bend left=45] – percusse Jun 24 '16 at 14:14
  • 3
    You can do \draw[->] .. ; for each line rather than \draw[->] .. .. .. ..; for all lines. – Manuel Jun 24 '16 at 15:04
  • 1
    The thing is that in most cases, you only want the arrow tip at the end of the whole path - you don't want one at the end of every subpath. So PGF/TikZ goes with the usually-what-you-want. The best way to do this is to use distinct paths. You could use e.g. markings or decorations probably, but that's very clunky. – cfr Jun 24 '16 at 21:21
3

You can use arrows.meta library and looseness key to control the distance from the control point to the two end points as said in the pgfmanual.

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usepackage[tightpage,active]{preview}
\PreviewEnvironment{tikzpicture}

\begin{document}
\begin{center}
\begin{tikzpicture}
\node (a) at (0,0) {$A$};
\node (b) at (2,0) {$B$};
\node (c) at (4,0) {$C$};

\path[->]
(a) edge (b)
(b) edge (c)
(a) edge [out=80,in=100,looseness=5] (c)
(a) edge [out=-55,in=-125,looseness=1.5] (c);
\end{tikzpicture}

\end{center}
\end{document}

enter image description here

  • That almost worked, but the shape of the edge does just not fit my diagram. I need the edge to move very far upward, then make a very sharp curve to the right, and then go on for a rather short distance. With the looseness alone, I cannot achieve this. – Stefan Hamcke Jun 24 '16 at 15:01
  • @StefanHamcke You can, adding one intermediate point (or may be more for more control). – Manuel Jun 24 '16 at 15:03
  • @StefanHamcke Or you can try to change the in and out angles. It will change the shape of the edge. – Hoang-Ngan Nguyen Jun 24 '16 at 15:41

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.