All commercial rights reserved. May be freely distributed and used with the following exceptions:

1. No commercial use without explicit permission.

2. It may not be distributed without this notice.

The diagram macros

The file diagram includes a number of macros for drawing commutative diagrams in special shapes as well as more flexible macros to paste together more complicated diagrams.

In general, there are two kinds of macros. The first kind has the following form \shapename[shape parameters] and is intended to be used in the following way:

$$
\shapename[shape_parameters]
$$

This will create a shape with the given parameters. It operates by building its own picture environment.

The second kind of procedure must be used inside a picture environment and allows the user to put a diagram of a given size and shape at a given place. The usual way in which this is used is:

$$
\bfig
\putshape1<optional parameters>(x1,y1)[shape_parameters1]
...
\putshape(xn,yn)<optional parameters>[shape_parametersn]
\efig
$$

Here is an example of the first kind of macro. I will have to explain a few details before giving examples of the second. The code

$$
\square[A`B`C`D;f`g`h`k]
$$

produces the diagram

[figure: C; D; k; A; B; f; g; h]

and the code

$$
\Atriangle[A`B`C;f`g`h]
$$

produces the diagram

[figure: B; C; h; A; f; g]

The reason for the shape name will be explained later.

If an arrow label extends especially high or low, the space automatically expands to match. For example,

$$
\square[A`B`C`D;\sum_{i=1}^{\infty}`g`h`\Psi^A_k]
$$

will get the diagram

[figure: C; D; Ψ_{k}^{A}; A; B; ∑{∞ \atop i=1}; g; h]

and so on.

Before going on, I will explain about the parameters. Any shape will have one or two parameters for height and/or length as well as one parameter for each arrow in the diagram. These are in addition to the parameters used in the actual procedures. For example, the procedure

$$
\square<-1`0`2`-3;1000`700>[A`B`C`D;f`g`h`k]
$$

gives the square:

[figure: C; D; k; A; B; f; g; h]

The meaning is as follows. The first four parameters refer to four arrows in linguistic order (top, left, right, bottom). A negative number gives a backward arrow, while a zero causes it to be omitted. A parameter with an absolute value of 1 is ordinary, while 2 gives an arrow with a tail (monomorphism) and 3 a double headed arrow (epimorphism). The last two parameters determine the width and height, respectively, in units of 0.01 em (an em is the width of an M, the widest letter in a font). It should be noted that it is not possible to give only some of the optional parameters; either all must be given or none is.

Here are the shapes. We have already seen the shape \square. There are eight different triangles, all isoceles right triangles in different orientations. The names all have the form \xtriangle, where x is the letter that most closely resembles the actual shape of the triangle.

Here are the names, followed by a sample of each one:

\btriangle

[figure: B; C; h; g; A; f]

\dtriangle

[figure: B; C; h; f; A; g]

\ptriangle

[figure: A; B; f; C; g; h]

\qtriangle

[figure: A; B; f; g; C; h]

\Atriangle

[figure: B; C; h; A; f; g]

\Vtriangle

[figure: A; B; f; C; g; h]

\Ctriangle

[figure: h; A; B; f; C; g]

\Dtriangle

[figure: h; B; g; A; C; f]

In addition, there are two special diagrams that come up often enough to be worth having a special macros for.

     \Atrianglepair

[figure: B; C; k; D; l; A; f; g; h]

     \Vtrianglepair

[figure: D; h; A; B; f; C; g; k; l]

Finally, there is one special shape that is probably not used by very many mathematicians. Still I have it and the user might as well share it.

\recurse[A`B`R`C;s`f_0`f`t_0`t]

[figure: t_{0}; R; f_{0}; f; C; A × C; t; B; A × B; s; A × f]

Notice what happens if the first parameter is empty:

\recurse[`B`R`C;s`f_0`f`t_0`t]

[figure: t_{0}; R; f_{0}; f; C; C; t; B; B; s; f]

