%% $Id: xy2cell.doc,v 3.3 1996/12/18 14:21:23 ross Exp $ %% %% Xy-pic ``2-cell'' feature. %% Copyright (c) 1993-1996 Ross Moore %% %% This file is part of the Xy-pic package for graphs and diagrams in TeX. %% See the companion README and INSTALL files for further information. %% Copyright (c) 1991-1996 Kristoffer H. Rose %% %% The Xy-pic package is free software; you can redistribute it and/or modify %% it under the terms of the GNU General Public License as published by the %% Free Software Foundation; either version 2 of the License, or (at your %% option) any later version. %% %% The Xy-pic package is distributed in the hope that it will be useful, but %% WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY %% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License %% for more details. %% %% You should have received a copy of the GNU General Public License along %% with this macro package; if not, write to the Free Software Foundation, %% Inc., 675 Mass Ave, Cambridge, MA 02139, USA. %% \ifx\xyloaded\undefined \input xy \fi \xyprovide{2cell}{Two-cell feature}{\stripRCS$Revision: 3.3 $}% {Ross Moore}{ross@mpce.mq.edu.au}% {Mathematics Department, Macquarie University, NSW~2109, Australia} \DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \noindent This feature is designed to facilitate the typesetting of curved arrows, either singly or in pairs, together with labels on each part and between. The intended mathematical usage is for typesetting categorical ``2-cell'' morphisms and ``pasting diagrams'', for which special features are provided. These features also allow attractive non-mathematical effects. \DOCMODE2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \paragraph*{Header:}\leavevmode \DOCHEADER \DOCMODE2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% The 2-cell feature makes use of facilities from the `curve' extension which is therefore automatically loaded. \DOCMODE( \xyrequire{curve}\xycatcodes \DOCMODE) \DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Typesetting 2-cells in Diagrams} \noindent Categorical ``2-cell'' morphisms are used in the study of tensor categories and elsewhere. The morphisms are displayed as a pair of curved arrows, symmetrically placed, together with an orientation indicated by a short broad arrow, or {\it Arrow}. Labels may be placed on all three components. \DOCMODE( \message{two-cells,} \DOCMODE) \UseAllTwocells \BUG: This document still uses version~2-style commmands, as described in appendix~??g[:v2]. \xyrequire{v2}\xycatcodes \xymatrixcolsep{5pc}% \xymatrixrowsep{2pc}% \begin{code} \diagram A\rtwocell^f_g &B\\ \enddiagram \end{code} $$ \docode $$ \displaycode \begin{code} \diagram A\ruppertwocell^f{\alpha} \rlowertwocell_h{\beta} \rto_(.35)g & B\\ \enddiagram \end{code} $$ \docode $$ \displaycode These categorical diagrams frequently have a matrix-like layout, as with commutative diagrams. To facilitate this there are control sequences of the form: |\rtwocell| , |\ultwocell| , |\xtwocell| , \dots\ analogous to the names defined in |xyv2| for use in diagrams produced using |xymatrix|. As this involves the definition of 21 new control sequences, many of which may never be used, these are not defined immediately upon loading |xy2cell|. Instead the user must first specify |\UseTwocells|. As in the second example above, just the upper or lower curved arrow may be set using control sequences of the form |\..uppertwocell| and |\..lowertwocell|. These together with the |\..compositemap| family, in which two abutting arrows are set with an empty object at the join, allow for the construction of complicated ``pasting diagrams'' (see figure ??[f.pasting] for an example). The following initialise the families of control sequences for use in matrix diagrams. \begin{defs} |\UseTwocells| &\quad two curves \cr |\UseHalfTwocells| &\quad one curve \cr |\UseCompositeMaps| &\quad 2 arrows, end-to-end \cr |\UseAllTwocells| &\quad (all the above) \cr \end{defs} \DOCMODE2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \DOCMODE( \xydef@\UseTwocells{\definesupermorphism{twocell}{% \xy@{start of 2-cell}{\begingroup}% \twocell@}} \xydef@\UseHalfTwocells{% \definesupermorphism{uppertwocell}{% \xy@{start of 2-cell}{\begingroup}% \uppertwocell@}% \definesupermorphism{lowertwocell}{% \xy@{start of 2-cell}{\begingroup}% \lowertwocell@}} \xydef@\UseCompositeMaps{\definesupermorphism{compositemap}{% \xy@{start composite-map}{\begingroup}% \compositemap@}} \xydef@\UseAllTwocells{% \UseTwocells \UseHalfTwocells \UseCompositeMaps } \DOCMODE) \DOCMODE2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% The families of connections are defined using the utility macro\dots % |\definesupermorphism| % which defines control sequences for morphisms between neighbouring cells, and next-to-neighbouring cells. More distant cells use |\xtwocell|, |\xcompositemap|, etc. with s e.g. |\xtwocell[1,3]| and |\xtwocell[llddd]|. \DOCMODE( \xydef@\supermorphism#1[#2]#3{\def\afterMORPHISM{[#2]#3}#1} \xydef@\afterMORPHISM{} \xydef@\definesupermorphism#1#2{% \expandafter\def\csname x#1\endcsname{\supermorphism{#2}}% \expandafter\def\csname u#1\endcsname{\supermorphism{#2}[-1,0]{}}% \expandafter\def\csname d#1\endcsname{\supermorphism{#2}[1,0]{}}% \expandafter\def\csname l#1\endcsname{\supermorphism{#2}[0,-1]{}}% \expandafter\def\csname r#1\endcsname{\supermorphism{#2}[0,1]{}}% \expandafter\def\csname uu#1\endcsname{\supermorphism{#2}[-2,0]{}}% \expandafter\def\csname dd#1\endcsname{\supermorphism{#2}[2,0]{}}% \expandafter\def\csname ll#1\endcsname{\supermorphism{#2}[0,-2]{}}% \expandafter\def\csname rr#1\endcsname{\supermorphism{#2}[0,2]{}}% \expandafter\def\csname ur#1\endcsname{\supermorphism{#2}[-1,1]{}}% \expandafter\def\csname ul#1\endcsname{\supermorphism{#2}[-1,-1]{}}% \expandafter\def\csname dr#1\endcsname{\supermorphism{#2}[1,1]{}}% \expandafter\def\csname dl#1\endcsname{\supermorphism{#2}[1,-1]{}}% \expandafter\def\csname uul#1\endcsname{\supermorphism{#2}[-2,-1]{}}% \expandafter\def\csname uur#1\endcsname{\supermorphism{#2}[-2,1]{}}% \expandafter\def\csname ull#1\endcsname{\supermorphism{#2}[-1,-2]{}}% \expandafter\def\csname urr#1\endcsname{\supermorphism{#2}[-1,2]{}}% \expandafter\def\csname ddl#1\endcsname{\supermorphism{#2}[2,-1]{}}% \expandafter\def\csname ddr#1\endcsname{\supermorphism{#2}[2,1]{}}% \expandafter\def\csname dll#1\endcsname{\supermorphism{#2}[1,-2]{}}% \expandafter\def\csname drr#1\endcsname{\supermorphism{#2}[1,2]{}}% \expandafter\def\csname uull#1\endcsname{\supermorphism{#2}[-2,-2]{}}% \expandafter\def\csname uurr#1\endcsname{\supermorphism{#2}[-2,2]{}}% \expandafter\def\csname ddll#1\endcsname{\supermorphism{#2}[2,-2]{}}% \expandafter\def\csname ddrr#1\endcsname{\supermorphism{#2}[2,2]{}}} \DOCMODE) \DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \bigskip Alternatively 2-cells can be set directly in \Xy-pictures without using the matrix feature. In this case the above commands are not needed. This is described in~\S??[standard]. Furthermore a new directional |\dir{=>}| can be used to place an ``Arrow'' anywhere in a picture, after the direction has been established appropriately. It is used with all of the 2-cell types. \DOCMODE( \newdir{=>}{!/5pt/\dir{=}!/2.5pt/\dir{=}*!/-5pt/\dir2{>}} \xydef@\arrowobject#1{\def\Arrowobject@{#1}} \xydef@\Arrowobject@{\dir{=>}} \DOCMODE) \DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %{\obeylines\long\outer\gdef\Pastingexample{% \begin{code} \xymatrixrowsep{1.5pc} \xymatrixcolsep{3pc} \diagram & & \relax\rtwocell<0>^{f_3^{}\;\;}{\omit} & \relax\ddtwocell<0>{\omit} \drtwocell<0>^{\;\;f_4^{}}{<3>} \ddrrtwocell<\omit>{<8>}\\ & & & &\relax\drtwocell<0>^{\;\;f_5^{}}{\omit}\\ A \uurrcompositemap<2>_{f_1^{}}^{f_2^{}}{<.5>} \uurrlowertwocell<-6>{\omit}\relax \drtwocell<0>_{g_1^{}\;}{\omit} & & & \relax\urtwocell<0>{\omit} & &\relax\rtwocell<0>^{f_6^{}\;}{\omit} & \relax\rlowertwocell<-3>_{g_4^{}}{<-1>} \rcompositemap<6>_{f_7^{}}^{f_8^{}}{\omit} & B \\ & \relax\urrtwocell<0>{\omit} \xcompositemap[-1,4]{}<-4.5>_{g_2^{}}^{g_3^{}}{\omit}\\ \enddiagram \end{code} \begin{figure*}[bt] $$ \docode $$ \caption{Pasting diagram.} ??=[f.pasting] \end{figure*} \DOCMODE2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \paragraph*{Default positions:} These set up default values for the parameters which specify the position of each component as well as the flags to indicate what type of 2-cell is to be typeset. \begin{defs1} \begin{tabular}{c l} |\toks6| &position of control point, normal to line $\overline{pc}$ at midpoint\\ |\toks5| &position of central Arrow\\ |\toks7| &position of |^| label\\ |\toks8| &position of |_| label\\ |\toks3| &flag for number of pieces... \\ \quad |f| & \underline{f}ull: i.e. both curved arrows\\ \quad |o| & \underline{o}ne: |\uppertwocell| or |\lowertwocell|\\ \quad |t| & \underline{t}wo maps: |\compositemaps|\\ \end{tabular} \end{defs1} \noindent |@| means to calculate from the value in |\toks6|, see |\tw@cell@@@|. \DOCMODE( \xydef@\twocell@{\toks6={3.5}\toks5={@}\toks7={@}\toks8={@}\toks3={f}% \tw@cell@ } \xydef@\uppertwocell@{\toks6={7}\toks5={@}\toks7={@}\toks8={@}\toks3={o}% \tw@cell@ } \xydef@\lowertwocell@{\toks6={-7}\toks5={@}\toks7={@}\toks8={@}\toks3={o}% \tw@cell@ } \xydef@\compositemap@{\toks6={3.5}\toks5={@}\toks7={@}\toks8={@}\toks3={t}% \tw@cell@ } \DOCMODE) This collects together all the relevant data, and resolves the default positions. \DOCMODE( \xydef@\tw@cell@@@{% \expandafter\ifx\the\toks6\omit\relax\toks6={}\else % % default position of label on upper arrow, % relative to where it meets the perpendicular bisector % \expandafter\ifx\expandafter @\the\toks7\relax\expandafter\dimen@\the\toks6\p@ \expandafter\if\the\toks3t\relax\dimen@=\p@ \else\expandafter\if\the\toks3o\divide\dimen@\tw@ \ifdim\dimen@<\z@ \dimen@ii-\p@ \advance\dimen@ii\dimen@ \dimen@=\dimen@ii \else \dimen@\p@ \fi \else\dimen@\p@ \fi\fi \edef\tmp@{\expandafter\removePT@\the\dimen@}% \expandafter\toks\expandafter7\expandafter{\tmp@}\fi % % default position of label on lower arrow, % relative to where it meets the perpendicular bisector % \expandafter\ifx\expandafter @\the\toks8\relax \expandafter\dimen@\the\toks6\p@ \expandafter\if\the\toks3t\relax\dimen@\p@ \else\expandafter\if\the\toks3o\divide\dimen@\tw@ \ifdim\dimen@<\z@ \dimen@ii-\p@ \advance\dimen@ii\dimen@ \dimen@=\dimen@ii \else \dimen@\p@ \fi \else\dimen@\p@ \fi\fi \edef\tmp@{\expandafter\removePT@\the\dimen@}% \expandafter\toks\expandafter8\expandafter{\tmp@}\fi % % default position of the Arrow, relative to midpoint % \expandafter\ifx\expandafter @\the\toks5\relax \expandafter\dimen@\the\toks6\p@ \expandafter\if\the\toks3o\divide\dimen@ by-4\relax \else\dimen@\z@\fi \edef\tmp@{\expandafter\removePT@\the\dimen@}% \expandafter\toks\expandafter5\expandafter{\tmp@}\fi \fi % % possible modifications for module maps % \twocellmod@ % % pass all the parameters to |\twocell@@@@| % \expandafter\if\the\toks3t\relax % % composed maps: ^ : first map _ : second map % \edef\tmp@{.[\noexpand\twocell@@@@{\the\toks6}{\the\toks5}% {\the\toks7}{\the\toks8}{\the\toks3}% {\the\toks2}{\the\toks1}{\the\toks@}{\the\toks4}!!!].\afterMORPHISM}% \else % % curved arrow(s) % \edef\tmp@{.[\noexpand\twocell@@@@{\the\toks6}{\the\toks5}% {\the\toks7}{\the\toks8}{\the\toks3}% {\the\toks1}{\the\toks2}{\the\toks@}{\the\toks4}!!!].\afterMORPHISM}% \fi \toks@={\endgroup}% \expandafter\def\expandafter\next@\expandafter{% \expandafter\def\expandafter\twocellhead@\expandafter{\twocellhead@}}% \expandafter\addtotoks@\expandafter{\next@}% \expandafter\def\expandafter\next@\expandafter{% \expandafter\def\expandafter\twocelltail@\expandafter{\twocelltail@}}% \expandafter\addtotoks@\expandafter{\next@}% \expandafter\addtotoks@\expandafter{\expandafter\twocellPATH\tmp@}% \the\toks@ }% \DOCMODE) See below for the possible forms of |\twocellPATH|. \DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Labels are placed labels on the upper and lower arrows, more correctly `anti-clockwise' and `clockwise', using |^| and |_|. These are entirely optional with the following token, or grouping, giving the contents of the label. When used with |\..compositemap| the |^| and |_| specify labels for the first and second arrows, respectively. \DOCMODE( \xydef@\twocellstyle{\scriptstyle} \xydef@\droptwocelllabel@#1{\xyFN@\droptwocelllabel@@#1@!} \xydef@\droptwocelllabel@@{% \ifx*\next\DN@*{\droptwocelldrop@}% \else\DN@##1@!{\droptwocelltext@{##1}}% \fi \next@ } {\xyuncatcodes \gdef\next#1{\drop+!C{\twocellstyle #1}}} \xylet@\droptwocelltext@=\next \xydef@\droptwocelldrop@#1@!{\bgroup \let\xy@=\oxy@ \let\objectstyle=\twocellstyle \drop#1{}% \edef\tmp@{\egroup \X@min=\the\X@min \X@max=\the\X@max \Y@min=\the\Y@min \Y@max=\the\Y@max}\tmp@ } \DOCMODE) Normally the label is balanced text, set in \TeX's math mode, with |\twocellstyle| setting the style. The default definition is given by \dots |\def\twocellstyle{\scriptstyle}| \noindent This can be altered using |\def| in versions of \TeX\ or |\redefine| in \LaTeX. However labels are not restricted to being simply text boxes. Any effect obtainable using the \Xy-pic kernel language can be set within an |\xybox| and used as a label. Alternatively if the first character in the label is |*| then the label is set as an \Xy-pic , as if with |\drop| or |*| in the kernel language. The current direction is tangential to the curved arrows. Extra braces are needed to get a |*| as the label, as in |^{{{*}}}| or |_{{}*}|. The position of a label normal to the tangential direction can also be altered by {\em nudging} (see below). Although it is possible to specify multiple labels, only the last usage of each of |^| and |_| is actually set, previous specifications being ignored. Similarly a label for the central Arrow must be given, after the other labels, by enclosing it within braces |{...}|. An empty group |{}| gives an empty label; this is necessary to avoid misinterpretation of subsequent tokens. As above if the first character is |*| then the label is set as an \XY-pic , the current direction being along the Arrow. \DOCMODE2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \paragraph*{Parsing:} Open a new group so the following registers can be used locally... |\toks@=\toks0|, |\toks1|, ..., |\toks8| the final parameter set is stored briefly in |\tmp@| before being used. OPTIONS: \begin{defs1} \begin{tabular}{c c l} && spaces are ignored \\ |<| & || &determines position of curves control point\\ & |<0>| &uses a single solid line,\\ & |<\omit>| &causes only the central Arrow (with label) to be set\\ \noalign{\smallskip} |\omit| &&omits the curved arrows, but allows their labels\\ |^| &&place ``above'' label (more correctly ``anti-clockwise'')\\ |_| &&place ``below'' label (more correctly ``clockwise'')\\ |~'| &&change the arrowhead \\ |~`| &&place/change the arrowtail\\ \end{tabular} \end{defs1} Label data e.g. |^{#1}| |_{#1}| is stored temporarily in |\toks@| then passed via |\tw@@cell@@| to |\tw@cell@@| for further parsing, as: |\the\toks@ @| |~'| and |~`| change the values of |\twocellhead@| and |\twocelltail@| Normally |\twocelltail@| is |{}|, so |~`| also changes a flag to indicate that |\twocelltail@| is indeed required. When the next token is a grouping |{...}| then it gives the label for the central Arrow. No other label specifications may follow. Default head and tail ornaments... \DOCMODE( \xydef@\twocellhead#1{\def\twocellhead@{#1}} \xydef@\twocelltail#1{\def\twocelltail@{#1}} \xydef@\twocellhead@{\dir{>}} \xydef@\twocelltail@{} \DOCMODE) clear |\toks..| registers for the new connection labels. \DOCMODE( \xywarnifdefined\twocellmod@ \xydef@\tw@cell@{\begingroup \toks@={{}}\toks1={{}}\toks2={{}}\toks4={{}}% \def\twocellmod@{}\xyFN@\tw@@cell@}% \xydef@\tw@@cell@{% \ifx\space@\next\expandafter\DN@\space{\xyFN@\tw@@cell@}% \else\ifx\bgroup\next \let\next@=\toks@\afterassignment\tw@@cell@@ \else\ifx ^\next \DN@^##1{\toks@={##1}\nudgepos@71\tw@@cell@}% \else\ifx _\next \DN@_##1{\toks@={##1}\nudgepos@82\tw@@cell@}% \else\addLT@\ifx \next \addGT@{\addLT@\DN@##1}{% \toks6={##1}\ifx\omit##1\relax\toks3={t}\toks5={0}\fi\xyFN@\tw@@cell@}% \else\ifx\omit\next \DN@\omit{\omitarrows@\xyFN@\tw@@cell@}% \else\ifx~\next \DN@~{\xyFN@\whichCurveObject@}% \else \DN@{\xyFN@\tw@cell@@\empty @}% \fi\fi\fi\fi\fi\fi\fi% \next@ } \xydef@\whichCurveObject@{% \ifx\space@\next\expandafter\DN@\space{\xyFN@\whichCurveObject@}% \else\ifx\next^\DN@^##1{\xy@{~^{##1}}{\uppercurveobject{##1}}\xyFN@\tw@@cell@}% \else\ifx\next_\DN@_##1{\xy@{~_{##1}}{\lowercurveobject{##1}}\xyFN@\tw@@cell@}% \else\addRQ@\ifx\next \addRQ@\DN@##1{% \xy@{~'{##1}}{\def\twocellhead@{##1}}\xyFN@\tw@@cell@}% \else\addLQ@\ifx\next \addLQ@\DN@##1{% \xy@{~`{##1}}{\def\twocelltail@{##1}}\xyFN@\tw@@cell@}% \else\ifx!\next \DN@!{\xyFN@\checkmodmap@}% \else\ifx\next\bgroup\DN@##1{\xy@{~{##1}}{\curveobject{##1}}\xyFN@\tw@@cell@}% \else\DN@##1{\xy@{~##1}{\curveobject{##1}}\xyFN@\tw@@cell@}% \fi\fi\fi\fi \fi\fi\fi \next@ } \xydef@\checkmodmap@{% \ifx\space@\next\expandafter\DN@\space{\xyFN@\checkmodmap@}% \else \def\twocellmod@{\modmap@}% \ifx\next!\DN@!##1{% \xy@{~!!{##1}}{\def\modmapobject@{##1}}\xyFN@\tw@@cell@}% \else \DN@{\xyFN@\tw@@cell@}\fi \fi \next@ } \DOCMODE) With no arrows, still allow labels: default positions are at $0$, $+X$, $-X$, with $X=${\em default value}. These values are altered by ``nudging''. \DOCMODE( \xydef@\omitarrows@{\toks5={0}\toks6={}\toks7={0}\toks8={0}} \DOCMODE) \DOCMODE3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{figure*}[tp] \begin{syntax} % &\iss & <2-cell> & typeset <2-cell> with the and \cr \noalign{\smallskip} % <2-cell> &\iss & |\..twocell| & typeset two curved arrows \cr &\orr & |\..uppertwocell| & typeset upper curved arrow only \cr &\orr & |\..lowertwocell| & typeset lower curved arrow only \cr &\orr & |\..compositemap| & use consecutive straight arrows \cr \noalign{\smallskip} % &\iss & |{||}| & specifies orientation and label \cr &\orr & |{||}| & adjust position, use default orientation \cr &\orr & |{||}| & use default position and orientation \cr &\orr & |{|*|}| & use as the label \cr &\orr & |{|*|}| \orr |{|*|}| \cr \noalign{\smallskip} % &\iss & |^| \orr |_| \orr |=| & oriented anti-/clockwise/equality \cr &\orr & |\omit| & no Arrow, default is clockwise \cr &\orr & |`| \orr |'| \orr |"| \orr |!| & no Arrow; tips on two curved arrows as:\\ anti-/clockwise/double-headed/none \cr \noalign{\smallskip} % &\iss & & list of optional modifications \cr \noalign{\smallskip} % &\iss & & use defaults \cr % &\orr & |^|