Options

Commuting diagram examples

These may not be pretty, and odd numbered diagrams require an \(id\) morphism, but here are some examples:

A commuting "line" (aka a morphism)

X \overset{f}{\rightarrow}Y $$ X \overset{f}{\rightarrow}Y $$ A commuting "triangle"

\begin{matrix} X & \overset{f}{\rightarrow } &Y \\ id_x \downarrow & & \downarrow h\\ X &\underset{g}{\rightarrow} &Z \end{matrix} $$ \begin{matrix} X & \overset{f}{\rightarrow } &Y \\ id_x \downarrow & & \downarrow h\\ X &\underset{g}{\rightarrow} &Z \end{matrix} $$ A commuting square

\begin{matrix} X & \overset{f}{\rightarrow } &W \\ e \downarrow & & \downarrow h\\ Y &\underset{g}{\rightarrow} &Z \end{matrix} $$ \begin{matrix} X & \overset{f}{\rightarrow } &W \\ e \downarrow & & \downarrow h\\ Y &\underset{g}{\rightarrow} &Z \end{matrix} $$ A commuting "pentagon"

\begin{matrix} X & \overset{f}{\rightarrow }& S & \overset{l}{\rightarrow } &W \\ id_x \downarrow & & & & \downarrow h\\ X &\underset{g}{\rightarrow}&T&\underset{k}{\rightarrow} &Z \end{matrix} $$ \begin{matrix} X & \overset{f}{\rightarrow }& S & \overset{l}{\rightarrow } &W \\ id_x \downarrow & & & & \downarrow h\\ X &\underset{g}{\rightarrow}&T&\underset{k}{\rightarrow} &Z \end{matrix} $$ A commuting "hexagon"

\begin{matrix} X & \overset{f}{\rightarrow }& S & \overset{l}{\rightarrow } &W \\ e \downarrow & & & & \downarrow h\\ Y &\underset{g}{\rightarrow}&T&\underset{k}{\rightarrow} &Z \end{matrix} $$ \begin{matrix} X & \overset{f}{\rightarrow }& S & \overset{l}{\rightarrow } &W \\ e \downarrow & & & & \downarrow h\\ Y &\underset{g}{\rightarrow}&T&\underset{k}{\rightarrow} &Z \end{matrix} $$ A commuting "\((2n+1)-\)gon"

\begin{matrix} X & \overset{f}{\rightarrow }& S & \overset{l}{\rightarrow }&R&\overset{\cdots}{\rightarrow }&W \\ id_x \downarrow & & & & & & \downarrow h\\ X &\underset{g}{\rightarrow}&T&\underset{k}{\rightarrow}&Q&\underset{\cdots}{\rightarrow} &Z \end{matrix} $$ \begin{matrix} X & \overset{f}{\rightarrow }& S & \overset{l}{\rightarrow }&R&\overset{\cdots}{\rightarrow }&W \\ id_x \downarrow & & & & & & \downarrow h\\ X &\underset{g}{\rightarrow}&T&\underset{k}{\rightarrow}&Q&\underset{\cdots}{\rightarrow} &Z \end{matrix} $$ A commuting "\((2n)-\)gon"

\begin{matrix} X & \overset{f}{\rightarrow }& S & \overset{l}{\rightarrow }&R&\overset{\cdots}{\rightarrow }&W \\ e \downarrow & & & & & & \downarrow h\\ Y &\underset{g}{\rightarrow}&T&\underset{k}{\rightarrow}&Q&\underset{\cdots}{\rightarrow} &Z \end{matrix} $$ \begin{matrix} X & \overset{f}{\rightarrow }& S & \overset{l}{\rightarrow }&R&\overset{\cdots}{\rightarrow }&W \\ e \downarrow & & & & & & \downarrow h\\ Y &\underset{g}{\rightarrow}&T&\underset{k}{\rightarrow}&Q&\underset{\cdots}{\rightarrow} &Z \end{matrix} $$

