15
\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.

egreg
  • 1,121,712
Haikal Yeo
  • 503
  • 3
  • 12

2 Answers2

21

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}

enter image description here

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}

enter image description here

egreg
  • 1,121,712
8

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

enter image description here

Herr K.
  • 17,946
  • 4
  • 61
  • 118
  • How may I add in $\delta$ as a label on the longest arrow? – Haikal Yeo Aug 04 '14 at 14:46
  • @HaikalYeo: You can add node[pos=<num>]{$\delta$} to the 4th line after the\drawcommand. Depending on where on the line you want$\delta$to be, you may want to put thenodecode before or after the coordinates, and then usepos` to adjust its position. – Herr K. Aug 04 '14 at 20:31
  • Sorry if I sound really stupid here but do I replace node and num with something else? – Haikal Yeo Aug 04 '14 at 21:05
  • Ooh. I get it already. Except I don't know how to adjust – Haikal Yeo Aug 04 '14 at 21:07
  • 1
    @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 05 '14 at 00:10