This takes care of the simple procedures. The remaining procedures are there as building blocks for more complicated diagrams.

These take the form

\putshape(xpos,ypos)[shape parameters]

where shape is one of the 11 shapes (excluding \recurse) described above and the parms are as described there. The parameters xpos and ypos are the offsets from the lower left corner of the picture measured in umits of .01 em in the usual L^{A}TEX fashion.

There is one more shape which is simply an arrow with an attached label. This is called \putmorphism and it is used with the syntax

\putmorphism(xpos,ypos)(run,rise)[node1`node2`label]{dist}{type}{loc}

Here the parameters xpos and ypos are as above. The slope is rise/run where rise and run are two numbers that give the slope in accordance with the L^{A}TEX rules. That is rise and run must have no common divisor and must not exceed 4 in absolute value. In addition, these procedures are defined so that rise must not be positive and if it is zero, then run must be positive. In other words, all arrows must go in the linguistic direction, downwards or to the right. Arrows can be made to go in the reverse direction as explained below.

The next three parameters are the node that appears first (in linguistic order), the one that appears second and the arrow label. The next paramater is the distance in the sense of L^{A}TEX between the centers of the nodes. This means it is the horizontal component of the distance, unless that is negative, in which case it is the vertical distance. The second parameter is the code for the arrowtype, an integer between -3 and 3 with the same meaning as explained above. Using negative values of this parameter allows one to draw an arrow that goes upwards or left. Note, however, that node1 is always the node that is above or to the left of node2. The last parameter should have the value a,b,l,r or m. The values a and b are used only for horizontal arrows and direct the arrow label to be placed above or below the arrow. The values l and r are used for all other arrows and direct the label to be left or right of the arrow. Finally, a vertical arrow only can be given the parameter m, in which case the arrow will be gapped and the label placed in the middle of the gap.

In general, the simple macros are designed to be used as indicated either in the display environment or in one of the others, usually

\begin{equation}\begin{array}{c}
...
\end{array}\end{equation}

The \putshape macros must be used inside a picture environment that is normally placed inside a display or similar environment. The reference point for the positioning parameters is determined as the lower left corner of the smallest rectangle with sides parallel to the coordinate axes that includes the center points of all nodes on its border. This rectangle will be degenerate in the case of a horizontal or vertical morphism. The reference point may either be on or outside the actual figure. For example, in the case of the btriangle, it is the center of the lower left node, while for a qtriangle it is outside the triangle itself being the fourth corner of the enclosing square.

The macros are made so that they fit together well. That is why all distances are from node centers to node centers. If a vertex is part of two shapes, it is probably best not to repeat it, since it is conceivable that round-off errors will cause its two appearances to be slightly offset. It can either be omitted or, since the width is used to determine the amount to shorten horizontal arrows, replaced by \phantom versions. Both methods are illustrated in the example given at the end.

A somewhat baroque (but taken from an actual text) example illustrates most of these points.

