#LyX 1.3 created this file. For more info see http://www.lyx.org/ \lyxformat 221 \textclass article \begin_preamble \usepackage[all]{xy} \makeatletter \newcommand{\xyR}[1]{ \makeatletter \xydef@\xymatrixrowsep@{#1} \makeatother } \makeatletter \newcommand{\xyC}[1]{ \makeatletter \xydef@\xymatrixcolsep@{#1} \makeatother } \newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}} \end_preamble \language english \inputencoding auto \fontscheme ae \graphics default \paperfontsize default \spacing single \papersize a4paper \paperpackage a4 \use_geometry 0 \use_amsmath 0 \use_natbib 0 \use_numerical_citations 0 \paperorientation portrait \secnumdepth 3 \tocdepth 3 \paragraph_separation indent \defskip medskip \quotes_language english \quotes_times 2 \papercolumns 1 \papersides 1 \paperpagestyle default \layout Title Using \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -pic in LyX \layout Author H. Peter Gumm \layout Abstract With the current version of LyX and with the \family typewriter preview \family default -style installed in the LaTeX-System, the graph drawing package \family typewriter \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset \family default -Pic can now be conveniently used inside LyX. Diagrams can be edited and displayed inside the main LyX editing window. Here, we shall describe how to use the \family typewriter \backslash xymatrix \family default command from \family typewriter xypic \family default inside LyX in order to draw, to edit and to preview diagrams as typically used in category theory, algebra, and related fields. \layout Abstract \begin_inset LatexCommand \tableofcontents{} \end_inset \layout Section Introduction \layout Standard The \family typewriter xypic \family default -package has long served as a convenient tool for easily constructing graphs and diagrams in LaTeX. Unfortunately, its use in LyX had long been restricted to the infamous ERT-boxes, meaning that the LyX editor could only display the LaTeX-source and not the finished diagram. The new \family typewriter preview \family default -style of LaTeX which is part of the AUCTeX project \begin_inset LatexCommand \cite{AUCTeX} \end_inset , finally enables the editing and displaying of \family typewriter xypic \family default -diagrams, constructed, displayed and interactively edited inside LyX. \layout Standard \begin_inset Graphics filename xyfigure.PNG scale 62 clip \end_inset \layout Standard In this note, we describe how \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -pic can be used from inside LyX, how diagrams can be created and edited. We have tested the following using LyX version 1.3.7, running under WindowsXP. \layout Standard There are two modes of operations: For a start, and for some first tests, it may be easiest to first enter the \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -Pic code inside the LyX-window, select it all and convert it to a graphical representation by pressing Ctrl-m or Ctrl-M. If you use \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -Pic more frequently, or if you want to modify your initial figure, you will want to assemble and modify your figures using LyX's math editor. This is shown in blue in the above figure: Once the cursor is moved over a diagram, this is displayed as an array of nodes and arrow-commands. These can be changed interactively. When the cursor leaves the editing area, the diagram reappears. \layout Standard In the first two sections of this documentation, we explain how to use LyX in the first mentioned mode and introduces all \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -Pic features that might be of use for drawing commutative diagrams, graphs or automata. Section 3 explains how to use the \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -Pic commands inside a math-editing area. \layout Standard It is not our intention to write another introduction to \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -Pic, rather our motivation is to give an introduction how the most important commands work inside LyX, since the keystrokes as explained in the \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -Pic manual \begin_inset LatexCommand \cite{xypic manual} \end_inset will not always function correctly inside LyX. \layout Section Preparation \layout Standard The following requires that the LaTeX-packages \family typewriter xypic \family default and \family typewriter preview \family default are installed in the LaTeX system. They are available from CTAN, see at \begin_inset LatexCommand \cite{instant-preview} \end_inset , resp. at \begin_inset LatexCommand \cite{xypic} \end_inset . After freshly installing them, it may be necessary, to run \family sans Edit\SpecialChar \menuseparator Reconfigure \family default from the main LyX menu. The steps to a first diagram output in LyX are then: \layout Enumerate Activate and test \family typewriter preview \begin_deeper \layout Enumerate Open LyX, choose \family sans Edit\SpecialChar \menuseparator Preferences\SpecialChar \menuseparator Look and Feel\SpecialChar \menuseparator Graphics \family default and place a check-mark at \emph on Instant Preview \emph default . \family sans \layout Enumerate Test, if \family typewriter instant-preview \family default works by opening a LyX-document and entering any math-formula, e.g. \begin_inset Formula $a+b=c$ \end_inset . \layout Enumerate Move the cursor out of the formula, and watch it change its appearance to look just like in the finished dvi- or postscript document. \end_deeper \layout Enumerate Activate and test \family typewriter xypic \begin_deeper \layout Enumerate Choose \family sans Layout\SpecialChar \menuseparator Document\SpecialChar \menuseparator Preamble \family default and type \family typewriter \newline \backslash usepackage[all]{xy}. \layout Enumerate Inside your LyX-Document, enter the text \family typewriter \newline \backslash xymatrix{A \backslash ar[r] & B} \family default . \layout Enumerate Select the whole text and choose \family sans Insert\SpecialChar \menuseparator Math\SpecialChar \menuseparator Display Formula \family default , or use the corresponding keyboard shortcut \family sans Ctrl-M \family default . \layout Enumerate Move the mouse cursor out of the editing box and wait for a split second to see an arrow appear: \begin_inset Formula $\xymatrix{A\ar[r] & B} $ \end_inset . \end_deeper \layout Section Commutative diagrams \layout Standard The following diagram, which is taken from the documentation of \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -Pic \begin_inset LatexCommand \cite{xypic manual} \end_inset by its creator Kristoffer H. Rose, will provide an example for many of the features available with that package. Its source code is: \layout LyX-Code \backslash xymatrix{ \newline U \backslash ar@/_{1pc}/[ddr]_ \backslash psi \backslash ar@/^{1pc}/[drr]^ \backslash varphi \newline \backslash ar@{.>}[dr]|-{(x,y)} \backslash \backslash \newline & X \backslash times_Z Y \backslash ar[d]^q \backslash ar[r]_p & X \backslash ar[d]_f \backslash \backslash \newline & Y \backslash ar[r]^g & Z } \layout LyX-Code \layout Standard Again, to turn this code into a graphical output, select it all at once starting from the \family typewriter \backslash xymatrix{ \family default \SpecialChar \ldots{} up to the closing brace \SpecialChar \ldots{} \family typewriter } \family default and turn it into display-math as explained above. A moment after the cursor leaves the math-area, you should see the diagram in its full graphical glory as shown below. \layout Standard \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\ & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\ & Y\ar[r]^{g} & Z} $ \end_inset \layout Subsection The matrix layout of diagrams \layout Standard \family typewriter xymatrix \family default uses a matrix to define the layout of the vertices of a diagram. For the above example, we need a \begin_inset Formula $3\times3$ \end_inset -matrix of which 5 entries are used for the vertices \begin_inset Formula $U$ \end_inset , \begin_inset Formula $X\times_{Z}Y$ \end_inset , \begin_inset Formula $X$ \end_inset , \begin_inset Formula $Y$ \end_inset , \begin_inset Formula $Z$ \end_inset , the other positions remaining empty. In this case, the following matrix determines the layout: \layout LyX-Code \backslash xymatrix{ \newline U \backslash \backslash \newline & X \backslash times_Z Y & X \backslash \backslash \newline & Y & Z } \layout Standard The pattern should be familiar from LaTeX: We see three rows, each row being terminated by the end-of-line-marker \family typewriter \backslash \backslash \family default . Each line consists of entries, separated by the ampersand \family typewriter & \family default . \layout Subsection Arrows \layout Standard Having entered the vertices, we add arrows between them. The basic \family typewriter xypic \family default -command to produce an arrow is \family typewriter \backslash ar \family default , it is entered into the cell of the matrix where the arrow is to start. The target of the arrow is defined by direction commands \family typewriter u \family default (up) \family typewriter d \family default (down) \family typewriter l \family default (left), or \family typewriter r \family default (right). These can be combined to a path and enclosed in square brackets. As an example, the arrows from the vertex \begin_inset Formula $U$ \end_inset in the upper left corner down and right to the vertices \begin_inset Formula $X\times_{Z}Y$ \end_inset , \begin_inset Formula $Y$ \end_inset , and \begin_inset Formula $X$ \end_inset are, respectively, defined as \family typewriter \backslash ar[dr] \family default , \family typewriter \backslash ar[ddr] \family default and \family typewriter \backslash ar[drr] \family default . Thus the above diagram with all arrows added becomes: \layout LyX-Code \backslash xymatrix{ \newline U \backslash ar[ddr] \backslash ar[drr] \backslash ar[dr] \backslash \backslash \newline & X \backslash times_Z Y \backslash ar[d] \backslash ar[r]& X \backslash ar[d] \backslash \backslash \newline & Y \backslash ar[r] & Z } \layout Standard \begin_inset Formula \xymatrix{ U \ar[ddr] \ar[drr] \ar[dr]\\ & X \times_{Z} Y \ar[d] \ar[r] & X \ar[d]\\ & Y \ar[r] & Z } \end_inset \layout LyX-Code \layout LyX-Code \layout Subsection Labels \layout Standard Labels are attached to arrows by affixing them as upper or lower indices to the \family typewriter \backslash ar \family default -command. Thus, \family typewriter \backslash ar[drr]^ \backslash varphi \family default defines an arrow going one cell down, two to the right and having the label \begin_inset Formula $\varphi$ \end_inset attached above. To attach a label below the arrow, make it a lower index as in \family typewriter \backslash ar[ddr]_ \backslash psi \family default . This explanation is correct only for arrows pointing to the right. More precisely, imagine looking along the arrow in the direction it is pointing. Then an upper index places a label to the left and a lower index places it to the right. Consequently, an arrow pointing from right to left, such as \family typewriter \backslash ar[l]^ \backslash alpha_ \backslash beta \family default will have label \begin_inset Formula $\alpha$ \end_inset below and label \begin_inset Formula $\beta$ \end_inset above the arrow, i.e. \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.} $ \end_inset Using the character | instead of ^ or _ , it is even possible to place the label right onto the arrow, obscuring part of its shaft. \layout Standard Normally, a label is placed halfway between an arrow's start and target objects. In the first diagram, the central arrow starting in \begin_inset Formula $U$ \end_inset has the label \begin_inset Formula $(x,y)$ \end_inset in the middle of the arrow's shaft, rather than in the middle between the two objects it connects. This is achieved by prefixing the label with a minus sign, here: \family typewriter \backslash ar[dr]|-{(x,y)} \family default . \layout LyX-Code \backslash xymatrix{ \newline U \backslash ar[ddr]_ \backslash psi \backslash ar[drr]^ \backslash varphi \backslash ar[dr]|-{(x,y)} \backslash \backslash \newline & X \backslash times_Z Y \backslash ar[d]^q \backslash ar[r]_p& X \backslash ar[d]_f \backslash \backslash \newline & Y \backslash ar[r]^g & Z } \layout LyX-Code \begin_inset Formula \xymatrix{ U \ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\ & X \times_{Z} Y \ar[d]^{q} \ar[r]_{p} & X \ar[d]_{f}\\ & Y \ar[r]^{g} & Z } \end_inset \layout Standard \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -pic normally permits labels to be shifted towards the tip or towards the end of an arrow by prefixing the label with a ratio, such as e.g. \family typewriter (.3) \family default . In LyX this works only for labels which are placed on top of the arrow, such as \family typewriter \backslash ar[r]|(0.3){ \backslash phi} \family default . The form \family typewriter \backslash ar[r]|-{(x,y)} \family default used above guarantees that the label is placed at the midpoint of the arrow rather than at the midpoint between the nodes connected by the arrow. \layout Standard For labels placed to the left or to the right of the arrow this does not work. The corresponding \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -pic code such as e.g. \family typewriter \backslash ar[r]^(.3)p \family default is not correctly interpreted by LyX's math editor. A workaround is suggested in the last section of this note. \layout Subsection Arrow modification \layout Standard Modification of the design, the form or the positioning of arrows are introduced by the \family typewriter @ \family default -character. This is followed by a pair of matching brackets, where the form of the bracket pair, \family typewriter { } \family default or \family typewriter < > \family default or \family typewriter / / \family default indicates, whether we want to modify the design, the shift or the curvature of the arrow. Various modifactions can be applied to an arrow at the same time. \layout Subsubsection Arrow design \layout Standard Various designs such as \emph on solid \emph default , \emph on dotted \emph default , \emph on dashed \emph default or \emph on double \emph default are possible for the shaft of an arrow. These can be combined with various ends and various tips. In general, the design of an arrow is described by following the command \family typewriter \backslash ar \family default immediately by an \family typewriter @ \family default -sign and a pair of braces {\SpecialChar \ldots{} } containing characters describing the end, the shaft and the tip of the arrow. These characters are chosen to give some form of ASCII-rendering of the real thing. For instance \family typewriter \backslash ar@{>..>>} \family default produces an arrow with split end, a dotted shaft and double head. A number of other arrow designs is given in the table below. Note that the ends of embedding arrows \begin_inset Formula $\xymatrix{A\ar@{^{(}->}[r] & B} $ \end_inset are described by raising or lowering opening parentheses, such as in \family typewriter \backslash ar@{^(->}[r]. \newline \layout Standard \begin_inset Tabular \begin_inset Text \layout Standard Result \end_inset \begin_inset Text \layout Standard Source code in LyX \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar@{-->}[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar@{-->} \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar@{..>}[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar@{..>} \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar@{~>}[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar@{~>} \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar@{->>}[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar@{->>} \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar@{-->>}[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar@{-->>} \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar@{>->>}[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar@{>->>} \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar@{_{(}->}[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar@{_(->} \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar@{^{(}->}[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar@{^(->} \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar@{|-|}[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar@{|-|} \end_inset \end_inset \layout Standard \begin_inset ERT status Inlined \layout Standard \backslash noindent \end_inset Following the @-character by either a 2, 3, _,or a ^, we can produce arrows with double, triple shaft or arrows showing only the lower or upper half of their tips and ends. Arrows need not have tips nor ends, as the last example shows : \newline \layout Standard \begin_inset Tabular \begin_inset Text \layout Standard Result \end_inset \begin_inset Text \layout Standard Source code for LyX \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar@2[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar@2 \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar@3[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar@3 \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar@_{->}[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar@_{->} \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar@^{->}[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar@^{->} \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar@^{>>->>}[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar@^{>>->>} \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar@{^{<}-_{>}}[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar@{^<-_>} \end_inset \begin_inset Text \layout Standard \begin_inset Formula \xymatrix{\ \ar@2{--}[r] & \ } \end_inset \end_inset \begin_inset Text \layout Standard \family typewriter \backslash ar@2{--} \end_inset \end_inset \layout Subsubsection Designing your own arrows \layout Standard Within certain limits there is even a way to design your own arrows. Using some the characters \family typewriter ><|ox+/()[ \family default one can even design one's own arrow tips using the \family typewriter \backslash newdir \family default command in the preample. For explanations, we refer to the \family typewriter \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset \family default -manual, from which we take the example: \layout Standard \family typewriter \backslash newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}} \family default . \layout Standard \begin_inset ERT status Inlined \layout Standard \backslash noindent \end_inset This defines a new arrow tip, referred to as \family typewriter |> \family default in \family typewriter \backslash ar@{-|>}[r] \family default and which displays correctly in LyX as: \begin_inset Formula \[ \xymatrix{A\ar@{-|>}[r] & \ \ B} \] \end_inset \layout Subsection Arrow positioning \layout Standard Arrows are shifted sideways with the modifier \family typewriter @< \family default \begin_inset Formula $\ldots$ \end_inset \family typewriter > \family default where the ellipsis is replaced by a positive or negative measure. For instance, to design a pair of mutually opposing arrows between two nodes, we shift them to see them apart. Note that the direction of the shift (positive) is to the left if one looks along the arrow. Thus \layout Standard \family typewriter \backslash [ \backslash xymatrix{ \backslash circ \backslash ar@<1ex>[r]& \backslash circ \backslash ar@<1ex>[l]} \backslash ] \layout Standard \begin_inset ERT status Inlined \layout Standard \backslash noindent \end_inset produces \begin_inset Formula \[ \xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]} \] \end_inset \layout Subsubsection Inline or centered diagrams \layout Standard Arrows and diagrams can be used inline, as this one: \begin_inset Formula $\xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]} $ \end_inset . For this they should be placed inside an inline math-environment $ \begin_inset Formula $\ldots$ \end_inset $ or \backslash ( \begin_inset Formula $\ldots$ \end_inset \backslash ). To center a diagram, put it inside display-math parentheses \family typewriter \backslash [ \family default and \family typewriter \backslash ] \family default . Diagrams constructed inline can later be centered, or, conversely, centered diagrams can be changed to inline formulas with \family sans Edit\SpecialChar \menuseparator Math \family default \family sans \SpecialChar \menuseparator Alignment. \layout Subsection Bending arrows \layout Standard There are two simple methods to make arrows bend. The first is giving an explicit value by which the midpoint of the arrow's shaft is raised or depressed, the other is by forcing the arrow to leave its origin in a prescribed compass direction and to make him enter the target at another direction. The necessary bending of the arrow is determined automatically. We describe both methods. \layout Subsubsection Raising the shaft \layout Standard For bending arrows we use the modifier @/ \begin_inset Formula $\ldots$ \end_inset / . The ellipsis stands for a TeX-measure which needs to be entered as a lower or upper index. Whereas in \family typewriter xypic \family default , we could simply write, e.g. \family typewriter \backslash ar@/_1pc/ \family default for an arrow bending \family typewriter 1pc \family default downwards, this cannot directly be done in LyX. It is necessary, to enclose the measure in a pair of braces, such as e.g. \family typewriter \backslash ar@/_{1pc}/ \family default . As an example, here are two opposing arrows between \begin_inset Formula $A$ \end_inset and \begin_inset Formula $B$ \end_inset , each bending by .5 pica, given by the following source code: \layout Standard \family typewriter \backslash [ \backslash xymatrix{A \backslash ar@/_{.5pc}/[r] & B \backslash ar@/_{.5pc}/[l]} \backslash ] \layout Standard \begin_inset Formula \[ \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]} \] \end_inset \layout Subsubsection Specifying exit- and entrance directions. \layout Standard An alternative for making arrows bend is by specifying their compass direction as they are leaving their source and their direction from which they enter their target. Instead of north, north-east, east, etc., the directions are named \family typewriter u \family default , \family typewriter ur \family default , \family typewriter r \family default , \family typewriter dr \family default , \family typewriter d \family default , \family typewriter dl \family default , \family typewriter l \family default , \family typewriter ul \family default , standing for up, up-right, right, down-right, etc.. A direction is specified as @( \emph on out \emph default , \emph on in \emph default ) where \emph on out \emph default stands for the direction the first object is left and \emph on in \emph default stands for the direction from which the target is entered. As an example, we show some bending arrows and a loop, which arises when we do not specify a target for an arrow, just its incoming and outgoing direction: \layout Standard \begin_inset Formula \[ \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\ E\ar@(ul,ur)} \] \end_inset \layout LyX-Code \backslash [ \backslash xymatrix{A \backslash ar@(dr,dl)[r] \backslash ar@(dr,dl)[rr] \newline &B \backslash ar@(d,r)[dl] &C \backslash \backslash \newline E \backslash ar@(ul,ur)} \backslash ] \layout Subsection Modifying vertices \layout Standard The above example is reminiscent of an automata diagram, except that in such a diagram states would be enclosed in small circles, with double circles denoting final states. \layout Subsubsection Framing objects \layout Standard With \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -Pic, entries can obtain a single or a double frame, such as \begin_inset Formula $\xymatrix{*+[F]{A}} $ \end_inset or \begin_inset Formula $\xymatrix{*+[F=]{B}} $ \end_inset by prefixing an entry with \family typewriter *[F-] \family default or \family typewriter *[F=] \family default and enclosing the portion of the entry to be framed in braces. Normally, the frame will be very tight so that it must be widened by prefixing with \family typewriter + \family default or with \family typewriter ++ \family default . Round frames, such as \begin_inset Formula $\xymatrix{*++[o][F]{A}} $ \end_inset and \begin_inset Formula $\xymatrix{*++[o][F=]{B}} $ \end_inset are obtained by specifying the shape as \family typewriter [o]. \family default So the latter figure was constructed as *++[o][F=]{B}. This way, the following automaton \layout Standard \begin_inset Formula \[ \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]} \] \end_inset \layout Standard \begin_inset ERT status Inlined \layout Standard \backslash noindent \end_inset can be typeset as \layout LyX-Code \backslash [ \backslash xymatrix{ \backslash txt{start} \backslash ar[r] \layout LyX-Code & *++[o][F]{1} \backslash ar[r] \layout LyX-Code & *++[o][F=]{2} \backslash ar@(ur,dr) \backslash ar@(ur,ul)[l] \layout LyX-Code } \backslash ]. \layout Standard The LaTeX command \family typewriter \backslash entrymodifiers={ \family default \SpecialChar \ldots{} \family typewriter } \family default will make a certain entry style the default, that can, of course be overridden for individual entries. Thus, after \family typewriter \backslash entrymodifiers={++[o][F-]} \family default , all following entries inside \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -matrices would be encircled. \layout Section Using LyX's math editor \layout Standard As an alternative to writing the \family typewriter xypic \family default code, then transforming it into a math-editing environment by marking it and applying \family sans Ctrl-m \family default , or \family sans Ctrl-M \family default , one may construct and modify the whole xypic-diagram inside LyX's math editor. We describe the editing steps for a figure just like the one above. \layout Subsection Caveat - how to enter braces \layout Standard Recall that in LyX's math-editor any pair of braces \family typewriter { \family default and \family typewriter } \family default that are to enclose a macro-parameter must be entered by typing just \family typewriter \backslash { \family default . The closing brace is automatically supplied and in between a box into which to the parameter is entered. In connection with \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -diagrams, this applies in particular to arrow modifications that are normally given in the form \family typewriter @{ \family default \SpecialChar \ldots{} \family typewriter } \family default with the ellipsis standing for the description of end, shaft and tip of the arrow. Inside the math-editor, enter just \family typewriter @ \backslash { \family default and let LyX provide the closing brace and the box into which to enter the description of the arrow. \layout Standard Braces that are entered without the backslash \family typewriter \backslash \family default will just appear as typed, but cannot be used to receive a macro parameter. They are useful, for instance to denote sets, e.g. \family typewriter {x \backslash in X \backslash mid x \backslash notin x} \family default will display as \begin_inset Formula $\{ x\in X\mid x\notin x\}$ \end_inset . \layout Subsection Setting up the matrix \layout Standard With \family sans Ctrl-m \family default or \family sans Ctrl-M \family default open a formula environment and enter: \family typewriter \backslash xymatrix \family default . This produces a 1 \begin_inset Formula $\times$ \end_inset 1- \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -matrix. Add extra rows by typing \family sans Ctrl-Enter \family default and add columns by typing \family sans Alt-m c i. \layout Standard At any time, further rows or columns can be entered or deleted using commands available from \family sans Edit\SpecialChar \menuseparator Math, \family default resp. their shortcuts, beginning with \family sans Alt-m c \family default for the column commands or \family sans Alt-m w \family default for the row commands. \begin_inset Foot collapsed false \layout Standard Note that in the keyboard shortcuts starting with \family sans M \family default - the letter \family sans M \family default stands for a \begin_inset Quotes eld \end_inset Meta \begin_inset Quotes erd \end_inset -key, which in Windows translates to the Alt-key. Similarly in shortcuts listed as starting with \family sans C \family default -, the \family sans C \family default stands for \family sans Ctrl \family default . \end_inset \layout Subsection Entering nodes, arrows and labels \layout Standard Type the nodes into the correct positions of the matrix. If you move the cursor out of the matrix, you should see a first rendering of the node layout. Next, add the arrows at the nodes from where they should emanate by typing \family typewriter \backslash ar[ \family default \emph on p \family typewriter \emph default ] \family default , where \emph on p \emph default can be any path made up from the characters \family typewriter u \family default , \family typewriter d \family default , \family typewriter l \family default , \family typewriter r \family default . Make sure that the path indeed leads to a node available within the matrix. Otherwise, the figure will not display as the cursor leaves the editing area. \layout Standard Next, label the arrows by attaching them as upper or lower indices to the end of their path. As always, in LyX's math editor, an underscore \family typewriter _ \family default opens a box for a lower index and a \family typewriter ^ \family default followed by a space opens a box for an upper index. You can enter any LaTeX-code as a label. \layout Subsection Modifying arrows \layout Standard Finally, modify the appearance of the arrows by entering @-modifiers @{\SpecialChar \ldots{} }, @<\SpecialChar \ldots{} >, @(\SpecialChar \ldots{} ,\SpecialChar \ldots{} ) or @/\SpecialChar \ldots{} /. The above caveat applies to the first form only. It must be entered as \family typewriter @ \backslash { \family default with the arrow description entered inside the LyX-supplied box. If this box remains empty, you have specified an empty arrow. This is a useful construction, too, as you will see in the next section. \layout Standard The other modifiers, @<\SpecialChar \ldots{} >, @(\SpecialChar \ldots{} ,\SpecialChar \ldots{} ) and @/\SpecialChar \ldots{} / are typed as shown with the arrow description replacing the ellipsis. The code for bending arrows, which in \family typewriter xypic \family default is @/_ \emph on measure \emph default / or @/ \emph on ^measure \emph default / where \emph on measure \emph default is any valid TeX-measure, should be entered as upper or lower index to the first slash / . Make sure that the ending slash does not end up with the upper or lower index. \layout Subsection What if something goes wrong \layout Standard When constructing a diagram, you should at times check it by just moving the cursor out of the editing area to see whether instant preview can successfu lly convert it into graphical output. If this does not happen, it may either be that instant preview for some reason is not aware that it should modify retranslate the graphics. Moving the cursor into the editing area and out again should wake up instant preview. \layout Standard A more serious reason could be a syntactical error in your input. If necessary, redo the last editing steps, using Ctrl-z, or try to translate the LyX-file into dvi using Ctrl-d or \family sans View\SpecialChar \menuseparator Dvi \family default . There should be some error generated, which hopefully gives you a hint as to the source of the mistake. \layout Section Hacks \layout Standard Certain things do not work correctly inside LyX. The ones that we (used to) miss most are the horizontal and vertical scaling of diagrams, and the correct positioning of arrows. After some experimentation, we have found workarounds that we are explaining here. \layout Subsection Horizontal and vertical scaling \layout Standard It is often convenient to stretch the horizontal or vertical dimensions of a diagram by using spacing commands for rows and/or columns. According to the \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -manual, for instance, \family typewriter \backslash xymatrix@R=1pc{ \family default \SpecialChar \ldots{} \family typewriter } \family default defines an \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -matrix with row spacing of 1 pica. Similarly, \family typewriter \backslash xymatrix@C= \family default \SpecialChar \ldots{} \family typewriter { \family default \SpecialChar \ldots{} \family typewriter } \family default allows to modify the space between columns. Unfortunately, these commands do currently not work inside LyX, as the @-character is interpreted by LyX as ending the \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -matrix-macro. \layout Standard Knowing that \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset stores the values for row-spacing and column-spacing in the variables \family typewriter \backslash xymatrixrowsep@ \family default and \family typewriter \backslash xymatrixrowsep@ \family default , add the following macro to the preamble ( \family sans Layout\SpecialChar \menuseparator Document\SpecialChar \menuseparator Preamble) \layout LyX-Code \backslash makeatletter \layout LyX-Code \backslash newcommand{ \backslash xyR}[1]{% \layout LyX-Code \backslash makeatletter \layout LyX-Code \backslash xydef@ \backslash xymatrixrowsep@{#1} \layout LyX-Code \backslash makeatother \layout LyX-Code } % end of \backslash xyR \layout LyX-Code \layout Standard A macro \family typewriter \backslash xyC \family default can be defined correspondingly by replacing \family typewriter \backslash xymatrixrowsep@ \family default with \family typewriter \backslash xymatrixcolsep@ \family default . Now, a figure can be scaled by entering \backslash xyR{...} into the \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -matrix. Place the cursor inside the matrix, just before the first entry. Then enter \family typewriter \backslash xyR \backslash { \family default or \family typewriter \backslash xyC \backslash { \family default or both. Dont't forget the backslashes and remember, that the closing brace is automatic ally supplied by LyX. Inside the braces enter the dimensions. The default is \family typewriter 2pt \family default . Here you see a diagram which is squashed vertically and stretched horizontally with \family typewriter \backslash xyR{9pc} \backslash xyC{.5pc} \family default : \layout Standard \begin_inset Formula \[ \xyC{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\ C\ar@{}[ur]|{\text{{horizontal stretch}}}} \] \end_inset \layout Subsection Invisible arrows \layout Standard Another \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset -feature not functioning in LyX is the correct positioning of labels along the shaft of arrows. The code \family typewriter \backslash ar[r]|(0.3) \backslash varphi \family default , for instance will place the label \begin_inset Formula $\phi$ \end_inset not in the middle of the arrow, but rather at about 30% of the way from its origin. The same ought to work with labels above or below the arrow, e.g. \family typewriter \backslash ar[r]^(0.3) \backslash phi \family default or \family typewriter \backslash ar[r]_(0.3) \backslash phi \family default . Unfortunately, this simple does not function in LyX. \layout Standard Still, this feature is sometimes necessary, when the default position of the label would otherwise clutter the picture, or even coincide with other items, such as the intersection of the arrows in the figure below. \layout Standard \begin_inset Formula \[ \xyC{4pc}\xymatrix{\bullet\ar@{}[dr(0.6)]^{\varphi}\ar[dr] & \circ\ar@{}[d]|\vdots\\ \circ\ar@{}[ur(0.6)]_{\phi}\ar[ur] & \bullet} \] \end_inset \layout Standard For strictly horizontal arrows, a workaround is easy: just pad the label itself with enough spaces to make the visible part shift enough to the right or to the left, as e.g. in \family typewriter \backslash ar[r]^{ \backslash phi \backslash \backslash \backslash } \family default . For vertical or diagonal arrows, this does not work, so you might wish to use the following trick: \layout Standard Produce an invisible second arrow, shorten (or prolong) it past its goal by adding a decimal stretching ratio, e.g. \family typewriter (0.6) \family default or \family typewriter (1.4) \family default to its path. Attach the label to this invisible arrow. In the above diagram, the downward pointing arrow with its label was produced by \family typewriter \backslash ar[dr] \backslash ar@{}[dr(0.6)]^ \backslash varphi \family default , where the second arrow is the invisible one, reaching only 0.6 of the way. Hence the label will appear at 0.3 of the way of the original visible arrow. \layout Standard This workaround has two minor drawbacks: First, it does not work with bending arrows. Secondly, prolonging an invisible arrow beyond the normal dimension of the figure will invisibly extend the figure box, and thereby cause too much vertical space between the figure and the preceding or the folling paragraph. \layout Standard Invisible arrows are an important tool, though, since they can, in principle, be used to place information at any chosen place in a diagram. Above, for instance, we have used an invisible arrow to carry the \family typewriter \backslash vdots \family default as label and at the preceding picture we had used an invisible arrow to carry some text into the center of the figure. \layout Bibliography \bibitem {key-1} Kristoffer H. Rose: \begin_inset ERT status Inlined \layout Standard \backslash Xy \end_inset \emph on -Pic User's Guide \emph default . Version 3.7, Feb. 16, 1999. Available as part of the \family typewriter xypic \family default LaTeX package. \layout Bibliography \bibitem {instant-preview} \begin_inset LatexCommand \url{http://www.tug.org/tex-archive/help/Catalogue/entries/preview-latex.html} \end_inset \layout Bibliography \bibitem {xypic} \begin_inset LatexCommand \url{http://www.tug.org/tex-archive/help/Catalogue/entries/xypic.html} \end_inset \layout Bibliography \bibitem {AUCTeX} \begin_inset LatexCommand \url{http://www.gnu.org/software/auctex/} \end_inset \the_end