1 #LyX 1.6.5svn created this file. For more info see http://www.lyx.org/
10 % define new commands used in sec. 5.1
12 \xydef@\xymatrixrowsep@{#1}}
14 \xydef@\xymatrixcolsep@{#1}}
16 \newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
18 % a pdf-bookmark for the TOC is added
19 \let\myTOC\tableofcontents
20 \renewcommand\tableofcontents{%
21 \pdfbookmark[1]{\contentsname}{}
24 % redefine the \LyX macro for PDF bookmarks
25 \def\LyX{\texorpdfstring{%
26 L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}
30 \use_default_options false
35 \font_typewriter default
36 \font_default_family default
46 \pdf_title "Using XY-pc in LyX"
47 \pdf_author "H. Peter Gumm"
48 \pdf_subject "LyX's XY-pic manual"
49 \pdf_keywords "LyX, documentation"
51 \pdf_bookmarksnumbered true
52 \pdf_bookmarksopen true
53 \pdf_bookmarksopenlevel 2
58 \pdf_pdfusetitle false
59 \pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue,pdfpagelayout=OneColumn, pdfnewwindow=true,pdfstartview=XYZ, plainpages=false, pdfpagelabels"
66 \paperorientation portrait
69 \paragraph_separation indent
71 \quotes_language english
74 \paperpagestyle default
75 \tracking_changes false
89 \begin_layout Plain Layout
106 \begin_layout Abstract
107 With the recent versions of LyX and with the
111 -style installed in the LaTeX-System, the graph drawing package
117 \begin_layout Plain Layout
128 -pic can be conveniently used inside LyX.
129 Diagrams can be edited and displayed inside the main LyX editing window.
130 Here, we shall describe how to use the
140 inside LyX in order to draw, to edit and to preview diagrams as typically
141 used in category theory, algebra, and related fields.
145 \begin_layout Abstract
146 \begin_inset CommandInset toc
147 LatexCommand tableofcontents
154 \begin_layout Section
158 \begin_layout Standard
163 -package has long served as a convenient tool for easily constructing graphs
164 and diagrams in LaTeX.
165 Unfortunately, its use in LyX had long been restricted to the infamous
166 TeX code boxes, meaning that the LyX editor could only display the LaTeX-source
167 and not the finished diagram.
172 -style of LaTeX which is part of the AUCTeX project
173 \begin_inset CommandInset citation
179 , finally enables the editing and displaying of
183 -diagrams, constructed, displayed and interactively edited inside LyX.
186 \begin_layout Standard
187 \begin_inset VSpace defskip
193 \begin_layout Standard
195 \begin_inset Graphics
196 filename xyfigure.png
198 BoundingBox 0bp 0bp 580bp 440bp
206 \begin_layout Standard
207 \begin_inset VSpace defskip
213 \begin_layout Standard
214 In this note, we describe how
218 \begin_layout Plain Layout
227 -pic can be used from inside LyX, how diagrams can be created and edited.
228 We have tested the following using LyX versions 1.3.7 up to 1.6, running under
230 \begin_inset space \thinspace{}
233 XP and under Windows Vista.
237 \begin_layout Standard
238 There are two modes of operations: For a start, and for some first tests,
239 it may be easiest to first enter the
243 \begin_layout Plain Layout
252 -pic code inside the LyX-window, select it all and convert it to a graphical
253 representation by pressing
266 \begin_layout Plain Layout
275 -pic more frequently, or if you want to modify your initial figure, you
276 will want to assemble and modify your figures using LyX's math editor.
280 \begin_layout Standard
281 Once the cursor is moved over a diagram, this is displayed as an array of
282 nodes and arrow-commands.
283 These can be changed interactively.
284 When the cursor leaves the editing area, the diagram reappears.
288 \begin_layout Standard
289 In the first two sections of this documentation, we explain how to use LyX
290 in the first mentioned mode and we introduce all
294 \begin_layout Plain Layout
303 -pic features that might be of use for drawing commutative diagrams, graphs
306 \begin_inset CommandInset ref
308 reference "sec:math-editor"
312 explains how to use the
316 \begin_layout Plain Layout
325 -pic commands inside a math-editing area.
329 \begin_layout Standard
330 It is not our intention to write another introduction to
334 \begin_layout Plain Layout
343 -pic, rather our motivation is to give an introduction how the most important
344 commands work inside LyX, since the keystrokes as explained in the
348 \begin_layout Plain Layout
358 \begin_inset CommandInset citation
364 will not always function correctly inside LyX.
368 \begin_layout Section
372 \begin_layout Standard
373 The following requires that the LaTeX-packages
381 are installed in the LaTeX system.
382 They are available from CTAN, see at
383 \begin_inset CommandInset citation
385 key "instant-preview"
391 \begin_inset CommandInset citation
398 After freshly installing them, it may be necessary, to run
400 Tools\SpecialChar \menuseparator
403 from the main LyX menu.
404 The steps to a first diagram output in LyX are then:
407 \begin_layout Enumerate
414 \begin_layout Enumerate
417 Tools\SpecialChar \menuseparator
418 Preferences\SpecialChar \menuseparator
419 Look and Feel\SpecialChar \menuseparator
429 \begin_layout Enumerate
432 Document\SpecialChar \menuseparator
433 Settings\SpecialChar \menuseparator
442 Use AMS Math package automatically
451 \begin_layout Enumerate
456 works by opening a LyX-document and entering any math-formula, e.
457 \begin_inset space \thinspace{}
462 \begin_inset Formula $a+b=c$
469 \begin_layout Enumerate
470 Move the cursor out of the formula, and watch it change its appearance to
471 look just like in the finished DVI- or PostScript document.
476 \begin_layout Enumerate
481 \begin_layout Plain Layout
496 \begin_layout Enumerate
497 Inside your LyX-Document, enter the text
500 \begin_inset Newline newline
512 \begin_layout Enumerate
513 Select the whole text and choose
515 Insert\SpecialChar \menuseparator
516 Math\SpecialChar \menuseparator
519 , or use the corresponding keyboard shortcut
527 \begin_layout Enumerate
528 Move the mouse cursor out of the editing box and wait for a split second
529 to see an arrow appear:
530 \begin_inset Formula $\xymatrix{A\ar[r] & B}
538 \begin_layout Section
542 \begin_layout Standard
543 The following diagram, which is taken from the documentation of
547 \begin_layout Plain Layout
557 \begin_inset CommandInset citation
563 by its creator Kristoffer H.
564 Rose, will provide an example for many of the features available with that
569 \begin_layout LyX-Code
573 \begin_inset Newline newline
585 \begin_inset Newline newline
595 \begin_inset Newline newline
611 \begin_inset Newline newline
619 \begin_layout LyX-Code
623 \begin_layout Standard
624 Again, to turn this code into a graphical output, select it all at once
631 \SpecialChar \ldots{}
632 up to the closing brace \SpecialChar \ldots{}
637 and turn it into display-math as explained above.
638 A moment after the cursor leaves the math-area, you should see the diagram
639 in its full graphical glory as shown below.
643 \begin_layout Standard
644 \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\
645 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
653 \begin_layout Subsection
654 The matrix layout of diagrams
657 \begin_layout Standard
662 uses a matrix to define the layout of the vertices of a diagram.
663 For the above example, we need a
664 \begin_inset Formula $3\times3$
667 -matrix of which 5 entries are used for the vertices
668 \begin_inset Formula $U$
672 \begin_inset Formula $X\times_{Z}Y$
676 \begin_inset Formula $X$
680 \begin_inset Formula $Y$
684 \begin_inset Formula $Z$
687 , the other positions remaining empty.
688 In this case, the following matrix determines the layout:
691 \begin_layout LyX-Code
695 \begin_inset Newline newline
703 \begin_inset Newline newline
713 \begin_inset Newline newline
719 \begin_layout Standard
720 The pattern should be familiar from LaTeX: We see three rows, the first
721 two being terminated by the end-of-line-marker
730 Each line consists of entries, separated by the ampersand
738 \begin_layout Subsection
742 \begin_layout Standard
743 Having entered the vertices, we add arrows between them.
748 -command to produce an arrow is
754 , it is entered into the cell of the matrix where the arrow is to start.
755 The target of the arrow is defined by direction commands
772 These can be combined to a path and enclosed in square brackets.
773 As an example, the arrows from the vertex
774 \begin_inset Formula $U$
777 in the upper left corner down and right to the vertices
778 \begin_inset Formula $X\times_{Z}Y$
782 \begin_inset Formula $Y$
786 \begin_inset Formula $X$
789 are, respectively, defined as
808 Thus the above diagram with all arrows added becomes:
811 \begin_layout LyX-Code
815 \begin_inset Newline newline
829 \begin_inset Newline newline
845 \begin_inset Newline newline
853 \begin_layout Standard
854 \begin_inset Formula \xymatrix{ U \ar[ddr] \ar[drr] \ar[dr]\\
855 & X \times_{Z} Y \ar[d] \ar[r] & X \ar[d]\\
864 \begin_layout LyX-Code
868 \begin_layout LyX-Code
872 \begin_layout Subsection
876 \begin_layout Standard
877 Labels are attached to arrows by affixing them as upper or lower indices
893 defines an arrow going one cell down, two to the right and having the label
895 \begin_inset Formula $\varphi$
899 To attach a label below the arrow, make it a lower index as in
908 This explanation is correct only for arrows pointing to the right.
909 More precisely, imagine looking along the arrow in the direction it is
911 Then an upper index places a label to the left and a lower index places
913 Consequently, an arrow pointing from right to left, such as
924 \begin_inset Formula $\alpha$
928 \begin_inset Formula $\beta$
932 \begin_inset space \thinspace{}
936 \begin_inset space \space{}
940 \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.}
944 Using the character | instead of ^ or _ , it is even possible to place the
945 label right onto the arrow, obscuring part of its shaft.
949 \begin_layout Standard
950 Normally, a label is placed halfway between an arrow's start and target
952 In the first diagram, the central arrow starting in
953 \begin_inset Formula $U$
957 \begin_inset Formula $(x,y)$
960 in the middle of the arrow's shaft, rather than in the middle between the
961 two objects it connects.
962 This is achieved by prefixing the label with a minus sign, here:
971 \begin_layout LyX-Code
975 \begin_inset Newline newline
993 \begin_inset Newline newline
1009 \begin_inset Newline newline
1017 \begin_layout LyX-Code
1018 \begin_inset Formula \xymatrix{ U \ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\
1019 & X \times_{Z} Y \ar[d]^{q} \ar[r]_{p} & X \ar[d]_{f}\\
1020 & Y \ar[r]^{g} & Z }
1028 \begin_layout Standard
1032 \begin_layout Plain Layout
1041 -pic normally permits labels to be shifted towards the tip or towards the
1042 start of an arrow by prefixing the label with a ratio, such as e.
1043 \begin_inset space \thinspace{}
1052 In LyX this works only for labels which are placed on top of the arrow,
1065 \begin_layout Standard
1066 For labels placed to the left or to the right of the arrow this does not
1072 \begin_layout Plain Layout
1081 -pic code such as e.
1082 \begin_inset space \thinspace{}
1102 is not correctly interpreted by LyX's math editor.
1103 Two workarounds are suggested in the last section of this note.
1106 \begin_layout Subsection
1110 \begin_layout Standard
1111 Modification of the design, the form or the positioning of arrows are introduced
1117 This is followed by a pair of matching brackets, where the form of the
1130 indicates, whether we want to modify the design, the or the curvature of
1132 Various modifications can be applied to an arrow at the same time.
1135 \begin_layout Subsubsection
1139 \begin_layout Standard
1140 Various designs such as
1156 are possible for the shaft of an arrow.
1157 These can be combined with various ends and various tips.
1158 In general, the design of an arrow is described by following the command
1169 -sign and a pair of braces {\SpecialChar \ldots{}
1170 } containing characters describing the end,
1171 the shaft and the tip of the arrow.
1172 These characters are chosen to give some form of ASCII-rendering of the
1180 produces an arrow with split end, a dotted shaft and double head.
1181 A number of other arrow designs is given in the table below.
1182 Note that the ends of embedding arrows
1183 \begin_inset Formula $\xymatrix{A\ar@{^{(}->}[r] & B}
1187 are described by raising or lowering opening parentheses, such as in
1192 \begin_inset Newline newline
1198 \begin_layout Standard
1199 \begin_inset Tabular
1200 <lyxtabular version="3" rows="11" columns="2">
1201 <features islongtable="true">
1202 <column alignment="center" valignment="top" width="0">
1203 <column alignment="center" valignment="top" width="0">
1205 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1208 \begin_layout Plain Layout
1214 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1217 \begin_layout Plain Layout
1225 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1228 \begin_layout Plain Layout
1229 \begin_inset Formula \xymatrix{\ \ar[r] & \ }
1239 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1242 \begin_layout Plain Layout
1254 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1257 \begin_layout Plain Layout
1258 \begin_inset Formula \xymatrix{\ \ar@{-->}[r] & \ }
1268 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1271 \begin_layout Plain Layout
1283 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1286 \begin_layout Plain Layout
1287 \begin_inset Formula \xymatrix{\ \ar@{..>}[r] & \ }
1297 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1300 \begin_layout Plain Layout
1312 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1315 \begin_layout Plain Layout
1316 \begin_inset Formula \xymatrix{\ \ar@{~>}[r] & \ }
1326 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1329 \begin_layout Plain Layout
1341 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1344 \begin_layout Plain Layout
1345 \begin_inset Formula \xymatrix{\ \ar@{->>}[r] & \ }
1355 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1358 \begin_layout Plain Layout
1370 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1373 \begin_layout Plain Layout
1374 \begin_inset Formula \xymatrix{\ \ar@{-->>}[r] & \ }
1384 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1387 \begin_layout Plain Layout
1399 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1402 \begin_layout Plain Layout
1403 \begin_inset Formula \xymatrix{\ \ar@{>->>}[r] & \ }
1413 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1416 \begin_layout Plain Layout
1428 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1431 \begin_layout Plain Layout
1432 \begin_inset Formula \xymatrix{\ \ar@{_{(}->}[r] & \ }
1442 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1445 \begin_layout Plain Layout
1457 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1460 \begin_layout Plain Layout
1461 \begin_inset Formula \xymatrix{\ \ar@{^{(}->}[r] & \ }
1471 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1474 \begin_layout Plain Layout
1486 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1489 \begin_layout Plain Layout
1490 \begin_inset Formula \xymatrix{\ \ar@{|-|}[r] & \ }
1500 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1503 \begin_layout Plain Layout
1521 \begin_layout Standard
1523 Following the @-character by either a 2, 3, _,or a ^, we can produce arrows
1524 with double, triple shaft or arrows showing only the lower or upper half
1525 of their tips and ends.
1526 Arrows need not have tips nor ends, as the last example shows :
1527 \begin_inset Newline newline
1533 \begin_layout Standard
1534 \begin_inset Tabular
1535 <lyxtabular version="3" rows="8" columns="2">
1536 <features islongtable="true">
1537 <column alignment="center" valignment="top" width="0">
1538 <column alignment="center" valignment="top" width="0">
1540 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1543 \begin_layout Plain Layout
1549 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1552 \begin_layout Plain Layout
1560 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1563 \begin_layout Plain Layout
1564 \begin_inset Formula \xymatrix{\ \ar@2[r] & \ }
1574 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1577 \begin_layout Plain Layout
1589 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1592 \begin_layout Plain Layout
1593 \begin_inset Formula \xymatrix{\ \ar@3[r] & \ }
1603 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1606 \begin_layout Plain Layout
1618 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1621 \begin_layout Plain Layout
1622 \begin_inset Formula \xymatrix{\ \ar@_{->}[r] & \ }
1632 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1635 \begin_layout Plain Layout
1647 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1650 \begin_layout Plain Layout
1651 \begin_inset Formula \xymatrix{\ \ar@^{->}[r] & \ }
1661 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1664 \begin_layout Plain Layout
1676 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1679 \begin_layout Plain Layout
1680 \begin_inset Formula \xymatrix{\ \ar@^{>>->>}[r] & \ }
1690 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1693 \begin_layout Plain Layout
1705 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1708 \begin_layout Plain Layout
1709 \begin_inset Formula \xymatrix{\ \ar@{^{<}-_{>}}[r] & \ }
1719 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1722 \begin_layout Plain Layout
1734 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1737 \begin_layout Plain Layout
1738 \begin_inset Formula \xymatrix{\ \ar@2{--}[r] & \ }
1748 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1751 \begin_layout Plain Layout
1769 \begin_layout Subsubsection
1770 Designing your own arrows
1773 \begin_layout Standard
1774 Within certain limits there is even a way to design your own arrows.
1775 Using some the characters
1779 one can even design one's own arrow tips using the
1785 command in the preamble.
1786 For explanations, we refer to the
1792 \begin_layout Plain Layout
1803 -manual, from which we take the example:
1806 \begin_layout Standard
1811 newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
1816 \begin_layout Standard
1818 This defines a new arrow tip, referred to as
1828 and which displays correctly in LyX as:
1829 \begin_inset Formula \[
1830 \xymatrix{A\ar@{-|>}[r] & \ \ B}
1838 \begin_layout Subsection
1842 \begin_layout Standard
1843 Arrows are shifted sideways with the modifier
1848 \begin_inset Formula $\ldots$
1855 where the ellipsis is replaced by a positive or negative measure.
1856 For instance, to design a pair of mutually opposing arrows between two
1857 nodes, we shift them to see them apart.
1858 Note that the direction of the shift (positive) is to the left if one looks
1863 \begin_layout Standard
1879 \begin_layout Standard
1882 \begin_inset space ~
1886 \begin_inset space ~
1890 \begin_inset Formula \[
1891 \xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1900 \begin_layout Subsubsection
1901 Inline or centered diagrams
1904 \begin_layout Standard
1905 Arrows and diagrams can be used inline, such as this one:
1906 \begin_inset Formula $\xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1911 When their code is written inside LyX as above, select it and choose either
1916 for inline appearance or
1921 Diagrams constructed inline can later be centered, or, conversely, centered
1922 diagrams can be changed to inline formulas with
1924 Edit\SpecialChar \menuseparator
1929 \SpecialChar \menuseparator
1930 Change Formula Type.
1933 \begin_layout Subsection
1937 \begin_layout Standard
1938 There are two simple methods to make arrows bend.
1939 The first is giving an explicit value by which the midpoint of the arrow's
1940 shaft is raised or depressed, the other is by forcing the arrow to leave
1941 its origin in a prescribed compass direction and to make him enter the
1942 target at another direction.
1943 The necessary bending of the arrow is determined automatically.
1944 We describe both methods.
1947 \begin_layout Subsubsection
1951 \begin_layout Standard
1952 For bending arrows we use the modifier @/
1953 \begin_inset Formula $\ldots$
1957 The ellipsis stands for a TeX-measure which needs to be entered as a lower
1963 , we could simply write, e.
1964 \begin_inset space \thinspace{}
1974 for an arrow bending
1978 downwards, this cannot directly be done in LyX.
1979 It is necessary, to enclose the measure in a pair of braces, such as e.
1980 \begin_inset space \thinspace{}
1991 As an example, here are two opposing arrows between
1992 \begin_inset Formula $A$
1996 \begin_inset Formula $B$
1999 , each bending by .5 pica, given by the following source code:
2002 \begin_layout Standard
2014 \begin_layout Standard
2015 \begin_inset Formula \[
2016 \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]}
2024 \begin_layout Subsubsection
2025 Specifying exit- and entrance directions
2028 \begin_layout Standard
2029 An alternative for making arrows bend is by specifying their compass direction
2030 as they are leaving their source and their direction from which they enter
2032 Instead of north, north-east, east, etc., the directions are named
2064 , standing for up, up-right, right, down-right, etc..
2065 A direction is specified as @(
2077 stands for the direction the first object is left and
2081 stands for the direction from which the target is entered.
2082 As an example, we show some bending arrows and a loop, which arises when
2083 we do not specify a target for an arrow, just its incoming and outgoing
2087 \begin_layout Standard
2088 \begin_inset Formula \[
2089 \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\
2098 \begin_layout LyX-Code
2106 \begin_inset Newline newline
2116 \begin_inset Newline newline
2124 \begin_layout Subsection
2128 \begin_layout Standard
2129 The above example is reminiscent of an automata diagram, except that in
2130 such a diagram states would be enclosed in small circles, with double circles
2131 denoting final states.
2135 \begin_layout Subsubsection
2139 \begin_layout Standard
2144 \begin_layout Plain Layout
2153 -pic, entries can obtain a single or a double frame, such as
2154 \begin_inset Formula $\xymatrix{*+[F]{A}}
2159 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2163 by prefixing an entry with
2171 and enclosing the portion of the entry to be framed in braces.
2172 Normally, the frame will be very tight so that it must be widened by prefixing
2182 Round frames, such as
2183 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2188 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2192 are obtained by specifying the shape as
2197 So the latter figure was constructed as *++[o][F=]{B}.
2198 This way, the following automaton
2201 \begin_layout Standard
2202 \begin_inset Formula \[
2203 \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]}
2211 \begin_layout Standard
2216 \begin_layout LyX-Code
2226 \begin_layout LyX-Code
2232 \begin_layout LyX-Code
2240 \begin_layout LyX-Code
2244 \begin_layout Standard
2251 \SpecialChar \ldots{}
2256 will make a certain entry style the default, that can, of course be overridden
2257 for individual entries.
2262 entrymodifiers={++[o][F-]}
2264 , all following entries inside
2268 \begin_layout Plain Layout
2277 -matrices would be encircled.
2280 \begin_layout Subsubsection
2284 \begin_layout Standard
2285 Framing a whole rectangle inside an xymatrix is done with the macro pair
2305 The dimension of the rectangle is given as a dotted pair
2306 \begin_inset Formula $P_{0}.P_{1}$
2309 of points denoting the top left and lower right corners of the rectangle.
2310 Each point, in turn,is given as a doubly quoted comma separated pair
2311 \begin_inset Quotes eld
2315 \begin_inset Formula $x,y$
2319 \begin_inset Quotes erd
2323 \begin_inset Formula $x$
2327 \begin_inset Formula $y$
2331 These are followed by the framing commands, to produce figures such as
2333 \begin_inset Formula \[
2334 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2335 C & \save"1,1"."1,2"*++[F]\frm{}\restore}
2351 save"1,1"."2,1"*+[F=]
2364 produces the doubly framed rectangle, and the code for the extra wide horizonta
2376 save"1,1"."1,2"*++[F]
2390 This code can be placed in arbitrary cells of the xymatrix.
2394 \begin_layout Section
2395 Using LyX's math editor
2396 \begin_inset CommandInset label
2398 name "sec:math-editor"
2405 \begin_layout Standard
2406 As an alternative to writing the
2410 code, then transforming it into a math-editing environment by marking it
2419 , one may construct and modify the whole xypic-diagram inside LyX's math
2421 We describe the editing steps for a figure just like the one above.
2425 \begin_layout Subsection
2426 Caveat - how to enter braces
2429 \begin_layout Standard
2430 Recall that in LyX's math-editor any pair of braces
2438 that are to enclose a macro-parameter must be entered by typing just
2445 The closing brace is automatically supplied and in between a box into which
2446 to the parameter is entered.
2451 \begin_layout Plain Layout
2460 -diagrams, this applies in particular to arrow modifications that are normally
2465 \SpecialChar \ldots{}
2470 with the ellipsis standing for the description of end, shaft and tip of
2472 Inside the math-editor, enter just
2478 and let LyX provide the closing brace and the box into which to enter the
2479 description of the arrow.
2482 \begin_layout Standard
2483 Braces that are entered without the backslash
2489 will just appear as typed, but cannot be used to receive a macro parameter.
2490 They are useful, for instance to denote sets, e.
2491 \begin_inset space \thinspace{}
2506 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2512 \begin_layout Subsection
2513 Setting up the matrix
2516 \begin_layout Standard
2525 open a formula environment and enter:
2533 \begin_inset Formula $\times$
2540 \begin_layout Plain Layout
2550 Add extra rows by typing
2554 and add columns by typing
2560 \begin_layout Standard
2561 At any time, further rows or columns can be entered or deleted using commands
2564 Edit\SpecialChar \menuseparator
2568 their shortcuts, beginning with
2572 for the column commands or
2576 for the row commands.
2577 A more direct way uses the icons in the math toolbar once it has been activated
2580 View\SpecialChar \menuseparator
2584 \begin_layout Subsection
2585 Entering nodes, arrows and labels
2588 \begin_layout Standard
2589 Type the nodes into the correct positions of the matrix.
2590 If you move the cursor out of the matrix, you should see a first rendering
2592 Next, add the arrows at the nodes from where they should emanate by typing
2609 can be any path made up from the characters
2626 Make sure that the path indeed leads to an existing node within the matrix.
2627 Otherwise, the figure will not display when the cursor leaves the editing
2631 \begin_layout Standard
2632 Next, label the arrows by attaching a label text as upper or lower indices
2633 to the end of the arrow's path.
2634 As always in LyX's math editor, an underscore
2638 opens a box for a lower index and a
2642 followed by a space opens a box for an upper index.
2643 You can enter any LaTeX-code as a label.
2646 \begin_layout Subsection
2650 \begin_layout Standard
2651 Finally, you can modify the appearance of the arrows by entering @-modifiers
2656 \SpecialChar \ldots{}
2665 \SpecialChar \ldots{}
2670 \SpecialChar \ldots{}
2671 ,\SpecialChar \ldots{}
2676 \SpecialChar \ldots{}
2682 The above caveat applies to the first form only.
2683 It must be entered as
2689 with the arrow description entered inside the LyX-supplied box.
2690 If this box remains empty, you have specified an empty arrow.
2691 This is a useful construction, too, as you will see in the next section.
2695 \begin_layout Standard
2696 The other modifiers,
2700 \SpecialChar \ldots{}
2709 \SpecialChar \ldots{}
2710 ,\SpecialChar \ldots{}
2719 \SpecialChar \ldots{}
2724 are typed as shown with the arrow description replacing the ellipsis.
2725 The code for bending arrows, which in
2754 is any valid TeX-measure that should be entered as upper or lower index
2755 to the first slash /.
2756 Make sure that the ending slash does not end up being part of the upper
2760 \begin_layout Subsection
2761 What if something goes wrong
2764 \begin_layout Standard
2765 When constructing a diagram, you should at times check it by just moving
2766 the cursor out of the editing area to see whether instant preview can successfu
2767 lly convert it into graphical output.
2768 If this does not happen, it may either be that instant preview for some
2769 reason is not aware that it should retranslate the graphics.
2770 Moving the cursor into the editing area and out again sometimes wakes up
2774 \begin_layout Standard
2775 A more serious reason could be a syntactical error in your input (in that
2776 case, the math edition area disappears completely).
2777 If necessary, undo the last editing steps, using
2781 , or try to translate the LyX-file into
2791 View\SpecialChar \menuseparator
2795 There should be some error generated, which hopefully gives you a hint
2796 as to the source of the mistake.
2799 \begin_layout Section
2803 \begin_layout Standard
2804 Certain things do not work correctly inside LyX.
2805 The ones that we (used to) miss most are the horizontal and vertical scaling
2806 of diagrams, and the correct positioning of arrows.
2807 There are some workarounds that we are explaining here.
2811 \begin_layout Subsection
2812 Horizontal and vertical scaling
2815 \begin_layout Standard
2816 It is often convenient to stretch the horizontal or the vertical dimensions
2817 of an entire diagram by using spacing commands for rows and/or columns.
2822 \begin_layout Plain Layout
2831 -manual, for instance,
2837 \SpecialChar \ldots{}
2846 \begin_layout Plain Layout
2855 -matrix with row spacing of 1 pica.
2862 \SpecialChar \ldots{}
2867 \SpecialChar \ldots{}
2872 allows to modify the space between columns.
2873 Unfortunately, these commands do currently not work inside LyX, as the
2874 @-character is interpreted by LyX as ending the
2878 \begin_layout Plain Layout
2891 \begin_layout Standard
2896 \begin_layout Plain Layout
2906 \begin_inset space ~
2909 stores the values for row-spacing and column-spacing in the variables
2921 , add the following macro to the preamble (
2923 Layout\SpecialChar \menuseparator
2924 Document\SpecialChar \menuseparator
2928 \begin_inset Newpage pagebreak
2934 \begin_layout LyX-Code
2942 \begin_layout LyX-Code
2947 xymatrixrowsep@{#1}}
2950 \begin_layout LyX-Code
2954 \begin_layout Standard
2961 can be defined correspondingly by replacing
2974 Now, a figure can be scaled by entering
2980 \begin_layout Plain Layout
2990 Place the cursor inside the matrix, just before the first entry.
3008 Don't forget the backslashes and remember, that the closing brace is automatica
3009 lly supplied by LyX.
3010 Inside the braces enter the dimensions.
3016 Here you see a diagram which is squashed vertically and stretched horizontally
3028 \begin_layout Standard
3029 \begin_inset Formula \[
3030 \xyC{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
3031 C\ar@{}[ur]|{\text{{horizontal stretch}}}}
3039 \begin_layout Subsection
3043 \begin_layout Standard
3048 \begin_layout Plain Layout
3057 -command allows the correct positioning of labels along the shaft of arrows.
3058 This feature is sometimes necessary, when the default position of a label
3059 would otherwise clutter the picture, or would even coincide with other
3060 items, such as the intersection of the arrows in the figure below.
3061 In order to shift a label position alongside the shaft of an arrow,
3065 \begin_layout Plain Layout
3075 \begin_inset space ~
3078 allows to prefix the label by a decimal number in parentheses, specifying
3079 the fraction of distance alongside the arrow where the label is to be placed.
3080 For instance, the code
3088 , will place the label on the shaft, but only about one third of the way.
3092 \begin_layout Standard
3093 Doing the same with labels above or below arrows as
3109 , does not work from inside LyX.
3110 Instead, one has to replace the hat-symbol ^, resp.
3111 the underscore _ , by the macros
3145 It is, in fact, possible to enter several labels this way and those labels
3146 are placed correctly, even if the arrow bends.
3147 In the following figure, the bending arrow with its four labels has been
3171 \begin_layout Standard
3172 \begin_inset Formula \[
3173 \xyC{4pc}\xymatrix{\bullet\ar[dr]\sp(0.3)\varphi & \circ\ar@{}[d]|\vdots\ar@(r,r)[d]\sp(0.2){\phi_{1}}\sp(0.4){\phi_{2}}\sb(0.6){\phi_{3}}\sp(0.8){\phi_{4}}\\
3174 \circ\ar[ur]\sb(0.3)\phi & \bullet}
3182 \begin_layout Subsection
3183 Invisible stretched arrows
3186 \begin_layout Standard
3187 A more general trick uses invisible arrows to place any object almost anywhere
3189 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3190 a decimal stretching ratio, e.
3191 \begin_inset space \thinspace{}
3204 Attach a label to this invisible arrow.
3208 \begin_layout Standard
3209 Thus, the down pointing arrow with its label
3210 \begin_inset Formula $\varphi$
3213 at (0.3) of its way along the shaft might as well have been produced by
3214 adding to the regular arrow
3221 \begin_inset Formula $\varphi$
3232 , reaching only 0.6 of the way.
3233 Its label will now appear at 0.3 of the way of the original visible arrow.
3237 \begin_layout Standard
3238 This workaround has two minor drawbacks: First, it does not work with bending
3240 Secondly, prolonging an invisible arrow beyond the normal dimension of
3241 the figure will invisibly extend the figure box, and thereby cause too
3242 much vertical space between the figure and the preceding or the following
3247 \begin_layout Standard
3248 Nevertheless, invisible arrows are an important tool, since they can, in
3249 principle, be used to place information at any chosen place in a diagram.
3250 In the above figure, for instance, we have used an invisible arrow to carry
3257 as label and at the earlier figure we had used an invisible arrow to carry
3259 \begin_inset Quotes eld
3267 \begin_inset Quotes erd
3270 into the center of the figure.
3273 \begin_layout Subsection
3280 \begin_layout Plain Layout
3294 \begin_layout Standard
3295 Here we have focused only on the
3301 command, which is just one of the features available in Kris Rose's amazing
3307 \begin_layout Plain Layout
3325 \begin_layout Plain Layout
3337 \begin_inset CommandInset citation
3343 demonstrates many of the advanced possibilities of that package.
3344 Beware, that its style is rather terse and you will likely need a lot of
3345 experimenting and modifying the many worked examples.
3347 \begin_inset CommandInset citation
3357 \begin_layout Plain Layout
3366 -pic to make braids, cobordism, string diagrams, and much more.
3367 A good and rather systematic introduction to
3373 \begin_layout Plain Layout
3385 \begin_inset CommandInset citation
3392 Even if you share with me the disadvantage of not being fluent in Esperanto,
3393 you will be able to understand most of it.
3397 \begin_layout Bibliography
3398 \begin_inset CommandInset bibitem
3399 LatexCommand bibitem
3410 \begin_layout Plain Layout
3426 Available as part of the
3434 \begin_layout Bibliography
3435 \begin_inset CommandInset bibitem
3436 LatexCommand bibitem
3438 key "instant-preview"
3443 \begin_inset Flex URL
3446 \begin_layout Plain Layout
3448 http://www.tug.org/tex-archive/help/Catalogue/entries/preview-latex.html
3456 \begin_layout Bibliography
3457 \begin_inset CommandInset bibitem
3458 LatexCommand bibitem
3465 \begin_inset Flex URL
3468 \begin_layout Plain Layout
3470 http://www.tug.org/tex-archive/help/Catalogue/entries/xypic.html
3478 \begin_layout Bibliography
3479 \begin_inset CommandInset bibitem
3480 LatexCommand bibitem
3487 \begin_inset Flex URL
3490 \begin_layout Plain Layout
3492 http://www.gnu.org/software/auctex/
3500 \begin_layout Bibliography
3501 \begin_inset CommandInset bibitem
3502 LatexCommand bibitem
3512 \begin_layout Plain Layout
3527 tutorial with an archive of examples
3530 \begin_inset Flex URL
3533 \begin_layout Plain Layout
3535 http://www.dpmms.cam.ac.uk/~al366/xytutorial.html
3543 \begin_layout Bibliography
3544 \begin_inset CommandInset bibitem
3545 LatexCommand bibitem
3555 \begin_layout Plain Layout
3570 Enkonduko pri Xymatrix
3574 \begin_inset Flex URL
3577 \begin_layout Plain Layout
3579 http://filip.ouvaton.org/xypic/xymatrix/index.html