1 #LyX 1.6.5svn created this file. For more info see http://www.lyx.org/
9 % define new commands used in sec. 5.1
11 \xydef@\xymatrixrowsep@{#1}}
13 \xydef@\xymatrixcolsep@{#1}}
15 \newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
17 % a pdf-bookmark for the TOC is added
18 \let\myTOC\tableofcontents
19 \renewcommand\tableofcontents{%
20 \pdfbookmark[1]{\contentsname}{}
23 % redefine the \LyX macro for PDF bookmarks
24 \def\LyX{\texorpdfstring{%
25 L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}
29 \use_default_options false
34 \font_typewriter default
35 \font_default_family default
45 \pdf_title "Using XY-pc in LyX"
46 \pdf_author "H. Peter Gumm"
47 \pdf_subject "LyX's XY-pic manual"
48 \pdf_keywords "LyX, documentation"
50 \pdf_bookmarksnumbered true
51 \pdf_bookmarksopen true
52 \pdf_bookmarksopenlevel 2
57 \pdf_pdfusetitle false
58 \pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue,pdfpagelayout=OneColumn, pdfnewwindow=true,pdfstartview=XYZ, plainpages=false, pdfpagelabels"
65 \paperorientation portrait
68 \paragraph_separation indent
70 \quotes_language english
73 \paperpagestyle default
74 \tracking_changes false
87 \begin_layout Plain Layout
104 \begin_layout Abstract
105 With the recent versions of LyX and with the
109 -style installed in the LaTeX-System, the graph drawing package
115 \begin_layout Plain Layout
126 -pic can be conveniently used inside LyX.
127 Diagrams can be edited and displayed inside the main LyX editing window.
128 Here, we shall describe how to use the
138 inside LyX in order to draw, to edit and to preview diagrams as typically
139 used in category theory, algebra, and related fields.
143 \begin_layout Abstract
144 \begin_inset CommandInset toc
145 LatexCommand tableofcontents
152 \begin_layout Section
156 \begin_layout Standard
161 -package has long served as a convenient tool for easily constructing graphs
162 and diagrams in LaTeX.
163 Unfortunately, its use in LyX had long been restricted to the infamous
164 TeX code boxes, meaning that the LyX editor could only display the LaTeX-source
165 and not the finished diagram.
170 -style of LaTeX which is part of the AUCTeX project
171 \begin_inset CommandInset citation
177 , finally enables the editing and displaying of
181 -diagrams, constructed, displayed and interactively edited inside LyX.
184 \begin_layout Standard
185 \begin_inset VSpace defskip
191 \begin_layout Standard
193 \begin_inset Graphics
194 filename xyfigure.png
196 BoundingBox 0bp 0bp 580bp 440bp
204 \begin_layout Standard
205 \begin_inset VSpace defskip
211 \begin_layout Standard
212 In this note, we describe how
216 \begin_layout Plain Layout
225 -pic can be used from inside LyX, how diagrams can be created and edited.
226 We have tested the following using LyX versions 1.3.7 up to 1.6, running under
228 \begin_inset space \thinspace{}
231 XP and under Windows Vista.
235 \begin_layout Standard
236 There are two modes of operations: For a start, and for some first tests,
237 it may be easiest to first enter the
241 \begin_layout Plain Layout
250 -pic code inside the LyX-window, select it all and convert it to a graphical
251 representation by pressing
264 \begin_layout Plain Layout
273 -pic more frequently, or if you want to modify your initial figure, you
274 will want to assemble and modify your figures using LyX's math editor.
278 \begin_layout Standard
279 Once the cursor is moved over a diagram, this is displayed as an array of
280 nodes and arrow-commands.
281 These can be changed interactively.
282 When the cursor leaves the editing area, the diagram reappears.
286 \begin_layout Standard
287 In the first two sections of this documentation, we explain how to use LyX
288 in the first mentioned mode and we introduce all
292 \begin_layout Plain Layout
301 -pic features that might be of use for drawing commutative diagrams, graphs
304 \begin_inset CommandInset ref
306 reference "sec:math-editor"
310 explains how to use the
314 \begin_layout Plain Layout
323 -pic commands inside a math-editing area.
327 \begin_layout Standard
328 It is not our intention to write another introduction to
332 \begin_layout Plain Layout
341 -pic, rather our motivation is to give an introduction how the most important
342 commands work inside LyX, since the keystrokes as explained in the
346 \begin_layout Plain Layout
356 \begin_inset CommandInset citation
362 will not always function correctly inside LyX.
366 \begin_layout Section
370 \begin_layout Standard
371 The following requires that the LaTeX-packages
379 are installed in the LaTeX system.
380 They are available from CTAN, see at
381 \begin_inset CommandInset citation
383 key "instant-preview"
389 \begin_inset CommandInset citation
396 After freshly installing them, it may be necessary, to run
398 Tools\SpecialChar \menuseparator
401 from the main LyX menu.
402 The steps to a first diagram output in LyX are then:
405 \begin_layout Enumerate
412 \begin_layout Enumerate
415 Tools\SpecialChar \menuseparator
416 Preferences\SpecialChar \menuseparator
417 Look and Feel\SpecialChar \menuseparator
427 \begin_layout Enumerate
430 Document\SpecialChar \menuseparator
431 Settings\SpecialChar \menuseparator
440 Use AMS Math package automatically
449 \begin_layout Enumerate
454 works by opening a LyX-document and entering any math-formula, e.
455 \begin_inset space \thinspace{}
460 \begin_inset Formula $a+b=c$
467 \begin_layout Enumerate
468 Move the cursor out of the formula, and watch it change its appearance to
469 look just like in the finished DVI- or PostScript document.
474 \begin_layout Enumerate
479 \begin_layout Plain Layout
494 \begin_layout Enumerate
495 Inside your LyX-Document, enter the text
498 \begin_inset Newline newline
510 \begin_layout Enumerate
511 Select the whole text and choose
513 Insert\SpecialChar \menuseparator
514 Math\SpecialChar \menuseparator
517 , or use the corresponding keyboard shortcut
525 \begin_layout Enumerate
526 Move the mouse cursor out of the editing box and wait for a split second
527 to see an arrow appear:
528 \begin_inset Formula $\xymatrix{A\ar[r] & B}
536 \begin_layout Section
540 \begin_layout Standard
541 The following diagram, which is taken from the documentation of
545 \begin_layout Plain Layout
555 \begin_inset CommandInset citation
561 by its creator Kristoffer H.
562 Rose, will provide an example for many of the features available with that
567 \begin_layout LyX-Code
571 \begin_inset Newline newline
583 \begin_inset Newline newline
593 \begin_inset Newline newline
609 \begin_inset Newline newline
617 \begin_layout LyX-Code
621 \begin_layout Standard
622 Again, to turn this code into a graphical output, select it all at once
629 \SpecialChar \ldots{}
630 up to the closing brace \SpecialChar \ldots{}
635 and turn it into display-math as explained above.
636 A moment after the cursor leaves the math-area, you should see the diagram
637 in its full graphical glory as shown below.
641 \begin_layout Standard
642 \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\
643 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
651 \begin_layout Subsection
652 The matrix layout of diagrams
655 \begin_layout Standard
660 uses a matrix to define the layout of the vertices of a diagram.
661 For the above example, we need a
662 \begin_inset Formula $3\times3$
665 -matrix of which 5 entries are used for the vertices
666 \begin_inset Formula $U$
670 \begin_inset Formula $X\times_{Z}Y$
674 \begin_inset Formula $X$
678 \begin_inset Formula $Y$
682 \begin_inset Formula $Z$
685 , the other positions remaining empty.
686 In this case, the following matrix determines the layout:
689 \begin_layout LyX-Code
693 \begin_inset Newline newline
701 \begin_inset Newline newline
711 \begin_inset Newline newline
717 \begin_layout Standard
718 The pattern should be familiar from LaTeX: We see three rows, the first
719 two being terminated by the end-of-line-marker
728 Each line consists of entries, separated by the ampersand
736 \begin_layout Subsection
740 \begin_layout Standard
741 Having entered the vertices, we add arrows between them.
746 -command to produce an arrow is
752 , it is entered into the cell of the matrix where the arrow is to start.
753 The target of the arrow is defined by direction commands
770 These can be combined to a path and enclosed in square brackets.
771 As an example, the arrows from the vertex
772 \begin_inset Formula $U$
775 in the upper left corner down and right to the vertices
776 \begin_inset Formula $X\times_{Z}Y$
780 \begin_inset Formula $Y$
784 \begin_inset Formula $X$
787 are, respectively, defined as
806 Thus the above diagram with all arrows added becomes:
809 \begin_layout LyX-Code
813 \begin_inset Newline newline
827 \begin_inset Newline newline
843 \begin_inset Newline newline
851 \begin_layout Standard
852 \begin_inset Formula \xymatrix{ U \ar[ddr] \ar[drr] \ar[dr]\\
853 & X \times_{Z} Y \ar[d] \ar[r] & X \ar[d]\\
862 \begin_layout LyX-Code
866 \begin_layout LyX-Code
870 \begin_layout Subsection
874 \begin_layout Standard
875 Labels are attached to arrows by affixing them as upper or lower indices
891 defines an arrow going one cell down, two to the right and having the label
893 \begin_inset Formula $\varphi$
897 To attach a label below the arrow, make it a lower index as in
906 This explanation is correct only for arrows pointing to the right.
907 More precisely, imagine looking along the arrow in the direction it is
909 Then an upper index places a label to the left and a lower index places
911 Consequently, an arrow pointing from right to left, such as
922 \begin_inset Formula $\alpha$
926 \begin_inset Formula $\beta$
930 \begin_inset space \thinspace{}
934 \begin_inset space \space{}
938 \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.}
942 Using the character | instead of ^ or _ , it is even possible to place the
943 label right onto the arrow, obscuring part of its shaft.
947 \begin_layout Standard
948 Normally, a label is placed halfway between an arrow's start and target
950 In the first diagram, the central arrow starting in
951 \begin_inset Formula $U$
955 \begin_inset Formula $(x,y)$
958 in the middle of the arrow's shaft, rather than in the middle between the
959 two objects it connects.
960 This is achieved by prefixing the label with a minus sign, here:
969 \begin_layout LyX-Code
973 \begin_inset Newline newline
991 \begin_inset Newline newline
1007 \begin_inset Newline newline
1015 \begin_layout LyX-Code
1016 \begin_inset Formula \xymatrix{ U \ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\
1017 & X \times_{Z} Y \ar[d]^{q} \ar[r]_{p} & X \ar[d]_{f}\\
1018 & Y \ar[r]^{g} & Z }
1026 \begin_layout Standard
1030 \begin_layout Plain Layout
1039 -pic normally permits labels to be shifted towards the tip or towards the
1040 start of an arrow by prefixing the label with a ratio, such as e.
1041 \begin_inset space \thinspace{}
1050 In LyX this works only for labels which are placed on top of the arrow,
1063 \begin_layout Standard
1064 For labels placed to the left or to the right of the arrow this does not
1070 \begin_layout Plain Layout
1079 -pic code such as e.
1080 \begin_inset space \thinspace{}
1100 is not correctly interpreted by LyX's math editor.
1101 Two workarounds are suggested in the last section of this note.
1104 \begin_layout Subsection
1108 \begin_layout Standard
1109 Modification of the design, the form or the positioning of arrows are introduced
1115 This is followed by a pair of matching brackets, where the form of the
1128 indicates, whether we want to modify the design, the or the curvature of
1130 Various modifications can be applied to an arrow at the same time.
1133 \begin_layout Subsubsection
1137 \begin_layout Standard
1138 Various designs such as
1154 are possible for the shaft of an arrow.
1155 These can be combined with various ends and various tips.
1156 In general, the design of an arrow is described by following the command
1167 -sign and a pair of braces {\SpecialChar \ldots{}
1168 } containing characters describing the end,
1169 the shaft and the tip of the arrow.
1170 These characters are chosen to give some form of ASCII-rendering of the
1178 produces an arrow with split end, a dotted shaft and double head.
1179 A number of other arrow designs is given in the table below.
1180 Note that the ends of embedding arrows
1181 \begin_inset Formula $\xymatrix{A\ar@{^{(}->}[r] & B}
1185 are described by raising or lowering opening parentheses, such as in
1190 \begin_inset Newline newline
1196 \begin_layout Standard
1197 \begin_inset Tabular
1198 <lyxtabular version="3" rows="11" columns="2">
1199 <features islongtable="true">
1200 <column alignment="center" valignment="top" width="0">
1201 <column alignment="center" valignment="top" width="0">
1203 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1206 \begin_layout Plain Layout
1212 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1215 \begin_layout Plain Layout
1223 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1226 \begin_layout Plain Layout
1227 \begin_inset Formula \xymatrix{\ \ar[r] & \ }
1237 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1240 \begin_layout Plain Layout
1252 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1255 \begin_layout Plain Layout
1256 \begin_inset Formula \xymatrix{\ \ar@{-->}[r] & \ }
1266 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1269 \begin_layout Plain Layout
1281 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1284 \begin_layout Plain Layout
1285 \begin_inset Formula \xymatrix{\ \ar@{..>}[r] & \ }
1295 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1298 \begin_layout Plain Layout
1310 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1313 \begin_layout Plain Layout
1314 \begin_inset Formula \xymatrix{\ \ar@{~>}[r] & \ }
1324 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1327 \begin_layout Plain Layout
1339 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1342 \begin_layout Plain Layout
1343 \begin_inset Formula \xymatrix{\ \ar@{->>}[r] & \ }
1353 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1356 \begin_layout Plain Layout
1368 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1371 \begin_layout Plain Layout
1372 \begin_inset Formula \xymatrix{\ \ar@{-->>}[r] & \ }
1382 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1385 \begin_layout Plain Layout
1397 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1400 \begin_layout Plain Layout
1401 \begin_inset Formula \xymatrix{\ \ar@{>->>}[r] & \ }
1411 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1414 \begin_layout Plain Layout
1426 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1429 \begin_layout Plain Layout
1430 \begin_inset Formula \xymatrix{\ \ar@{_{(}->}[r] & \ }
1440 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1443 \begin_layout Plain Layout
1455 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1458 \begin_layout Plain Layout
1459 \begin_inset Formula \xymatrix{\ \ar@{^{(}->}[r] & \ }
1469 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1472 \begin_layout Plain Layout
1484 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1487 \begin_layout Plain Layout
1488 \begin_inset Formula \xymatrix{\ \ar@{|-|}[r] & \ }
1498 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1501 \begin_layout Plain Layout
1519 \begin_layout Standard
1521 Following the @-character by either a 2, 3, _,or a ^, we can produce arrows
1522 with double, triple shaft or arrows showing only the lower or upper half
1523 of their tips and ends.
1524 Arrows need not have tips nor ends, as the last example shows :
1525 \begin_inset Newline newline
1531 \begin_layout Standard
1532 \begin_inset Tabular
1533 <lyxtabular version="3" rows="8" columns="2">
1534 <features islongtable="true">
1535 <column alignment="center" valignment="top" width="0">
1536 <column alignment="center" valignment="top" width="0">
1538 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1541 \begin_layout Plain Layout
1547 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1550 \begin_layout Plain Layout
1558 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1561 \begin_layout Plain Layout
1562 \begin_inset Formula \xymatrix{\ \ar@2[r] & \ }
1572 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1575 \begin_layout Plain Layout
1587 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1590 \begin_layout Plain Layout
1591 \begin_inset Formula \xymatrix{\ \ar@3[r] & \ }
1601 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1604 \begin_layout Plain Layout
1616 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1619 \begin_layout Plain Layout
1620 \begin_inset Formula \xymatrix{\ \ar@_{->}[r] & \ }
1630 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1633 \begin_layout Plain Layout
1645 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1648 \begin_layout Plain Layout
1649 \begin_inset Formula \xymatrix{\ \ar@^{->}[r] & \ }
1659 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1662 \begin_layout Plain Layout
1674 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1677 \begin_layout Plain Layout
1678 \begin_inset Formula \xymatrix{\ \ar@^{>>->>}[r] & \ }
1688 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1691 \begin_layout Plain Layout
1703 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1706 \begin_layout Plain Layout
1707 \begin_inset Formula \xymatrix{\ \ar@{^{<}-_{>}}[r] & \ }
1717 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1720 \begin_layout Plain Layout
1732 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1735 \begin_layout Plain Layout
1736 \begin_inset Formula \xymatrix{\ \ar@2{--}[r] & \ }
1746 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1749 \begin_layout Plain Layout
1767 \begin_layout Subsubsection
1768 Designing your own arrows
1771 \begin_layout Standard
1772 Within certain limits there is even a way to design your own arrows.
1773 Using some the characters
1777 one can even design one's own arrow tips using the
1783 command in the preamble.
1784 For explanations, we refer to the
1790 \begin_layout Plain Layout
1801 -manual, from which we take the example:
1804 \begin_layout Standard
1809 newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
1814 \begin_layout Standard
1816 This defines a new arrow tip, referred to as
1826 and which displays correctly in LyX as:
1827 \begin_inset Formula \[
1828 \xymatrix{A\ar@{-|>}[r] & \ \ B}
1836 \begin_layout Subsection
1840 \begin_layout Standard
1841 Arrows are shifted sideways with the modifier
1846 \begin_inset Formula $\ldots$
1853 where the ellipsis is replaced by a positive or negative measure.
1854 For instance, to design a pair of mutually opposing arrows between two
1855 nodes, we shift them to see them apart.
1856 Note that the direction of the shift (positive) is to the left if one looks
1861 \begin_layout Standard
1877 \begin_layout Standard
1880 \begin_inset space ~
1884 \begin_inset space ~
1888 \begin_inset Formula \[
1889 \xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1898 \begin_layout Subsubsection
1899 Inline or centered diagrams
1902 \begin_layout Standard
1903 Arrows and diagrams can be used inline, such as this one:
1904 \begin_inset Formula $\xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1909 When their code is written inside LyX as above, select it and choose either
1914 for inline appearance or
1919 Diagrams constructed inline can later be centered, or, conversely, centered
1920 diagrams can be changed to inline formulas with
1922 Edit\SpecialChar \menuseparator
1927 \SpecialChar \menuseparator
1928 Change Formula Type.
1931 \begin_layout Subsection
1935 \begin_layout Standard
1936 There are two simple methods to make arrows bend.
1937 The first is giving an explicit value by which the midpoint of the arrow's
1938 shaft is raised or depressed, the other is by forcing the arrow to leave
1939 its origin in a prescribed compass direction and to make him enter the
1940 target at another direction.
1941 The necessary bending of the arrow is determined automatically.
1942 We describe both methods.
1945 \begin_layout Subsubsection
1949 \begin_layout Standard
1950 For bending arrows we use the modifier @/
1951 \begin_inset Formula $\ldots$
1955 The ellipsis stands for a TeX-measure which needs to be entered as a lower
1961 , we could simply write, e.
1962 \begin_inset space \thinspace{}
1972 for an arrow bending
1976 downwards, this cannot directly be done in LyX.
1977 It is necessary, to enclose the measure in a pair of braces, such as e.
1978 \begin_inset space \thinspace{}
1989 As an example, here are two opposing arrows between
1990 \begin_inset Formula $A$
1994 \begin_inset Formula $B$
1997 , each bending by .5 pica, given by the following source code:
2000 \begin_layout Standard
2012 \begin_layout Standard
2013 \begin_inset Formula \[
2014 \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]}
2022 \begin_layout Subsubsection
2023 Specifying exit- and entrance directions
2026 \begin_layout Standard
2027 An alternative for making arrows bend is by specifying their compass direction
2028 as they are leaving their source and their direction from which they enter
2030 Instead of north, north-east, east, etc., the directions are named
2062 , standing for up, up-right, right, down-right, etc..
2063 A direction is specified as @(
2075 stands for the direction the first object is left and
2079 stands for the direction from which the target is entered.
2080 As an example, we show some bending arrows and a loop, which arises when
2081 we do not specify a target for an arrow, just its incoming and outgoing
2085 \begin_layout Standard
2086 \begin_inset Formula \[
2087 \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\
2096 \begin_layout LyX-Code
2104 \begin_inset Newline newline
2114 \begin_inset Newline newline
2122 \begin_layout Subsection
2126 \begin_layout Standard
2127 The above example is reminiscent of an automata diagram, except that in
2128 such a diagram states would be enclosed in small circles, with double circles
2129 denoting final states.
2133 \begin_layout Subsubsection
2137 \begin_layout Standard
2142 \begin_layout Plain Layout
2151 -pic, entries can obtain a single or a double frame, such as
2152 \begin_inset Formula $\xymatrix{*+[F]{A}}
2157 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2161 by prefixing an entry with
2169 and enclosing the portion of the entry to be framed in braces.
2170 Normally, the frame will be very tight so that it must be widened by prefixing
2180 Round frames, such as
2181 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2186 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2190 are obtained by specifying the shape as
2195 So the latter figure was constructed as *++[o][F=]{B}.
2196 This way, the following automaton
2199 \begin_layout Standard
2200 \begin_inset Formula \[
2201 \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]}
2209 \begin_layout Standard
2214 \begin_layout LyX-Code
2224 \begin_layout LyX-Code
2230 \begin_layout LyX-Code
2238 \begin_layout LyX-Code
2242 \begin_layout Standard
2249 \SpecialChar \ldots{}
2254 will make a certain entry style the default, that can, of course be overridden
2255 for individual entries.
2260 entrymodifiers={++[o][F-]}
2262 , all following entries inside
2266 \begin_layout Plain Layout
2275 -matrices would be encircled.
2278 \begin_layout Subsubsection
2282 \begin_layout Standard
2283 Framing a whole rectangle inside an xymatrix is done with the macro pair
2303 The dimension of the rectangle is given as a dotted pair
2304 \begin_inset Formula $P_{0}.P_{1}$
2307 of points denoting the top left and lower right corners of the rectangle.
2308 Each point, in turn,is given as a doubly quoted comma separated pair
2309 \begin_inset Quotes eld
2313 \begin_inset Formula $x,y$
2317 \begin_inset Quotes erd
2321 \begin_inset Formula $x$
2325 \begin_inset Formula $y$
2329 These are followed by the framing commands, to produce figures such as
2331 \begin_inset Formula \[
2332 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2333 C & \save"1,1"."1,2"*++[F]\frm{}\restore}
2349 save"1,1"."2,1"*+[F=]
2362 produces the doubly framed rectangle, and the code for the extra wide horizonta
2374 save"1,1"."1,2"*++[F]
2388 This code can be placed in arbitrary cells of the xymatrix.
2392 \begin_layout Section
2393 Using LyX's math editor
2394 \begin_inset CommandInset label
2396 name "sec:math-editor"
2403 \begin_layout Standard
2404 As an alternative to writing the
2408 code, then transforming it into a math-editing environment by marking it
2417 , one may construct and modify the whole xypic-diagram inside LyX's math
2419 We describe the editing steps for a figure just like the one above.
2423 \begin_layout Subsection
2424 Caveat - how to enter braces
2427 \begin_layout Standard
2428 Recall that in LyX's math-editor any pair of braces
2436 that are to enclose a macro-parameter must be entered by typing just
2443 The closing brace is automatically supplied and in between a box into which
2444 to the parameter is entered.
2449 \begin_layout Plain Layout
2458 -diagrams, this applies in particular to arrow modifications that are normally
2463 \SpecialChar \ldots{}
2468 with the ellipsis standing for the description of end, shaft and tip of
2470 Inside the math-editor, enter just
2476 and let LyX provide the closing brace and the box into which to enter the
2477 description of the arrow.
2480 \begin_layout Standard
2481 Braces that are entered without the backslash
2487 will just appear as typed, but cannot be used to receive a macro parameter.
2488 They are useful, for instance to denote sets, e.
2489 \begin_inset space \thinspace{}
2504 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2510 \begin_layout Subsection
2511 Setting up the matrix
2514 \begin_layout Standard
2523 open a formula environment and enter:
2531 \begin_inset Formula $\times$
2538 \begin_layout Plain Layout
2548 Add extra rows by typing
2552 and add columns by typing
2558 \begin_layout Standard
2559 At any time, further rows or columns can be entered or deleted using commands
2562 Edit\SpecialChar \menuseparator
2566 their shortcuts, beginning with
2570 for the column commands or
2574 for the row commands.
2575 A more direct way uses the icons in the math toolbar once it has been activated
2578 View\SpecialChar \menuseparator
2582 \begin_layout Subsection
2583 Entering nodes, arrows and labels
2586 \begin_layout Standard
2587 Type the nodes into the correct positions of the matrix.
2588 If you move the cursor out of the matrix, you should see a first rendering
2590 Next, add the arrows at the nodes from where they should emanate by typing
2607 can be any path made up from the characters
2624 Make sure that the path indeed leads to an existing node within the matrix.
2625 Otherwise, the figure will not display when the cursor leaves the editing
2629 \begin_layout Standard
2630 Next, label the arrows by attaching a label text as upper or lower indices
2631 to the end of the arrow's path.
2632 As always in LyX's math editor, an underscore
2636 opens a box for a lower index and a
2640 followed by a space opens a box for an upper index.
2641 You can enter any LaTeX-code as a label.
2644 \begin_layout Subsection
2648 \begin_layout Standard
2649 Finally, you can modify the appearance of the arrows by entering @-modifiers
2654 \SpecialChar \ldots{}
2663 \SpecialChar \ldots{}
2668 \SpecialChar \ldots{}
2669 ,\SpecialChar \ldots{}
2674 \SpecialChar \ldots{}
2680 The above caveat applies to the first form only.
2681 It must be entered as
2687 with the arrow description entered inside the LyX-supplied box.
2688 If this box remains empty, you have specified an empty arrow.
2689 This is a useful construction, too, as you will see in the next section.
2693 \begin_layout Standard
2694 The other modifiers,
2698 \SpecialChar \ldots{}
2707 \SpecialChar \ldots{}
2708 ,\SpecialChar \ldots{}
2717 \SpecialChar \ldots{}
2722 are typed as shown with the arrow description replacing the ellipsis.
2723 The code for bending arrows, which in
2752 is any valid TeX-measure that should be entered as upper or lower index
2753 to the first slash /.
2754 Make sure that the ending slash does not end up being part of the upper
2758 \begin_layout Subsection
2759 What if something goes wrong
2762 \begin_layout Standard
2763 When constructing a diagram, you should at times check it by just moving
2764 the cursor out of the editing area to see whether instant preview can successfu
2765 lly convert it into graphical output.
2766 If this does not happen, it may either be that instant preview for some
2767 reason is not aware that it should retranslate the graphics.
2768 Moving the cursor into the editing area and out again sometimes wakes up
2772 \begin_layout Standard
2773 A more serious reason could be a syntactical error in your input (in that
2774 case, the math edition area disappears completely).
2775 If necessary, undo the last editing steps, using
2779 , or try to translate the LyX-file into
2789 View\SpecialChar \menuseparator
2793 There should be some error generated, which hopefully gives you a hint
2794 as to the source of the mistake.
2797 \begin_layout Section
2801 \begin_layout Standard
2802 Certain things do not work correctly inside LyX.
2803 The ones that we (used to) miss most are the horizontal and vertical scaling
2804 of diagrams, and the correct positioning of arrows.
2805 There are some workarounds that we are explaining here.
2809 \begin_layout Subsection
2810 Horizontal and vertical scaling
2813 \begin_layout Standard
2814 It is often convenient to stretch the horizontal or the vertical dimensions
2815 of an entire diagram by using spacing commands for rows and/or columns.
2820 \begin_layout Plain Layout
2829 -manual, for instance,
2835 \SpecialChar \ldots{}
2844 \begin_layout Plain Layout
2853 -matrix with row spacing of 1 pica.
2860 \SpecialChar \ldots{}
2865 \SpecialChar \ldots{}
2870 allows to modify the space between columns.
2871 Unfortunately, these commands do currently not work inside LyX, as the
2872 @-character is interpreted by LyX as ending the
2876 \begin_layout Plain Layout
2889 \begin_layout Standard
2894 \begin_layout Plain Layout
2904 \begin_inset space ~
2907 stores the values for row-spacing and column-spacing in the variables
2919 , add the following macro to the preamble (
2921 Layout\SpecialChar \menuseparator
2922 Document\SpecialChar \menuseparator
2926 \begin_inset Newpage pagebreak
2932 \begin_layout LyX-Code
2940 \begin_layout LyX-Code
2945 xymatrixrowsep@{#1}}
2948 \begin_layout LyX-Code
2952 \begin_layout Standard
2959 can be defined correspondingly by replacing
2972 Now, a figure can be scaled by entering
2978 \begin_layout Plain Layout
2988 Place the cursor inside the matrix, just before the first entry.
3006 Don't forget the backslashes and remember, that the closing brace is automatica
3007 lly supplied by LyX.
3008 Inside the braces enter the dimensions.
3014 Here you see a diagram which is squashed vertically and stretched horizontally
3026 \begin_layout Standard
3027 \begin_inset Formula \[
3028 \xyC{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
3029 C\ar@{}[ur]|{\text{{horizontal stretch}}}}
3037 \begin_layout Subsection
3041 \begin_layout Standard
3046 \begin_layout Plain Layout
3055 -command allows the correct positioning of labels along the shaft of arrows.
3056 This feature is sometimes necessary, when the default position of a label
3057 would otherwise clutter the picture, or would even coincide with other
3058 items, such as the intersection of the arrows in the figure below.
3059 In order to shift a label position alongside the shaft of an arrow,
3063 \begin_layout Plain Layout
3073 \begin_inset space ~
3076 allows to prefix the label by a decimal number in parentheses, specifying
3077 the fraction of distance alongside the arrow where the label is to be placed.
3078 For instance, the code
3086 , will place the label on the shaft, but only about one third of the way.
3090 \begin_layout Standard
3091 Doing the same with labels above or below arrows as
3107 , does not work from inside LyX.
3108 Instead, one has to replace the hat-symbol ^, resp.
3109 the underscore _ , by the macros
3143 It is, in fact, possible to enter several labels this way and those labels
3144 are placed correctly, even if the arrow bends.
3145 In the following figure, the bending arrow with its four labels has been
3169 \begin_layout Standard
3170 \begin_inset Formula \[
3171 \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}}\\
3172 \circ\ar[ur]\sb(0.3)\phi & \bullet}
3180 \begin_layout Subsection
3181 Invisible stretched arrows
3184 \begin_layout Standard
3185 A more general trick uses invisible arrows to place any object almost anywhere
3187 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3188 a decimal stretching ratio, e.
3189 \begin_inset space \thinspace{}
3202 Attach a label to this invisible arrow.
3206 \begin_layout Standard
3207 Thus, the down pointing arrow with its label
3208 \begin_inset Formula $\varphi$
3211 at (0.3) of its way along the shaft might as well have been produced by
3212 adding to the regular arrow
3219 \begin_inset Formula $\varphi$
3230 , reaching only 0.6 of the way.
3231 Its label will now appear at 0.3 of the way of the original visible arrow.
3235 \begin_layout Standard
3236 This workaround has two minor drawbacks: First, it does not work with bending
3238 Secondly, prolonging an invisible arrow beyond the normal dimension of
3239 the figure will invisibly extend the figure box, and thereby cause too
3240 much vertical space between the figure and the preceding or the following
3245 \begin_layout Standard
3246 Nevertheless, invisible arrows are an important tool, since they can, in
3247 principle, be used to place information at any chosen place in a diagram.
3248 In the above figure, for instance, we have used an invisible arrow to carry
3255 as label and at the earlier figure we had used an invisible arrow to carry
3257 \begin_inset Quotes eld
3265 \begin_inset Quotes erd
3268 into the center of the figure.
3271 \begin_layout Subsection
3278 \begin_layout Plain Layout
3292 \begin_layout Standard
3293 Here we have focused only on the
3299 command, which is just one of the features available in Kris Rose's amazing
3305 \begin_layout Plain Layout
3323 \begin_layout Plain Layout
3335 \begin_inset CommandInset citation
3341 demonstrates many of the advanced possibilities of that package.
3342 Beware, that its style is rather terse and you will likely need a lot of
3343 experimenting and modifying the many worked examples.
3345 \begin_inset CommandInset citation
3355 \begin_layout Plain Layout
3364 -pic to make braids, cobordism, string diagrams, and much more.
3365 A good and rather systematic introduction to
3371 \begin_layout Plain Layout
3383 \begin_inset CommandInset citation
3390 Even if you share with me the disadvantage of not being fluent in Esperanto,
3391 you will be able to understand most of it.
3395 \begin_layout Bibliography
3396 \begin_inset CommandInset bibitem
3397 LatexCommand bibitem
3408 \begin_layout Plain Layout
3424 Available as part of the
3432 \begin_layout Bibliography
3433 \begin_inset CommandInset bibitem
3434 LatexCommand bibitem
3436 key "instant-preview"
3441 \begin_inset Flex URL
3444 \begin_layout Plain Layout
3446 http://www.tug.org/tex-archive/help/Catalogue/entries/preview-latex.html
3454 \begin_layout Bibliography
3455 \begin_inset CommandInset bibitem
3456 LatexCommand bibitem
3463 \begin_inset Flex URL
3466 \begin_layout Plain Layout
3468 http://www.tug.org/tex-archive/help/Catalogue/entries/xypic.html
3476 \begin_layout Bibliography
3477 \begin_inset CommandInset bibitem
3478 LatexCommand bibitem
3485 \begin_inset Flex URL
3488 \begin_layout Plain Layout
3490 http://www.gnu.org/software/auctex/
3498 \begin_layout Bibliography
3499 \begin_inset CommandInset bibitem
3500 LatexCommand bibitem
3510 \begin_layout Plain Layout
3525 tutorial with an archive of examples
3528 \begin_inset Flex URL
3531 \begin_layout Plain Layout
3533 http://www.dpmms.cam.ac.uk/~al366/xytutorial.html
3541 \begin_layout Bibliography
3542 \begin_inset CommandInset bibitem
3543 LatexCommand bibitem
3553 \begin_layout Plain Layout
3568 Enkonduko pri Xymatrix
3572 \begin_inset Flex URL
3575 \begin_layout Plain Layout
3577 http://filip.ouvaton.org/xypic/xymatrix/index.html