Simple commutative diagram

In algebra, especially in category theory, we use so called commutative diagrams. Vertices denote objects such as groups or modules. Arrows represent morphisms, which are maps between those objects.

The characteristic quality of such diagrams is that they commute. This means, you get the same result by composition, not matter which directed way in the diagram you go, if start point and end point are the same.

Such diagrams are used a lot for visualizing algebraic properties. Whole proofs are done by chasing through such a diagram. That’s why our example deals with it. It is a diagram visualizing the first isomorphism theorem in group theory.

We use the TikZ package, because it offers a wealth of arrow heads and tails, and useful graphic tools for positioning and labeling.

The code is fully explained in the LaTeX Cookbook, Chapter 10, Advanced Mathematics, Drawing commutative diagrams.

Edit and compile if you like:
% Simple commutative diagram
% Author: Stefan Kottwitz
% https://www.packtpub.com/hardware-and-creative/latex-cookbook
\documentclass[border = 5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows.meta}
\usepackage{amsmath}
\DeclareMathOperator{\im}{im}
\begin{document}
\begin{tikzpicture}
  \matrix (m)
    [
      matrix of math nodes,
      row sep    = 3em,
      column sep = 4em
    ]
    {
      G              & \im \varphi \\
      G/\ker \varphi &             \\
    };
  \path
    (m-1-1) edge [->>] node [left] {$\pi$} (m-2-1)
    (m-1-1.east |- m-1-2)
      edge [->] node [above] {$\varphi$} (m-1-2)
    (m-2-1.east) edge [{Hooks[right,length=0.8ex]}->,
      dashed] node [below] {$\tilde{\varphi}$} (m-1-2);
\end{tikzpicture}
\end{document}
Click to download: commutative-diagram.texcommutative-diagram.pdf
Open in Overleaf: commutative-diagram.tex