Comments

  • 1.

    We could use diagonal arrows for the odd-numbered diagrams:

    • \searrow produces an arrow pointing to south east \(\searrow\)
    • \swarrow produces an arrow pointing to south west \(\swarrow\)
    • \nearrow produces an arrow pointing to north east \(\nearrow\)
    • \nwarrow produces an arrow pointing to north west \(\nwarrow\)

    The commuting triangle example would look like this:

    $$ \begin{matrix} X & \xrightarrow{f} & Y \\ & \searrow & \downarrow \\ & & Z \end{matrix} $$ Unfortunately, I don't know of an easy and nice way of labelling the diagonal arrows; maybe we can draw some inspiration from this Maths Stackexchange thread.

    Comment Source:We could use diagonal arrows for the odd-numbered diagrams: - `\searrow` produces an arrow pointing to south east \\(\searrow\\) - `\swarrow` produces an arrow pointing to south west \\(\swarrow\\) - `\nearrow` produces an arrow pointing to north east \\(\nearrow\\) - `\nwarrow` produces an arrow pointing to north west \\(\nwarrow\\) The commuting triangle example would look like this: \[ \begin{matrix} X & \xrightarrow{f} & Y \\\\ & \searrow & \downarrow \\\\ & & Z \end{matrix} \] Unfortunately, I don't know of an easy and nice way of labelling the diagonal arrows; maybe we can draw some inspiration from [this Maths Stackexchange thread](https://math.meta.stackexchange.com/questions/2324/how-to-draw-a-commutative-diagram).
  • 2.
    edited May 27

    Here's a somewhat more complicated way, but the results look pretty good.

    You will need to install:

    First, there's a website for making commutative diagrams with TikZ: https://tikzcd.yichuanshen.de/

    Screen shot

    After you are done making your diagram, click the link icon, which will copy the \(\LaTeX\) for the diagram to the clipboard.

    Then, insert the code that was copied into this template:

    \documentclass{standalone}
    \usepackage{tikz}
    \usetikzlibrary{cd}
    \begin{document}
    
    % Paste your copied diagram here!
    
    \end{document}
    

    Save the file to commutative_diagram.tex. Then type at the command line:

    # pdflatex commutative_diagram.tex
    

    Next convert the resulting pdf into an svg:

    # pdf2svg commutative_diagram.pdf commutative_diagram.svg
    

    The result has some obnoxious white blocks, so we'll want to filter those out. Type:

    # sed -i.bak -e s/fill:rgb\(100\%,100\%,100\%\)\;fill-opacity:1/fill-opacity:0/ \
          commutative_diagram.svg
    

    Finally, the result is a little small. To resize the svg, type:

    rsvg-convert -a -w 500 -f svg commutative_diagram.svg -o enlarged_diagram.svg
    

    To make a smaller diagram use a number less than 500.

    Finally, you can share SVG image files with svgur.com. Here is the result of this little tutorial:

    Product Diagram

    Comment Source:Here's a somewhat more complicated way, but the results look pretty good. You will need to install: - [pdflatex](https://www.tug.org/texlive/) - [pdf2svg](https://github.com/dawbarton/pdf2svg) - [rsvg-convert](https://github.com/GNOME/librsvg) - [sed](https://www.gnu.org/software/sed/manual/sed.html) First, there's a website for making commutative diagrams with TikZ: https://tikzcd.yichuanshen.de/ ![Screen shot](https://i.imgur.com/OQCyb1D.png) After you are done making your diagram, click the link icon, which will copy the \\(\LaTeX\\) for the diagram to the clipboard. Then, insert the code that was copied into this template: <pre> \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{cd} \begin{document} % Paste your copied diagram here! \end{document} </pre> Save the file to `commutative_diagram.tex`. Then type at the command line: <pre> # pdflatex commutative_diagram.tex </pre> Next convert the resulting `pdf` into an `svg`: <pre> # pdf2svg commutative_diagram.pdf commutative_diagram.svg </pre> The result has some obnoxious white blocks, so we'll want to filter those out. Type: <pre> # sed -i.bak -e s/fill:rgb\(100\%,100\%,100\%\)\;fill-opacity:1/fill-opacity:0/ \ commutative_diagram.svg </pre> Finally, the result is a little small. To resize the svg, type: <pre> rsvg-convert -a -w 500 -f svg commutative_diagram.svg -o enlarged_diagram.svg </pre> To make a smaller diagram use a number less than `500`. Finally, you can share SVG image files with [svgur.com](http://svgur.com/). Here is the result of this little tutorial: ![Product Diagram](https://svgshare.com/i/6qX.svg)
  • 3.

    \(\require{begingroup}\begingroup\require{AMScd}\newcommand{\tlap}[1]{\raisebox{0pt}[0pt][0pt]{#1}}\newcommand{\blap}[1]{\vbox to 0pt{\hbox{#1}\vss}}\) If you only need horizontal or vertical arrows or equalities, you can use AMScd. To load it put \require{AMScd} in at least one equation in your post. This can produce diagrams like the one in the OP, but with arrows that can stretch to accomodate longer text. For more information see the guide here.

    Examples:

    Morphism:

    \begin{CD} A @>f>> B \end{CD}\begin{CD} A @>f>> B \end{CD} "Triangle":

    \begin{CD} X @>g>> Y \\\ @| {}@VfVV \\\ X @>{f\circ g}>> Z \end{CD}\begin{CD} X @>g>> Y \\ @| {}@VfVV \\ X @>{f\circ g}>> Z \end{CD} Square:

    \begin{CD} X @>g>> W \\\@VhVV {}@VVfV \\\ Y @>>k> Z \end{CD}\begin{CD} X @>g>> W \\@VhVV {}@VVfV \\ Y @>>k> Z \end{CD} Stretching:

    \begin{CD} X @>g>> W \\\@VhVV {}@VVfV \\\ Y @>\text{This is a long label.}>> Z \end{CD}\begin{CD} X @>g>> W \\@VhVV {}@VVfV \\ Y @>\text{This is a long label.}>> Z \end{CD} \(\endgroup\)

    Comment Source:\\(\require{begingroup}\begingroup\require{AMScd}\newcommand{\tlap}[1]{\raisebox{0pt}[0pt][0pt]{#1}}\newcommand{\blap}[1]{\vbox to 0pt{\hbox{#1}\vss}}\\) If you only need horizontal or vertical arrows or equalities, you can use AMScd. To load it put `\require{AMScd}` in at least one equation in your post. This can produce diagrams like the one in the OP, but with arrows that can stretch to accomodate longer text. For more information see the guide [here](http://www.jmilne.org/not/Mamscd.pdf). Examples: Morphism: `\begin{CD} A @>f>> B \end{CD}`\begin{CD} A @>f>> B \end{CD} "Triangle": `\begin{CD} X @>g>> Y \\\ @| {}@VfVV \\\ X @>{f\circ g}>> Z \end{CD}`\begin{CD} X @>g>> Y \\\ @| {}@VfVV \\\ X @>{f\circ g}>> Z \end{CD} Square: `\begin{CD} X @>g>> W \\\@VhVV {}@VVfV \\\ Y @>>k> Z \end{CD}`\begin{CD} X @>g>> W \\\@VhVV {}@VVfV \\\ Y @>>k> Z \end{CD} Stretching: `\begin{CD} X @>g>> W \\\@VhVV {}@VVfV \\\ Y @>\text{This is a long label.}>> Z \end{CD}`\begin{CD} X @>g>> W \\\@VhVV {}@VVfV \\\ Y @>\text{This is a long label.}>> Z \end{CD} \\(\endgroup\\)
Sign In or Register to comment.