% $Id: eurotex2001-pqa-article.tex,v 1.9 2001/11/12 09:53:59 pedro Exp pedro $
\documentclass{europroc}
\usepackage[dvips]{graphicx}
\usepackage{dcpic,pictex}
\usepackage{calrsfs}
\usepackage{dsfont}
\usepackage{alltt}
\begin{document}
\title[DCpic]{DCpic, Commutative Diagrams in a (La)\TeX\ Document}
\author[Pedro Quaresma]{Pedro Quaresma\thanks{This work was partially
supported by the Portuguese Ministry of Science and Technology (MCT),
under the programme PRAXIS XXI.}\\ CISUC\\ Departamento de
Matem{\'a}tica, Universidade de Coimbra\\ 3001-454 COIMBRA, PORTUGAL}
\maketitle
\begin{abstract}
DCpic is a package of \TeX\ macros for graphing Commutative Diagrams
in a (La)\TeX\ or Con\TeX t document. Its distinguishing features
are: the use of \PiCTeX\ a powerful graphical engine, and a simple
specification syntax. A commutative diagram is described in
terms of its objects and its arrows. The objects are
textual elements and the arrows can have various straight or curved
forms.
We describe the syntax and semantics of the user's commands, and
present many examples of their use.
\end{abstract}
\keywords{Commutative Diagrams, (La)\TeX, \PiCTeX}
\section{Introduction}
\initial{3}{C}{\scshape ommutative Diagrams} (Diagramas Comutativos,
in Portuguese), are a kind of graphs which are widely used in Category
Theory~\cite{Herrlich73,MacLane71,Pierce98}, not only as a concise and
convenient notation but also for ``arrow chasing'', a powerful tool
for mathematical thought. For example, the fact that in a Category we
have arrow composition is easily expressed by the following
commutative diagram.
$$
\begindc{\commdiag}[30]
\obj(10,15){$A$}
\obj(25,15){$B$}
\obj(40,15){$C$}
\mor(10,15)(25,15){$f$}
\mor(25,15)(40,15){$g$}
\cmor((10,11)(11,7)(15,6)(25,6)(35,6)(39,7)(40,11))
\pup(25,3){$g\circ f$}
\enddc
$$
The word commutative means that the result from going throught the
path $f$ plus $g$ is equal to the result from going throught the path
$g\circ f$. Most of the graphs used in Category Theory are digraphs which
we can specify in terms of its objects, and its arrows.
The (La)\TeX\ approach to typesetting can be characterized as
``logical design''~\cite{Knuth86,Lamport94,Otten99}, but commutative
diagrams are pieces of ``visual design'', and that, in our opinion is
the {\em piece de resistance} of commutative diagrams package
implementation in (La)\TeX. In a commutative diagrams package a user
seeks the simplest notation, a logical notation, with the most
powerful graphical engine possible, the visual part. The DCpic
package, along with the package by John
Reynolds~\cite{Feruglio94,Reynolds87}, has the simplest notation off
all the commutative diagrams packages described in the Feruglio
article~\cite{Feruglio94}. In terms of graphical capabilities the
\PiCTeX~\cite{Wichura87} package provides us with the best
\TeX-graphics engine, that is, without going to {\em Postscript}
specials.
The DCpic package depends only of \PiCTeX\ and \TeX,
which means that you can use it in all formats that are based on these
two. We have tested DCpic with \LaTeX, \TeX\ plain, pdf\LaTeX,
pdf\TeX~\cite{Thanh99}, and Con\TeX t~\cite{Otten99}; we are confident
that it can be used under many other formats.
The present version (3.1) of DCpic package is available in CTAN and in
the author's Web-page\footnote{http://www.mat.uc.pt/{\~{}}pedro/LaTeX/}.
\section{Constructing Commutative Diagrams}
DCpic depends on \PiCTeX, thus you must include an apropriate command
to load \PiCTeX\ and DCpic in your document,
e.g. ``{\tt $\backslash$usepackage\{dcpic,pictex\}}'', in a \LaTeX\ document.
A commutative diagram in DCpic is a ``picture'' in \PiCTeX, in which
we place our {\em objects} and {\em morphisms} (arrows). The user's
commands in DCpic are: {\tt begindc} and {\tt enddc} which establishe
the coordinate system where the objects will by placed; {\tt obj}, the
command which defines the place and the contents of each object; {\tt
mor}, and {\tt cmor}, the commands which define the morphisms, linear
and curved arrows, and its labels.
Now we will describe each of these commands in greater detail.
\subsection{The Diagram Environment}
The command {\tt begindc}, establishes a Cartesian coordinate system
with 1pt units,
\begin{alltt}
\(\backslash\)begindc[{\em}] \dots \(\backslash\)enddc
\end{alltt}
such a small unit gives us a good control over the placement of the
graphical objects, but in most of the diagrams not involving curved
arrows such a ``fine grain'' is not desirable, so the optional
argument specifies a magnifying factor $m\in\mathds{N}$, with a default
value of 30. The advantage of this decision is twofold: we can define
the ``grain'' of the diagram, and we can adjust the size of the
diagram to the available space.
\begin{itemize}
\item a ``course grain'' diagram is specified almost as a table, with
the numbers giving us the lines and the columns were the objects will
be placed, the following diagram has the default magnification factor:
\begin{center}
\begin{tabular}{cc}
\begindc{\commdiag}[300]
\obj(1,1){$A$}
\obj(3,1){$B$}
\obj(3,3){$C$}
\mor(1,1)(3,1){$f$}[\atright,\solidarrow]
\mor(1,1)(3,3){$g$}
\mor(3,1)(3,3){$h$}[\atright,\solidarrow]
\enddc &\tt
\begin{tabular}[b]{l}
$\backslash$begindc\{$\backslash$commdiag\}\\
$\backslash$obj(1,1)\{\$A\$\}\\
$\backslash$obj(3,1)\{\$B\$\}\\
$\backslash$obj(3,3)\{\$C\$\}\\
$\backslash$mor(1,1)(3,1)\{\$f\$\}[$\backslash$atright,$\backslash$solidarrow]\\
$\backslash$mor(1,1)(3,3)\{\$g\$\}\\
$\backslash$mor(3,1)(3,3)\{\$h\$\}[$\backslash$atright,$\backslash$solidarrow]\\
$\backslash$enddc
\end{tabular}
\end{tabular}
\end{center}
\item a ``fine grain'' diagram is a bit harder to design but it gives
us a better control over the objects placement, the following diagram
has a magnification factor of three, this gives us the capability of
drawing the arrows $f$ and $f^\prime$ very close together:
\begin{center}
\begin{tabular}{cc}
\begindc{\commdiag}[30]
\obj(10,10){$A$}
\obj(30,10){$B$}
\obj(30,30){$C$}
\mor(10,9)(30,9){$f$}[\atright,\solidarrow]
\mor(10,11)(30,11){$f^\prime$}
\mor(10,10)(30,30){$g$}
\mor(30,10)(30,30){$h$}[\atright,\solidarrow]
\enddc &\tt
\begin{tabular}[b]{l}
$\backslash$begindc\{$\backslash$commdiag\}[30]\\
$\backslash$obj(10,10)\{\$A\$\}\\
$\backslash$obj(30,10)\{\$B\$\}\\
$\backslash$obj(30,30)\{\$C\$\}\\
$\backslash$mor(10,9)(30,9)\{\$f\$\}[$\backslash$atright,$\backslash$solidarrow]\\
$\backslash$mor(10,11)(30,11)\{\$f{\^{}}$\backslash$prime\$\}\\
$\backslash$mor(10,10)(30,30)\{\$g\$\}\\
$\backslash$mor(30,10)(30,30)\{\$h\$\}[$\backslash$atright,$\backslash$solidarrow]\\
$\backslash$enddc
\end{tabular}
\end{tabular}
\end{center}
\item the magnification factor gives us the capability of adapting the
size of the diagram to the available space, without having to
redesign the diagram, for example the specification of the
next two diagrams differs only in the magnification factor: 30 for
the first; and 25 for the second.
\begin{center}
\begin{tabular}{cc}
\begindc{\commdiag}[300]
\obj(1,1){$A$}
\obj(3,1){$B$}
\obj(3,3){$C$}
\mor(1,1)(3,1){$f$}[\atright,\solidarrow]
\mor(1,1)(3,3){$g$}
\mor(3,1)(3,3){$h$}[\atright,\solidarrow]
\enddc &
\begindc{\commdiag}[250]
\obj(1,1){$A$}
\obj(3,1){$B$}
\obj(3,3){$C$}
\mor(1,1)(3,1){$f$}[\atright,\solidarrow]
\mor(1,1)(3,3){$g$}
\mor(3,1)(3,3){$h$}[\atright,\solidarrow]
\enddc
\end{tabular}
\end{center}
\end{itemize}
Note that the magnification factor does not interfere with the size of
the objects, but only with the size of the diagram as a whole.
After establishing our ``drawing board'' we can begin placing our
``objects'' on it, we have three commands to do so, the {\tt obj},
{\tt mor}, and {\tt cmor}, for objects, morphisms, and ``curved''
morphisms respectively.
\subsection{Objects}
Each object has a place and a content
\begin{alltt}
\(\backslash\)obj({\em},{\em})\{{\em}\}
\end{alltt}
the $x$ and $y$, integer values, will be multiplied by the magnifying
factor. The {\em contents} will be put in the centre of an ``hbox''
expanding to both sides of $(m\times x,m\times y)$.
\subsection{Linear Arrows}
Each linear arrow will have as mandatory arguments two pairs of
coordinates, the beginning and the ending points, and a label,
{\small\begin{alltt}
\(\backslash\)mor({\em},{\em})({\em},{\em})[{\em},{\em}]\{{\em