$$
\bfig
\putmorphism(0,2100)(0,-1)[``T\eta'T]{1400}1l
\putmorphism(0,2100)(1,0)[TT`T`\mu]{700}1a
\putmorphism(0,2100)(1,-1)[`TTT'`TT\eta']{700}1l
\putmorphism(700,2100)(1,-1)[`TT'`T\eta]{700}1r
\put(700,1750){\makebox(0,0){1}}
\putmorphism(700,1420)(1,0)[\phantom{TTT'}`\phantom{TT'}`\mu
  T']{700}1a
\putmorphism(700,1380)(1,0)[\phantom{TTT'}`%

  \phantom{TT'}`T\sigma]{700}1b
\putsquare<0`1`1`1;700`700>(700,700)[TTT'`TT'`TT'TT'`TT'T';`T\eta'TT'``]
\putmorphism(700,700)(1,0)[\phantom{TT'TT'}`%
  \phantom{TT'T'}`TT'\sigma]{700}1a
\put(300,1400){\makebox(0,0){2}}
\put(950,1050){\makebox(0,0){3}}
\putbtriangle<0`1`0;700>(1400,700)[``TT';T\eta'T'`id`]
\putmorphism(1400,700)(1,0)[\phantom{TT'T'}`%
  \phantom{TT'}`T\mu']{700}1a
\put(1600,1050){\makebox(0,0){6}}
\putsquare<1`1`0`1;700`700>(0,0)[TT'T`\phantom{TT'TT'}`T'T`T'TT';%
  TT'T\eta'`\sigma T``T'T\eta']
\putmorphism(700,0)(1,0)[\phantom{T'TT'}`%
  \phantom{T'T'}`T'\sigma]{700}1b
\putsquare<0`0`1`1;700`700>(1400,0)[``T'T'`T';``\sigma`\mu']
\putmorphism(700,700)(0,-1)[``\sigma TT']{700}1m
\putmorphism(1400,700)(0,-1)[``\sigma T']{700}1m
\put(300,350){\makebox(0,0){4}}
\put(1050,350){\makebox(0,0){5}}
\put(1750,350){\makebox(0,0){7}}
\efig
$$

which produces

Here is a page of samples of the results from the various \putshapes. The code

$$

[figure: T η′T; T T; T; μ; T T T′; T T η′; T T′; T η; 1; μT′; T σ; T T′T T′; T T′T′; T T T′; T T′; T η′T T′; T T′σ; 2; 3; T T′; id; T η′T′; T μ′; 6; T′T; T′T T′; T′T η′; T T′T; T T′T η′; σT; T′σ; T′T′; T′; μ′; σ; σT T′; σT′; 4; 5; 7]

\bfig
\putsquare(0,0)[A`B`C`D;f`g`h`k]
\putbtriangle(0,1500)[A`B`C;f`g`h]
\putdtriangle(2200,1500)[A`B`C;f`g`h]
\putptriangle(0,3000)[A`B`C;f`g`h]
\putqtriangle(1000,500)[A`B`C;f`g`h]
\putCtriangle(1500,750)[A`B`C;f`g`h]
\putDtriangle(700,1000)[A`B`C;f`g`h]
\putAtriangle(2000,2200)[A`B`C;f`g`h]
\putAtrianglepair(0,2500)[A`B`C`D;f`g`h`k`l]
\putVtriangle(2000,3000)[A`B`C;f`g`h]
\putVtrianglepair(1000,2500)[A`B`C`D;f`g`h`k`l]
\efig
$$

produces the diagram:

[figure: C; D; k; A; B; f; g; h; B; C; h; g; A; f; B; C; h; f; A; g; A; B; f; C; g; h; A; B; f; g; C; h; h; A; B; f; C; g; h; B; g; A; C; f; B; C; h; A; f; g; B; C; k; D; l; A; f; g; h; A; B; f; C; g; h; D; h; A; B; f; C; g; k; l]

Added: For horizontal and vertical lines only, arrow parameters of ±4, ±5 and ±6 will give dashed lines.

Here is a double cube:

$$
\bfig
\putsquare(0,750)[A`B`C`D;```]
\putsquare(0,250)[\phantom{C}`\phantom{D}`E`F;```]
\putsquare(250,500)[A'`B'`C'`D';```]
\putsquare(250,0)[\phantom{C'}`\phantom{D'}`E'`F';```]
\putmorphism(0,1250)(1,-1)[```]{250}1a
\putmorphism(500,1250)(1,-1)[```]{250}1a
\putmorphism(0,750)(1,-1)[```]{250}1a

\putmorphism(500,750)(1,-1)[```]{250}1a
\putmorphism(0,250)(1,-1)[```]{250}1a
\putmorphism(500,250)(1,-1)[```]{250}1a
\efig
$$

[figure: C; D; A; B; E; F; C′; D′; A′; B′; E′; F′]