# I want to draw a nice connecting homomorphism arrow

\begin{tikzpicture}[scale=1.5]

\node (A) at (0,0) {$0$};
\node (B) at (1,0) {$H^0(G,P)$};
\node (C) at (2,0) {$H^0(G,M)$};
\node (D) at (3,0) {$H^0(G,N)$};
\node (E) at (1,-1) {$H^1(G,P)$};
\node (F) at (2,-1) {$H^1(G,M)$};
\node (G) at (3,-1) {$H^1(G,N)$};
\path[->,font=\scriptsize,>=angle 90]
(A) edge node[above]{} (B)
(B) edge node[above]{$\phi$} (C)
(C) edge node[above]{$\psi$} (D)
(D) edge node[above]{} (E)
(E) edge node[above]{} (F)
(F) edge node[above]{} (G);

\end{tikzpicture}


So I've got this that I want to try and draw a 'nice' connecting homomorphism which I'll try my best to describe: It starts from the end of the last element in the first row and ends at the beginning of the first element in the second row.

Maybe it's better to do it in tikzcd but I don't know how to do that either.

-
– Andrew Swann Jun 12 '14 at 10:55

With TikZ only

# Code

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,quotes}
\begin{document}
\begin{tikzpicture}[scale=2]
\matrix(m)[matrix of math nodes,column sep=15pt,row sep=15pt]{
0 & H^0(G,P) & H^0(G,M) & H^0(G,N) \\
& H^1(G,P) & H^1(G,M) & H^1(G,N) \\
};
\draw[->,font=\scriptsize,every node/.style={above},rounded corners]
(m-1-1) edge (m-1-2)
(m-1-2) edge["$\phi$"] (m-1-3)
(m-1-3) edge["$\psi$"] (m-1-4)
(m-1-4.east) --+(5pt,0)|-+(0,-7.5pt)-|([xshift=-5pt]m-2-2.west)--(m-2-2.west)
(m-2-2) edge (m-2-3)
(m-2-3) edge (m-2-4)
;
\end{tikzpicture}
\end{document}


# Output

-
How may I add in $\delta$ as a label on the longest arrow? – Haikal Yeo Aug 4 '14 at 14:46
@HaikalYeo: You can add node[pos=<num>]{$\delta$} to the 4th line after the \draw command. Depending on where on the line you want $\delta$ to be, you may want to put the node code before or after the coordinates, and then use pos to adjust its position. – Herr K. Aug 4 '14 at 20:31
Sorry if I sound really stupid here but do I replace node and num with something else? – Haikal Yeo Aug 4 '14 at 21:05
Ooh. I get it already. Except I don't know how to adjust <num> – Haikal Yeo Aug 4 '14 at 21:07
@HaikalYeo: <num> is a number between 0 and 1, which controls the position of the node on a path. For example, (m-1-4.east) --+(5pt,0)|-+(0,-7.5pt)-|node[pos=.25]{$\delta$}([xshift=-5pt]m-2-2.west)--(m-2-‌​2.west) will put the node at the middle of the longest line. – Herr K. Aug 5 '14 at 0:10

With tikz-cd it's a piece of cake:

\documentclass{article}

\usepackage{tikz-cd}

\begin{document}

\begin{tikzcd}[scale=1.5]
0 \arrow{r} &
H^0(G,P) \arrow{r}{\phi} &
H^0(G,M) \arrow{r}{\psi} &
H^0(G,N) \arrow{dll} \\
&
H^1(G,P) \arrow{r} &
H^1(G,M) \arrow{r} &
H^1(G,N)
\end{tikzcd}

\end{document}


With a modification of the example in the documentation at the end of page 11 we can get a bent arrow:

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}

\begin{tikzcd}
0 \arrow{r} &
H^0(G,P) \arrow{r}{\phi} &
H^0(G,M) \arrow{r}{\psi} \arrow[phantom, ""{coordinate, name=Z}]{d} &
H^0(G,N)
\arrow[
rounded corners,
to path={
-- ([xshift=2ex]\tikztostart.east)
|- (Z) [near end]\tikztonodes
-| ([xshift=-2ex]\tikztotarget.west)
-- (\tikztotarget)
}
]{dll} \\
&
H^1(G,P) \arrow{r} &
H^1(G,M) \arrow{r} &
H^1(G,N)
\end{tikzcd}

\end{document}


-
Is it possible to bend the arrow such that it starts at the right side of H^0(G,N) and then ends at the left side of H^1(G,P), making an inverted S shape? – Haikal Yeo Jun 11 '14 at 22:01
@HaikalYeo Yes, it's possible. I'm not saying I fully understand the code, I just adapted it from an example in the documentation. – egreg Jun 11 '14 at 22:13
Which documentation are you referring to? May I have the link to it? – Haikal Yeo Jun 11 '14 at 22:46
@HaikalYeo The documentation of tikz-cd`; you should have it on your system, but you can find it online at texdoc.net/texmf-dist/doc/latex/tikz-cd/tikz-cd-doc.pdf – egreg Jun 11 '14 at 22:47
I used the exact same code but there is an additional down arrow from H^0(G,M) to H^1(G,M). How do I remove this? – Haikal Yeo Jun 12 '14 at 8:58