# Snake lemma

> The two exact rows, the kernels and cokernels, and the connecting map that snakes between them. A tikz-cd example with its LaTeX source.

A tikz-cd example in the TeXeR TikZ library: https://texer.org/library/tikz-cd/snake-lemma

Package: [tikz-cd](https://texer.org/library/tikz-cd.md), on CTAN at https://ctan.org/pkg/tikz-cd.

Tags: snake lemma, homological algebra, exact sequence

## Source

```latex
\usepackage{tikz-cd}
\usetikzlibrary{calc}

\begin{tikzcd}[column sep=2em, row sep=2.2em]
  & \ker a \arrow[r] \arrow[d] & \ker b \arrow[r] \arrow[d] & \ker c \arrow[d]
  \arrow[dddll, rounded corners, to path={
    -- ([xshift=3ex]\tikztostart.east)
    |- ($(\tikztostart)!0.5!(\tikztotarget)$) node[pos=0.3, right] {$\partial$}
    -| ([xshift=-3ex]\tikztotarget.west)
    -- (\tikztotarget)}] \\
    & A \arrow[r] \arrow[d, "a", near start] & B \arrow[r] \arrow[d, "b", near start] & C \arrow[r] \arrow[d, "c", near start] & 0 \\
    0 \arrow[r] & A' \arrow[r] \arrow[d] & B' \arrow[r] \arrow[d] & C' \arrow[d] \\
    & \operatorname{coker} a \arrow[r] & \operatorname{coker} b \arrow[r] & \operatorname{coker} c
\end{tikzcd}
```

## As a complete document

The same example in a document that compiles on its own with pdfLaTeX:

```latex
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz-cd}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzcd}[column sep=2em, row sep=2.2em]
  & \ker a \arrow[r] \arrow[d] & \ker b \arrow[r] \arrow[d] & \ker c \arrow[d]
  \arrow[dddll, rounded corners, to path={
    -- ([xshift=3ex]\tikztostart.east)
    |- ($(\tikztostart)!0.5!(\tikztotarget)$) node[pos=0.3, right] {$\partial$}
    -| ([xshift=-3ex]\tikztotarget.west)
    -- (\tikztotarget)}] \\
    & A \arrow[r] \arrow[d, "a", near start] & B \arrow[r] \arrow[d, "b", near start] & C \arrow[r] \arrow[d, "c", near start] & 0 \\
    0 \arrow[r] & A' \arrow[r] \arrow[d] & B' \arrow[r] \arrow[d] & C' \arrow[d] \\
    & \operatorname{coker} a \arrow[r] & \operatorname{coker} b \arrow[r] & \operatorname{coker} c
\end{tikzcd}
\end{document}
```
