1 #LyX 2.0 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
30 \maintain_unincluded_children false
32 \language_package default
37 \font_typewriter default
38 \font_default_family default
39 \use_non_tex_fonts false
46 \default_output_format default
48 \bibtex_command default
49 \index_command default
53 \pdf_title "Using XY-pc in LyX"
54 \pdf_author "H. Peter Gumm"
55 \pdf_subject "LyX's XY-pic manual"
56 \pdf_keywords "LyX, documentation"
58 \pdf_bookmarksnumbered true
59 \pdf_bookmarksopen true
60 \pdf_bookmarksopenlevel 2
65 \pdf_pdfusetitle false
66 \pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue,pdfpagelayout=OneColumn, pdfnewwindow=true,pdfstartview=XYZ, plainpages=false, pdfpagelabels"
76 \paperorientation portrait
85 \paragraph_separation indent
86 \paragraph_indentation default
87 \quotes_language english
90 \paperpagestyle default
91 \tracking_changes false
105 \begin_layout Plain Layout
122 \begin_layout Abstract
123 With the recent versions of LyX and with the
127 -style installed in the LaTeX-System, the graph drawing package
133 \begin_layout Plain Layout
144 -pic can be conveniently used inside LyX.
145 Diagrams can be edited and displayed inside the main LyX editing window.
146 Here, we shall describe how to use the
156 inside LyX in order to draw, to edit and to preview diagrams as typically
157 used in category theory, algebra, and related fields.
161 \begin_layout Abstract
162 \begin_inset CommandInset toc
163 LatexCommand tableofcontents
170 \begin_layout Section
174 \begin_layout Standard
179 -package has long served as a convenient tool for easily constructing graphs
180 and diagrams in LaTeX.
181 Unfortunately, its use in LyX had long been restricted to the infamous
182 TeX code boxes, meaning that the LyX editor could only display the LaTeX-source
183 and not the finished diagram.
188 -style of LaTeX which is part of the AUCTeX project
189 \begin_inset CommandInset citation
195 , finally enables the editing and displaying of
199 -diagrams, constructed, displayed and interactively edited inside LyX.
202 \begin_layout Standard
203 \begin_inset VSpace defskip
209 \begin_layout Standard
211 \begin_inset Graphics
212 filename xyfigure.png
214 BoundingBox 0bp 0bp 580bp 440bp
222 \begin_layout Standard
223 \begin_inset VSpace defskip
229 \begin_layout Standard
230 In this note, we describe how
234 \begin_layout Plain Layout
243 -pic can be used from inside LyX, how diagrams can be created and edited.
244 We have tested the following using LyX versions 1.3.7 up to 1.6, running under
246 \begin_inset space \thinspace{}
249 XP and under Windows Vista.
253 \begin_layout Standard
254 There are two modes of operations: For a start, and for some first tests,
255 it may be easiest to first enter the
259 \begin_layout Plain Layout
268 -pic code inside the LyX-window, select it all and convert it to a graphical
269 representation by pressing
282 \begin_layout Plain Layout
291 -pic more frequently, or if you want to modify your initial figure, you
292 will want to assemble and modify your figures using LyX's math editor.
296 \begin_layout Standard
297 Once the cursor is moved over a diagram, this is displayed as an array of
298 nodes and arrow-commands.
299 These can be changed interactively.
300 When the cursor leaves the editing area, the diagram reappears.
304 \begin_layout Standard
305 In the first two sections of this documentation, we explain how to use LyX
306 in the first mentioned mode and we introduce all
310 \begin_layout Plain Layout
319 -pic features that might be of use for drawing commutative diagrams, graphs
322 \begin_inset CommandInset ref
324 reference "sec:math-editor"
328 explains how to use the
332 \begin_layout Plain Layout
341 -pic commands inside a math-editing area.
345 \begin_layout Standard
346 It is not our intention to write another introduction to
350 \begin_layout Plain Layout
359 -pic, rather our motivation is to give an introduction how the most important
360 commands work inside LyX, since the keystrokes as explained in the
364 \begin_layout Plain Layout
374 \begin_inset CommandInset citation
380 will not always function correctly inside LyX.
384 \begin_layout Section
388 \begin_layout Standard
389 The following requires that the LaTeX-packages
397 are installed in the LaTeX system.
398 They are available from CTAN, see at
399 \begin_inset CommandInset citation
401 key "instant-preview"
407 \begin_inset CommandInset citation
414 After freshly installing them, it may be necessary, to run
416 Tools\SpecialChar \menuseparator
419 from the main LyX menu.
420 The steps to a first diagram output in LyX are then:
423 \begin_layout Enumerate
430 \begin_layout Enumerate
433 Tools\SpecialChar \menuseparator
434 Preferences\SpecialChar \menuseparator
435 Look and Feel\SpecialChar \menuseparator
445 \begin_layout Enumerate
448 Document\SpecialChar \menuseparator
449 Settings\SpecialChar \menuseparator
458 Use AMS Math package automatically
467 \begin_layout Enumerate
472 works by opening a LyX-document and entering any math-formula, e.
473 \begin_inset space \thinspace{}
478 \begin_inset Formula $a+b=c$
485 \begin_layout Enumerate
486 Move the cursor out of the formula, and watch it change its appearance to
487 look just like in the finished DVI- or PostScript document.
492 \begin_layout Enumerate
497 \begin_layout Plain Layout
512 \begin_layout Enumerate
513 Inside your LyX-Document, enter the text
516 \begin_inset Newline newline
528 \begin_layout Enumerate
529 Select the whole text and choose
531 Insert\SpecialChar \menuseparator
532 Math\SpecialChar \menuseparator
535 , or use the corresponding keyboard shortcut
543 \begin_layout Enumerate
544 Move the mouse cursor out of the editing box and wait for a split second
545 to see an arrow appear:
546 \begin_inset Formula $\xymatrix{A\ar[r] & B}
554 \begin_layout Section
558 \begin_layout Standard
559 The following diagram, which is taken from the documentation of
563 \begin_layout Plain Layout
573 \begin_inset CommandInset citation
579 by its creator Kristoffer H.
580 Rose, will provide an example for many of the features available with that
585 \begin_layout LyX-Code
589 \begin_inset Newline newline
601 \begin_inset Newline newline
611 \begin_inset Newline newline
627 \begin_inset Newline newline
635 \begin_layout LyX-Code
639 \begin_layout Standard
640 Again, to turn this code into a graphical output, select it all at once
647 \SpecialChar \ldots{}
648 up to the closing brace \SpecialChar \ldots{}
653 and turn it into display-math as explained above.
654 A moment after the cursor leaves the math-area, you should see the diagram
655 in its full graphical glory as shown below.
659 \begin_layout Standard
660 \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\
661 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
670 \begin_layout Subsection
671 The matrix layout of diagrams
674 \begin_layout Standard
679 uses a matrix to define the layout of the vertices of a diagram.
680 For the above example, we need a
681 \begin_inset Formula $3\times3$
684 -matrix of which 5 entries are used for the vertices
685 \begin_inset Formula $U$
689 \begin_inset Formula $X\times_{Z}Y$
693 \begin_inset Formula $X$
697 \begin_inset Formula $Y$
701 \begin_inset Formula $Z$
704 , the other positions remaining empty.
705 In this case, the following matrix determines the layout:
708 \begin_layout LyX-Code
712 \begin_inset Newline newline
720 \begin_inset Newline newline
730 \begin_inset Newline newline
736 \begin_layout Standard
737 The pattern should be familiar from LaTeX: We see three rows, the first
738 two being terminated by the end-of-line-marker
747 Each line consists of entries, separated by the ampersand
755 \begin_layout Subsection
759 \begin_layout Standard
760 Having entered the vertices, we add arrows between them.
765 -command to produce an arrow is
771 , it is entered into the cell of the matrix where the arrow is to start.
772 The target of the arrow is defined by direction commands
789 These can be combined to a path and enclosed in square brackets.
790 As an example, the arrows from the vertex
791 \begin_inset Formula $U$
794 in the upper left corner down and right to the vertices
795 \begin_inset Formula $X\times_{Z}Y$
799 \begin_inset Formula $Y$
803 \begin_inset Formula $X$
806 are, respectively, defined as
825 Thus the above diagram with all arrows added becomes:
828 \begin_layout LyX-Code
832 \begin_inset Newline newline
846 \begin_inset Newline newline
862 \begin_inset Newline newline
870 \begin_layout Standard
871 \begin_inset Formula \xymatrix{ U \ar[ddr] \ar[drr] \ar[dr]\\
872 & X \times_{Z} Y \ar[d] \ar[r] & X \ar[d]\\
881 \begin_layout LyX-Code
885 \begin_layout LyX-Code
889 \begin_layout Subsection
893 \begin_layout Standard
894 Labels are attached to arrows by affixing them as upper or lower indices
910 defines an arrow going one cell down, two to the right and having the label
912 \begin_inset Formula $\varphi$
916 To attach a label below the arrow, make it a lower index as in
925 This explanation is correct only for arrows pointing to the right.
926 More precisely, imagine looking along the arrow in the direction it is
928 Then an upper index places a label to the left and a lower index places
930 Consequently, an arrow pointing from right to left, such as
941 \begin_inset Formula $\alpha$
945 \begin_inset Formula $\beta$
949 \begin_inset space \thinspace{}
953 \begin_inset space \space{}
957 \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.}
961 Using the character | instead of ^ or _ , it is even possible to place the
962 label right onto the arrow, obscuring part of its shaft.
966 \begin_layout Standard
967 Normally, a label is placed halfway between an arrow's start and target
969 In the first diagram, the central arrow starting in
970 \begin_inset Formula $U$
974 \begin_inset Formula $(x,y)$
977 in the middle of the arrow's shaft, rather than in the middle between the
978 two objects it connects.
979 This is achieved by prefixing the label with a minus sign, here:
988 \begin_layout LyX-Code
992 \begin_inset Newline newline
1010 \begin_inset Newline newline
1026 \begin_inset Newline newline
1034 \begin_layout LyX-Code
1035 \begin_inset Formula \xymatrix{ U \ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\
1036 & X \times_{Z} Y \ar[d]^{q} \ar[r]_{p} & X \ar[d]_{f}\\
1045 \begin_layout Standard
1049 \begin_layout Plain Layout
1058 -pic normally permits labels to be shifted towards the tip or towards the
1059 start of an arrow by prefixing the label with a ratio, such as e.
1060 \begin_inset space \thinspace{}
1069 In LyX this works only for labels which are placed on top of the arrow,
1082 \begin_layout Standard
1083 For labels placed to the left or to the right of the arrow this does not
1089 \begin_layout Plain Layout
1098 -pic code such as e.
1099 \begin_inset space \thinspace{}
1119 is not correctly interpreted by LyX's math editor.
1120 Two workarounds are suggested in the last section of this note.
1123 \begin_layout Subsection
1127 \begin_layout Standard
1128 Modification of the design, the form or the positioning of arrows are introduced
1134 This is followed by a pair of matching brackets, where the form of the
1147 indicates, whether we want to modify the design, the or the curvature of
1149 Various modifications can be applied to an arrow at the same time.
1152 \begin_layout Subsubsection
1156 \begin_layout Standard
1157 Various designs such as
1173 are possible for the shaft of an arrow.
1174 These can be combined with various ends and various tips.
1175 In general, the design of an arrow is described by following the command
1186 -sign and a pair of braces {\SpecialChar \ldots{}
1187 } containing characters describing the end,
1188 the shaft and the tip of the arrow.
1189 These characters are chosen to give some form of ASCII-rendering of the
1197 produces an arrow with split end, a dotted shaft and double head.
1198 A number of other arrow designs is given in the table below.
1199 Note that the ends of embedding arrows
1200 \begin_inset Formula $\xymatrix{A\ar@{^{(}->}[r] & B}
1204 are described by raising or lowering opening parentheses, such as in
1209 \begin_inset Newline newline
1215 \begin_layout Standard
1216 \begin_inset Tabular
1217 <lyxtabular version="3" rows="11" columns="2">
1218 <features islongtable="true" longtabularalignment="center">
1219 <column alignment="center" valignment="top" width="0">
1220 <column alignment="center" valignment="top" width="0">
1222 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1225 \begin_layout Plain Layout
1231 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1234 \begin_layout Plain Layout
1242 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1245 \begin_layout Plain Layout
1246 \begin_inset Formula \xymatrix{\ \ar[r] & \ }
1255 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1258 \begin_layout Plain Layout
1270 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1273 \begin_layout Plain Layout
1274 \begin_inset Formula \xymatrix{\ \ar@{-->}[r] & \ }
1283 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1286 \begin_layout Plain Layout
1298 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1301 \begin_layout Plain Layout
1302 \begin_inset Formula \xymatrix{\ \ar@{..>}[r] & \ }
1311 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1314 \begin_layout Plain Layout
1326 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1329 \begin_layout Plain Layout
1330 \begin_inset Formula \xymatrix{\ \ar@{~>}[r] & \ }
1339 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1342 \begin_layout Plain Layout
1354 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1357 \begin_layout Plain Layout
1358 \begin_inset Formula \xymatrix{\ \ar@{->>}[r] & \ }
1367 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1370 \begin_layout Plain Layout
1382 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1385 \begin_layout Plain Layout
1386 \begin_inset Formula \xymatrix{\ \ar@{-->>}[r] & \ }
1395 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1398 \begin_layout Plain Layout
1410 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1413 \begin_layout Plain Layout
1414 \begin_inset Formula \xymatrix{\ \ar@{>->>}[r] & \ }
1423 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1426 \begin_layout Plain Layout
1438 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1441 \begin_layout Plain Layout
1442 \begin_inset Formula \xymatrix{\ \ar@{_{(}->}[r] & \ }
1451 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1454 \begin_layout Plain Layout
1466 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1469 \begin_layout Plain Layout
1470 \begin_inset Formula \xymatrix{\ \ar@{^{(}->}[r] & \ }
1479 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1482 \begin_layout Plain Layout
1494 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1497 \begin_layout Plain Layout
1498 \begin_inset Formula \xymatrix{\ \ar@{|-|}[r] & \ }
1507 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1510 \begin_layout Plain Layout
1528 \begin_layout Standard
1530 Following the @-character by either a 2, 3, _,or a ^, we can produce arrows
1531 with double, triple shaft or arrows showing only the lower or upper half
1532 of their tips and ends.
1533 Arrows need not have tips nor ends, as the last example shows :
1534 \begin_inset Newline newline
1540 \begin_layout Standard
1541 \begin_inset Tabular
1542 <lyxtabular version="3" rows="8" columns="2">
1543 <features islongtable="true" longtabularalignment="center">
1544 <column alignment="center" valignment="top" width="0">
1545 <column alignment="center" valignment="top" width="0">
1547 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1550 \begin_layout Plain Layout
1556 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1559 \begin_layout Plain Layout
1567 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1570 \begin_layout Plain Layout
1571 \begin_inset Formula \xymatrix{\ \ar@2[r] & \ }
1580 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1583 \begin_layout Plain Layout
1595 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1598 \begin_layout Plain Layout
1599 \begin_inset Formula \xymatrix{\ \ar@3[r] & \ }
1608 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1611 \begin_layout Plain Layout
1623 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1626 \begin_layout Plain Layout
1627 \begin_inset Formula \xymatrix{\ \ar@_{->}[r] & \ }
1636 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1639 \begin_layout Plain Layout
1651 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1654 \begin_layout Plain Layout
1655 \begin_inset Formula \xymatrix{\ \ar@^{->}[r] & \ }
1664 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1667 \begin_layout Plain Layout
1679 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1682 \begin_layout Plain Layout
1683 \begin_inset Formula \xymatrix{\ \ar@^{>>->>}[r] & \ }
1692 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1695 \begin_layout Plain Layout
1707 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1710 \begin_layout Plain Layout
1711 \begin_inset Formula \xymatrix{\ \ar@{^{<}-_{>}}[r] & \ }
1720 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1723 \begin_layout Plain Layout
1735 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1738 \begin_layout Plain Layout
1739 \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
1831 \xymatrix{A\ar@{-|>}[r] & \ \ B}
1839 \begin_layout Subsection
1843 \begin_layout Standard
1844 Arrows are shifted sideways with the modifier
1849 \begin_inset Formula $\ldots$
1856 where the ellipsis is replaced by a positive or negative measure.
1857 For instance, to design a pair of mutually opposing arrows between two
1858 nodes, we shift them to see them apart.
1859 Note that the direction of the shift (positive) is to the left if one looks
1864 \begin_layout Standard
1880 \begin_layout Standard
1883 \begin_inset space ~
1887 \begin_inset space ~
1891 \begin_inset Formula
1893 \xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1902 \begin_layout Subsubsection
1903 Inline or centered diagrams
1906 \begin_layout Standard
1907 Arrows and diagrams can be used inline, such as this one:
1908 \begin_inset Formula $\xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1913 When their code is written inside LyX as above, select it and choose either
1918 for inline appearance or
1923 Diagrams constructed inline can later be centered, or, conversely, centered
1924 diagrams can be changed to inline formulas with
1926 Edit\SpecialChar \menuseparator
1931 \SpecialChar \menuseparator
1932 Change Formula Type.
1935 \begin_layout Subsection
1939 \begin_layout Standard
1940 There are two simple methods to make arrows bend.
1941 The first is giving an explicit value by which the midpoint of the arrow's
1942 shaft is raised or depressed, the other is by forcing the arrow to leave
1943 its origin in a prescribed compass direction and to make him enter the
1944 target at another direction.
1945 The necessary bending of the arrow is determined automatically.
1946 We describe both methods.
1949 \begin_layout Subsubsection
1953 \begin_layout Standard
1954 For bending arrows we use the modifier @/
1955 \begin_inset Formula $\ldots$
1959 The ellipsis stands for a TeX-measure which needs to be entered as a lower
1965 , we could simply write, e.
1966 \begin_inset space \thinspace{}
1976 for an arrow bending
1980 downwards, this cannot directly be done in LyX.
1981 It is necessary, to enclose the measure in a pair of braces, such as e.
1982 \begin_inset space \thinspace{}
1993 As an example, here are two opposing arrows between
1994 \begin_inset Formula $A$
1998 \begin_inset Formula $B$
2001 , each bending by .5 pica, given by the following source code:
2004 \begin_layout Standard
2016 \begin_layout Standard
2017 \begin_inset Formula
2019 \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]}
2027 \begin_layout Subsubsection
2028 Specifying exit- and entrance directions
2031 \begin_layout Standard
2032 An alternative for making arrows bend is by specifying their compass direction
2033 as they are leaving their source and their direction from which they enter
2035 Instead of north, north-east, east, etc., the directions are named
2067 , standing for up, up-right, right, down-right, etc..
2068 A direction is specified as @(
2080 stands for the direction the first object is left and
2084 stands for the direction from which the target is entered.
2085 As an example, we show some bending arrows and a loop, which arises when
2086 we do not specify a target for an arrow, just its incoming and outgoing
2090 \begin_layout Standard
2091 \begin_inset Formula
2093 \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\
2103 \begin_layout LyX-Code
2111 \begin_inset Newline newline
2121 \begin_inset Newline newline
2129 \begin_layout Subsection
2133 \begin_layout Standard
2134 The above example is reminiscent of an automata diagram, except that in
2135 such a diagram states would be enclosed in small circles, with double circles
2136 denoting final states.
2140 \begin_layout Subsubsection
2144 \begin_layout Standard
2149 \begin_layout Plain Layout
2158 -pic, entries can obtain a single or a double frame, such as
2159 \begin_inset Formula $\xymatrix{*+[F]{A}}
2164 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2168 by prefixing an entry with
2176 and enclosing the portion of the entry to be framed in braces.
2177 Normally, the frame will be very tight so that it must be widened by prefixing
2187 Round frames, such as
2188 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2193 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2197 are obtained by specifying the shape as
2202 So the latter figure was constructed as *++[o][F=]{B}.
2203 This way, the following automaton
2206 \begin_layout Standard
2207 \begin_inset Formula
2209 \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]}
2217 \begin_layout Standard
2222 \begin_layout LyX-Code
2232 \begin_layout LyX-Code
2238 \begin_layout LyX-Code
2246 \begin_layout LyX-Code
2250 \begin_layout Standard
2257 \SpecialChar \ldots{}
2262 will make a certain entry style the default, that can, of course be overridden
2263 for individual entries.
2268 entrymodifiers={++[o][F-]}
2270 , all following entries inside
2274 \begin_layout Plain Layout
2283 -matrices would be encircled.
2286 \begin_layout Subsubsection
2290 \begin_layout Standard
2291 Framing a whole rectangle inside an xymatrix is done with the macro pair
2311 The dimension of the rectangle is given as a dotted pair
2312 \begin_inset Formula $P_{0}.P_{1}$
2315 of points denoting the top left and lower right corners of the rectangle.
2316 Each point, in turn,is given as a doubly quoted comma separated pair
2317 \begin_inset Quotes eld
2321 \begin_inset Formula $x,y$
2325 \begin_inset Quotes erd
2329 \begin_inset Formula $x$
2333 \begin_inset Formula $y$
2337 These are followed by the framing commands, to produce figures such as
2339 \begin_inset Formula
2341 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2342 C & \save"1,1"."1,2"*++[F]\frm{}\restore
2359 save"1,1"."2,1"*+[F=]
2372 produces the doubly framed rectangle, and the code for the extra wide horizonta
2384 save"1,1"."1,2"*++[F]
2398 This code can be placed in arbitrary cells of the xymatrix.
2402 \begin_layout Section
2403 Using LyX's math editor
2404 \begin_inset CommandInset label
2406 name "sec:math-editor"
2413 \begin_layout Standard
2414 As an alternative to writing the
2418 code, then transforming it into a math-editing environment by marking it
2427 , one may construct and modify the whole xypic-diagram inside LyX's math
2429 We describe the editing steps for a figure just like the one above.
2433 \begin_layout Subsection
2434 Caveat - how to enter braces
2437 \begin_layout Standard
2438 Recall that in LyX's math-editor any pair of braces
2446 that are to enclose a macro-parameter must be entered by typing just
2453 The closing brace is automatically supplied and in between a box into which
2454 to the parameter is entered.
2459 \begin_layout Plain Layout
2468 -diagrams, this applies in particular to arrow modifications that are normally
2473 \SpecialChar \ldots{}
2478 with the ellipsis standing for the description of end, shaft and tip of
2480 Inside the math-editor, enter just
2486 and let LyX provide the closing brace and the box into which to enter the
2487 description of the arrow.
2490 \begin_layout Standard
2491 Braces that are entered without the backslash
2497 will just appear as typed, but cannot be used to receive a macro parameter.
2498 They are useful, for instance to denote sets, e.
2499 \begin_inset space \thinspace{}
2514 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2520 \begin_layout Subsection
2521 Setting up the matrix
2524 \begin_layout Standard
2533 open a formula environment and enter:
2541 \begin_inset Formula $\times$
2548 \begin_layout Plain Layout
2558 Add extra rows by typing
2562 and add columns by typing
2568 \begin_layout Standard
2569 At any time, further rows or columns can be entered or deleted using commands
2572 Edit\SpecialChar \menuseparator
2576 their shortcuts, beginning with
2580 for the column commands or
2584 for the row commands.
2585 A more direct way uses the icons in the math toolbar once it has been activated
2588 View\SpecialChar \menuseparator
2592 \begin_layout Subsection
2593 Entering nodes, arrows and labels
2596 \begin_layout Standard
2597 Type the nodes into the correct positions of the matrix.
2598 If you move the cursor out of the matrix, you should see a first rendering
2600 Next, add the arrows at the nodes from where they should emanate by typing
2617 can be any path made up from the characters
2634 Make sure that the path indeed leads to an existing node within the matrix.
2635 Otherwise, the figure will not display when the cursor leaves the editing
2639 \begin_layout Standard
2640 Next, label the arrows by attaching a label text as upper or lower indices
2641 to the end of the arrow's path.
2642 As always in LyX's math editor, an underscore
2646 opens a box for a lower index and a
2650 followed by a space opens a box for an upper index.
2651 You can enter any LaTeX-code as a label.
2654 \begin_layout Subsection
2658 \begin_layout Standard
2659 Finally, you can modify the appearance of the arrows by entering @-modifiers
2664 \SpecialChar \ldots{}
2673 \SpecialChar \ldots{}
2678 \SpecialChar \ldots{}
2679 ,\SpecialChar \ldots{}
2684 \SpecialChar \ldots{}
2690 The above caveat applies to the first form only.
2691 It must be entered as
2697 with the arrow description entered inside the LyX-supplied box.
2698 If this box remains empty, you have specified an empty arrow.
2699 This is a useful construction, too, as you will see in the next section.
2703 \begin_layout Standard
2704 The other modifiers,
2708 \SpecialChar \ldots{}
2717 \SpecialChar \ldots{}
2718 ,\SpecialChar \ldots{}
2727 \SpecialChar \ldots{}
2732 are typed as shown with the arrow description replacing the ellipsis.
2733 The code for bending arrows, which in
2762 is any valid TeX-measure that should be entered as upper or lower index
2763 to the first slash /.
2764 Make sure that the ending slash does not end up being part of the upper
2768 \begin_layout Subsection
2769 What if something goes wrong
2772 \begin_layout Standard
2773 When constructing a diagram, you should at times check it by just moving
2774 the cursor out of the editing area to see whether instant preview can successfu
2775 lly convert it into graphical output.
2776 If this does not happen, it may either be that instant preview for some
2777 reason is not aware that it should retranslate the graphics.
2778 Moving the cursor into the editing area and out again sometimes wakes up
2782 \begin_layout Standard
2783 A more serious reason could be a syntactical error in your input (in that
2784 case, the math edition area disappears completely).
2785 If necessary, undo the last editing steps, using
2789 , or try to translate the LyX-file into
2799 View\SpecialChar \menuseparator
2803 There should be some error generated, which hopefully gives you a hint
2804 as to the source of the mistake.
2807 \begin_layout Section
2811 \begin_layout Standard
2812 Certain things do not work correctly inside LyX.
2813 The ones that we (used to) miss most are the horizontal and vertical scaling
2814 of diagrams, and the correct positioning of arrows.
2815 There are some workarounds that we are explaining here.
2819 \begin_layout Subsection
2820 Horizontal and vertical scaling
2823 \begin_layout Standard
2824 It is often convenient to stretch the horizontal or the vertical dimensions
2825 of an entire diagram by using spacing commands for rows and/or columns.
2830 \begin_layout Plain Layout
2839 -manual, for instance,
2845 \SpecialChar \ldots{}
2854 \begin_layout Plain Layout
2863 -matrix with row spacing of 1 pica.
2870 \SpecialChar \ldots{}
2875 \SpecialChar \ldots{}
2880 allows to modify the space between columns.
2881 Unfortunately, these commands do currently not work inside LyX, as the
2882 @-character is interpreted by LyX as ending the
2886 \begin_layout Plain Layout
2899 \begin_layout Standard
2904 \begin_layout Plain Layout
2914 \begin_inset space ~
2917 stores the values for row-spacing and column-spacing in the variables
2929 , add the following macro to the preamble (
2931 Layout\SpecialChar \menuseparator
2932 Document\SpecialChar \menuseparator
2936 \begin_inset Newpage pagebreak
2942 \begin_layout LyX-Code
2950 \begin_layout LyX-Code
2955 xymatrixrowsep@{#1}}
2958 \begin_layout LyX-Code
2962 \begin_layout Standard
2969 can be defined correspondingly by replacing
2982 Now, a figure can be scaled by entering
2988 \begin_layout Plain Layout
2998 Place the cursor inside the matrix, just before the first entry.
3016 Don't forget the backslashes and remember, that the closing brace is automatica
3017 lly supplied by LyX.
3018 Inside the braces enter the dimensions.
3024 Here you see a diagram which is squashed vertically and stretched horizontally
3036 \begin_layout Standard
3037 \begin_inset Formula
3039 \xyC{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
3040 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3049 \begin_layout Subsection
3053 \begin_layout Standard
3058 \begin_layout Plain Layout
3067 -command allows the correct positioning of labels along the shaft of arrows.
3068 This feature is sometimes necessary, when the default position of a label
3069 would otherwise clutter the picture, or would even coincide with other
3070 items, such as the intersection of the arrows in the figure below.
3071 In order to shift a label position alongside the shaft of an arrow,
3075 \begin_layout Plain Layout
3085 \begin_inset space ~
3088 allows to prefix the label by a decimal number in parentheses, specifying
3089 the fraction of distance alongside the arrow where the label is to be placed.
3090 For instance, the code
3098 , will place the label on the shaft, but only about one third of the way.
3102 \begin_layout Standard
3103 Doing the same with labels above or below arrows as
3119 , does not work from inside LyX.
3120 Instead, one has to replace the hat-symbol ^, resp.
3121 the underscore _ , by the macros
3155 It is, in fact, possible to enter several labels this way and those labels
3156 are placed correctly, even if the arrow bends.
3157 In the following figure, the bending arrow with its four labels has been
3181 \begin_layout Standard
3182 \begin_inset Formula
3184 \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}}\\
3185 \circ\ar[ur]\sb(0.3)\phi & \bullet
3194 \begin_layout Subsection
3195 Invisible stretched arrows
3198 \begin_layout Standard
3199 A more general trick uses invisible arrows to place any object almost anywhere
3201 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3202 a decimal stretching ratio, e.
3203 \begin_inset space \thinspace{}
3216 Attach a label to this invisible arrow.
3220 \begin_layout Standard
3221 Thus, the down pointing arrow with its label
3222 \begin_inset Formula $\varphi$
3225 at (0.3) of its way along the shaft might as well have been produced by
3226 adding to the regular arrow
3233 \begin_inset Formula $\varphi$
3244 , reaching only 0.6 of the way.
3245 Its label will now appear at 0.3 of the way of the original visible arrow.
3249 \begin_layout Standard
3250 This workaround has two minor drawbacks: First, it does not work with bending
3252 Secondly, prolonging an invisible arrow beyond the normal dimension of
3253 the figure will invisibly extend the figure box, and thereby cause too
3254 much vertical space between the figure and the preceding or the following
3259 \begin_layout Standard
3260 Nevertheless, invisible arrows are an important tool, since they can, in
3261 principle, be used to place information at any chosen place in a diagram.
3262 In the above figure, for instance, we have used an invisible arrow to carry
3269 as label and at the earlier figure we had used an invisible arrow to carry
3271 \begin_inset Quotes eld
3279 \begin_inset Quotes erd
3282 into the center of the figure.
3285 \begin_layout Subsection
3292 \begin_layout Plain Layout
3306 \begin_layout Standard
3307 Here we have focused only on the
3313 command, which is just one of the features available in Kris Rose's amazing
3319 \begin_layout Plain Layout
3337 \begin_layout Plain Layout
3349 \begin_inset CommandInset citation
3355 demonstrates many of the advanced possibilities of that package.
3356 Beware, that its style is rather terse and you will likely need a lot of
3357 experimenting and modifying the many worked examples.
3359 \begin_inset CommandInset citation
3369 \begin_layout Plain Layout
3378 -pic to make braids, cobordism, string diagrams, and much more.
3379 You might want to look on
3383 example shipped with LyX, which demonstrates how to use more advanced
3387 \begin_layout Plain Layout
3405 A good and rather systematic introduction to
3411 \begin_layout Plain Layout
3423 \begin_inset CommandInset citation
3430 Even if you share with me the disadvantage of not being fluent in Esperanto,
3431 you will be able to understand most of it.
3435 \begin_layout Bibliography
3436 \labelwidthstring References
3437 \begin_inset CommandInset bibitem
3438 LatexCommand bibitem
3449 \begin_layout Plain Layout
3465 Available as part of the
3473 \begin_layout Bibliography
3474 \labelwidthstring References
3475 \begin_inset CommandInset bibitem
3476 LatexCommand bibitem
3478 key "instant-preview"
3483 \begin_inset Flex URL
3486 \begin_layout Plain Layout
3488 http://www.tug.org/tex-archive/help/Catalogue/entries/preview-latex.html
3496 \begin_layout Bibliography
3497 \labelwidthstring References
3498 \begin_inset CommandInset bibitem
3499 LatexCommand bibitem
3506 \begin_inset Flex URL
3509 \begin_layout Plain Layout
3511 http://www.tug.org/tex-archive/help/Catalogue/entries/xypic.html
3519 \begin_layout Bibliography
3520 \labelwidthstring References
3521 \begin_inset CommandInset bibitem
3522 LatexCommand bibitem
3529 \begin_inset Flex URL
3532 \begin_layout Plain Layout
3534 http://www.gnu.org/software/auctex/
3542 \begin_layout Bibliography
3543 \labelwidthstring References
3544 \begin_inset CommandInset bibitem
3545 LatexCommand bibitem
3555 \begin_layout Plain Layout
3570 tutorial with an archive of examples
3573 \begin_inset Flex URL
3576 \begin_layout Plain Layout
3578 http://www.math.columbia.edu/~lauda/xy/
3586 \begin_layout Bibliography
3587 \labelwidthstring References
3588 \begin_inset CommandInset bibitem
3589 LatexCommand bibitem
3599 \begin_layout Plain Layout
3614 Enkonduko pri Xymatrix
3618 \begin_inset Flex URL
3621 \begin_layout Plain Layout
3623 http://filip.ouvaton.org/xypic/xymatrix/index.html