Help:LaTeX Editing/Commutative Diagrams

From ProofWiki
Jump to: navigation, search

A lot of effort has been put into implementing extensions for commutative diagrams. This page lists these and other possibilities to draw them.

Drawing diagrams

The XyJax package

From Talk:Main Page/Archive 9#Xymatrix and Talk:Main Page/Archive_8#xymatrix_.28moved_from_User_talk:Lord_Farin.29

Some explanation will be added. For now, see the manual at http://www.jmilne.org/not/Mxymatrix.pdf



Examples:

  • Square diagrams:
\xymatrix{
A \ar[d]^b \ar[r]^a & B \ar[d]^c \\
C \ar[r]^d          & D }
$\xymatrix{ A \ar[d]^b \ar[r]^a & B \ar[d]^c \\ C \ar[r]^d & D }$
  • Triangles:
\xymatrix{
G \ar[d]^\pi \ar[r]^{\forall f} & H\\
G/N \ar[ru]_{\exists ! \bar f} }
$\xymatrix{ G \ar[d]^\pi \ar[r]^{\forall f} & H\\ G/N \ar[ru]_{\exists ! \bar f} }$
  • Curved lines and specifying positions:
\begin{xy}
<0em,0em>*+{X \times Y}="xy", <5em,0em>*+{X}="x", <0em,-5em>*+{Y}="y",
<5em,-5em>*+{Z}="z", <-4em,4em>*+={U}="u",
"xy";"x" **@{-} ?>*@{>} ?<>(.5)*!/^0.5em/{\scriptstyle p},
"xy";"y" **@{-} ?>*@{>} ?<>(.5)*!/_0.5em/{\scriptstyle q},
"x";"z" **@{-} ?>*@{>} ?<>(.5)*!/^0.5em/{\scriptstyle f},
"y";"z" **@{-} ?>*@{>} ?<>(.5)*!/_0.5em/{\scriptstyle g},
"u";"xy" **@{--} ?>*@{>},
"u";"y" **\crv{<-3em,-2em>} ?>*@{>} ?<>(.5)*!/^.5em/{y},
"u";"x" **\crv{<2em,3em>} ?>*@{>} ?<>(.5)*!/_.5em/{x}
\end{xy}
$\begin{xy} <0em,0em>*+{X \times Y}="xy", <5em,0em>*+{X}="x", <0em,-5em>*+{Y}="y", <5em,-5em>*+{Z}="z", <-4em,4em>*+={U}="u", "xy";"x" **@{-} ?>*@{>} ?<>(.5)*!/^0.5em/{\scriptstyle p}, "xy";"y" **@{-} ?>*@{>} ?<>(.5)*!/_0.5em/{\scriptstyle q}, "x";"z" **@{-} ?>*@{>} ?<>(.5)*!/^0.5em/{\scriptstyle f}, "y";"z" **@{-} ?>*@{>} ?<>(.5)*!/_0.5em/{\scriptstyle g}, "u";"xy" **@{--} ?>*@{>}, "u";"y" **\crv{<-3em,-2em>} ?>*@{>} ?<>(.5)*!/^.5em/{y}, "u";"x" **\crv{<2em,3em>} ?>*@{>} ?<>(.5)*!/_.5em/{x} \end{xy}$

The AMScd package

This package only supports rectangular diagrams, no diagonal arrows. For detailed help, see the AMScd manual.

Example:

\require{AMScd}

\begin{CD}
  A @>a>> B \\
  @VVbV @VVcV \\
  C @>d>> D
\end{CD}

Result:

$\require{AMScd} \begin{CD} A @>a>> B \\ @VVbV @VVcV \\ C @>d>> D \end{CD}$


Using standard $\LaTeX$ environments

It is possible to draw some diagrams using the matrix or array environments, but this has severe limitations. Example:

\begin{array}{ccc}
A & \xrightarrow{a} & B \\
\downarrow & \searrow & \downarrow \\
C & \xrightarrow{d} & D
\end{array}
$\begin{array}{ccc} A & \xrightarrow{a} & B \\ \downarrow & \searrow & \downarrow \\ C & \xrightarrow{d} & D \end{array}$


As an image

Another good option is to create an image and upload it. This is for example explained at https://meta.wikimedia.org/wiki/Help:Displaying_a_formula#Commutative_diagrams

The disadvantage is that this does not allow other users to change the notation, for example to bring it up with the House Style, or to use the source code for other diagrams.

External Links