Commit 82368919 authored by Niles Johnson's avatar Niles Johnson

add a little more explanations about the diagrams

parent 8e07977d
No preview for this file type
\documentclass{amsart}
\usepackage{hyperref}
%%
%% commutative diagrams with tikz
......@@ -35,9 +35,113 @@
\title{Diagrams with tikz}
\date{\today}
\begin{document}
\maketitle
\section{Introduction}
This document demonstrates how to draw commutative diagrams with
tikz. For rectangular diagrams, the matrix-style input of tikzcd
suffices, but for more complex diagrams it's useful to position nodes
by coordinates rather than \& tabs.
\noindent
Here's the basic idea for this system:
\begin{itemize}
\item Objects are positioned by coordinates and given labels.
\item Arrows connect objects referenced by their labels; thus when you
adjust objects, the arrows automatically adjust.
\item Scale is controlled by independent parameters, so the entire
diagram can be adjusted as necessary.
\end{itemize}
\noindent
And here's an example together with annotated code that produces it.
\[
\begin{tikzpicture}[x=25mm,y=20mm] % this option sets x and y scales
% draw the objects; use options tikzob and mm
% to automatically set appropriate spacing
% and ensure mathmode
%
% nodes are labeled so you don't have to
% retype the coordinates for start/end points of arrows
\draw[tikzob,mm]
(0,0) node (a) {(xe)y}
(1,0) node (b) {x(ey)}
(-.5,-1) node (c) {xy}
(1.5,-1) node (d) {xy};
% next draw arrows (paths) to/from nodes labeled above
% use options tikzar and mm to set arrow format and
% ensure mathmode
\path[tikzar,mm] %arrows
(a) edge node {\alpha} (b)
(c) edge node {r\,\mathrm{id}} (a)
(c) edge[swap] node {\mathrm{id}} (d)
(b) edge node {\mathrm{id} \, l} (d);
% if 2-cells are needed, add them at the appropriate
% positions
\draw[tikzob,mm]
(0.5,-0.5) node[rotate=270,font=\Large] {\Rightarrow}
++(3mm,0mm) node {\mu};
\end{tikzpicture}
\]
\begin{verbatim}
\begin{tikzpicture}[x=25mm,y=20mm] % this option sets x and y scales
% draw the objects; use options tikzob and mm
% to automatically set appropriate spacing
% and ensure mathmode
%
% nodes are labeled so you don't have to
% retype the coordinates for start/end points of arrows
\draw[tikzob,mm]
(0,0) node (a) {(xe)y}
(1,0) node (b) {x(ey)}
(-.5,-1) node (c) {xy}
(1.5,-1) node (d) {xy};
% next draw arrows (paths) to/from nodes labeled above
% use options tikzar and mm to set arrow format and
% ensure mathmode
\path[tikzar,mm] %arrows
(a) edge node {\alpha} (b)
(c) edge node {r\,\mathrm{id}} (a)
(c) edge[swap] node {\mathrm{id}} (d)
(b) edge node {\mathrm{id} \, l} (d);
% if 2-cells are needed, add them at the appropriate
% positions
\draw[tikzob,mm]
(0.5,-0.5) node[rotate=270,font=\Large] {\Rightarrow}
++(3mm,0mm) node {\mu};
\end{tikzpicture}
\end{verbatim}
To use this, you need the tikz styles defined in the preamble of this
document. You also need to load some other tikz packages, and tikz-cd
(to get spacing of nodes right). It's around a dozen lines of code
all together, and it's all in this preamble.
\section{More diagrams}
Here are some more examples for you to copy/paste and modify! The
rest of these just use features that are already built in to tikz, and
show you how to use them for things one often wants to do with
diagrams. If you develop any other useful examples, send them to
Niles or (bonus) just send a pull request to \url{https://gitlab.com/nilesjohnson/latex_starter.git}!
\[
\begin{tikzpicture}[x=35mm,y=25mm,baseline={(0,16mm)}]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment