1 #LyX 1.6.2svn 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
88 \begin_layout Plain Layout
105 \begin_layout Abstract
106 With the recent versions of LyX and with the
110 -style installed in the LaTeX-System, the graph drawing package
116 \begin_layout Plain Layout
127 -Pic can be conveniently used inside LyX.
128 Diagrams can be edited and displayed inside the main LyX editing window.
129 Here, we shall describe how to use the
139 inside LyX in order to draw, to edit and to preview diagrams as typically
140 used in category theory, algebra, and related fields.
144 \begin_layout Abstract
145 \begin_inset CommandInset toc
146 LatexCommand tableofcontents
153 \begin_layout Section
157 \begin_layout Standard
162 -package has long served as a convenient tool for easily constructing graphs
163 and diagrams in LaTeX.
164 Unfortunately, its use in LyX had long been restricted to the infamous
165 TeX code boxes, meaning that the LyX editor could only display the LaTeX-source
166 and not the finished diagram.
171 -style of LaTeX which is part of the AUCTeX project
172 \begin_inset CommandInset citation
178 , finally enables the editing and displaying of
182 -diagrams, constructed, displayed and interactively edited inside LyX.
185 \begin_layout Standard
186 \begin_inset VSpace defskip
192 \begin_layout Standard
194 \begin_inset Graphics
195 filename xyfigure.png
197 BoundingBox 0bp 0bp 580bp 440bp
205 \begin_layout Standard
206 \begin_inset VSpace defskip
212 \begin_layout Standard
213 In this note, we describe how
217 \begin_layout Plain Layout
226 -pic can be used from inside LyX, how diagrams can be created and edited.
227 We have tested the following using LyX versions 1.3.7 up to 1.6, running under
229 \begin_inset space \thinspace{}
232 XP and under Windows Vista.
236 \begin_layout Standard
237 There are two modes of operations: For a start, and for some first tests,
238 it may be easiest to first enter the
242 \begin_layout Plain Layout
251 -Pic code inside the LyX-window, select it all and convert it to a graphical
252 representation by pressing
265 \begin_layout Plain Layout
274 -Pic more frequently, or if you want to modify your initial figure, you
275 will want to assemble and modify your figures using LyX's math editor.
279 \begin_layout Standard
280 Once the cursor is moved over a diagram, this is displayed as an array of
281 nodes and arrow-commands.
282 These can be changed interactively.
283 When the cursor leaves the editing area, the diagram reappears.
287 \begin_layout Standard
288 In the first two sections of this documentation, we explain how to use LyX
289 in the first mentioned mode and we introduce all
293 \begin_layout Plain Layout
302 -Pic features that might be of use for drawing commutative diagrams, graphs
305 \begin_inset CommandInset ref
307 reference "sec:math-editor"
311 explains how to use the
315 \begin_layout Plain Layout
324 -Pic commands inside a math-editing area.
328 \begin_layout Standard
329 It is not our intention to write another introduction to
333 \begin_layout Plain Layout
342 -Pic, rather our motivation is to give an introduction how the most important
343 commands work inside LyX, since the keystrokes as explained in the
347 \begin_layout Plain Layout
357 \begin_inset CommandInset citation
363 will not always function correctly inside LyX.
367 \begin_layout Section
371 \begin_layout Standard
372 The following requires that the LaTeX-packages
380 are installed in the LaTeX system.
381 They are available from CTAN, see at
382 \begin_inset CommandInset citation
384 key "instant-preview"
390 \begin_inset CommandInset citation
397 After freshly installing them, it may be necessary, to run
399 Edit\SpecialChar \menuseparator
402 from the main LyX menu.
403 The steps to a first diagram output in LyX are then:
406 \begin_layout Enumerate
413 \begin_layout Enumerate
416 Edit\SpecialChar \menuseparator
417 Preferences\SpecialChar \menuseparator
418 Look and Feel\SpecialChar \menuseparator
421 and place a check-mark at
429 \begin_layout Enumerate
434 works by opening a LyX-document and entering any math-formula, e.
435 \begin_inset space \thinspace{}
440 \begin_inset Formula $a+b=c$
447 \begin_layout Enumerate
448 Move the cursor out of the formula, and watch it change its appearance to
449 look just like in the finished DVI- or PostScript document.
454 \begin_layout Enumerate
459 \begin_layout Plain Layout
474 \begin_layout Enumerate
475 Inside your LyX-Document, enter the text
478 \begin_inset Newline newline
490 \begin_layout Enumerate
491 Select the whole text and choose
493 Insert\SpecialChar \menuseparator
494 Math\SpecialChar \menuseparator
497 , or use the corresponding keyboard shortcut
505 \begin_layout Enumerate
506 Move the mouse cursor out of the editing box and wait for a split second
507 to see an arrow appear:
508 \begin_inset Formula $\xymatrix{A\ar[r] & B}
517 \begin_layout Standard
518 The following diagram, which is taken from the documentation of
522 \begin_layout Plain Layout
532 \begin_inset CommandInset citation
538 by its creator Kristoffer H.
539 Rose, will provide an example for many of the features available with that
544 \begin_layout LyX-Code
548 \begin_inset Newline newline
560 \begin_inset Newline newline
570 \begin_inset Newline newline
586 \begin_inset Newline newline
594 \begin_layout LyX-Code
598 \begin_layout Standard
599 Again, to turn this code into a graphical output, select it all at once
606 \SpecialChar \ldots{}
607 up to the closing brace \SpecialChar \ldots{}
612 and turn it into display-math as explained above.
613 A moment after the cursor leaves the math-area, you should see the diagram
614 in its full graphical glory as shown below.
618 \begin_layout Standard
619 \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\
620 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
628 \begin_layout Subsection
629 The matrix layout of diagrams
632 \begin_layout Standard
637 uses a matrix to define the layout of the vertices of a diagram.
638 For the above example, we need a
639 \begin_inset Formula $3\times3$
642 -matrix of which 5 entries are used for the vertices
643 \begin_inset Formula $U$
647 \begin_inset Formula $X\times_{Z}Y$
651 \begin_inset Formula $X$
655 \begin_inset Formula $Y$
659 \begin_inset Formula $Z$
662 , the other positions remaining empty.
663 In this case, the following matrix determines the layout:
666 \begin_layout LyX-Code
670 \begin_inset Newline newline
678 \begin_inset Newline newline
688 \begin_inset Newline newline
694 \begin_layout Standard
695 The pattern should be familiar from LaTeX: We see three rows, the first
696 two being terminated by the end-of-line-marker
705 Each line consists of entries, separated by the ampersand
713 \begin_layout Subsection
717 \begin_layout Standard
718 Having entered the vertices, we add arrows between them.
723 -command to produce an arrow is
729 , it is entered into the cell of the matrix where the arrow is to start.
730 The target of the arrow is defined by direction commands
747 These can be combined to a path and enclosed in square brackets.
748 As an example, the arrows from the vertex
749 \begin_inset Formula $U$
752 in the upper left corner down and right to the vertices
753 \begin_inset Formula $X\times_{Z}Y$
757 \begin_inset Formula $Y$
761 \begin_inset Formula $X$
764 are, respectively, defined as
783 Thus the above diagram with all arrows added becomes:
786 \begin_layout LyX-Code
790 \begin_inset Newline newline
804 \begin_inset Newline newline
820 \begin_inset Newline newline
828 \begin_layout Standard
829 \begin_inset Formula \xymatrix{ U \ar[ddr] \ar[drr] \ar[dr]\\
830 & X \times_{Z} Y \ar[d] \ar[r] & X \ar[d]\\
839 \begin_layout LyX-Code
843 \begin_layout LyX-Code
847 \begin_layout Subsection
851 \begin_layout Standard
852 Labels are attached to arrows by affixing them as upper or lower indices
868 defines an arrow going one cell down, two to the right and having the label
870 \begin_inset Formula $\varphi$
874 To attach a label below the arrow, make it a lower index as in
883 This explanation is correct only for arrows pointing to the right.
884 More precisely, imagine looking along the arrow in the direction it is
886 Then an upper index places a label to the left and a lower index places
888 Consequently, an arrow pointing from right to left, such as
899 \begin_inset Formula $\alpha$
903 \begin_inset Formula $\beta$
907 \begin_inset space \thinspace{}
911 \begin_inset space \space{}
915 \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.}
919 Using the character | instead of ^ or _ , it is even possible to place the
920 label right onto the arrow, obscuring part of its shaft.
924 \begin_layout Standard
925 Normally, a label is placed halfway between an arrow's start and target
927 In the first diagram, the central arrow starting in
928 \begin_inset Formula $U$
932 \begin_inset Formula $(x,y)$
935 in the middle of the arrow's shaft, rather than in the middle between the
936 two objects it connects.
937 This is achieved by prefixing the label with a minus sign, here:
946 \begin_layout LyX-Code
950 \begin_inset Newline newline
968 \begin_inset Newline newline
984 \begin_inset Newline newline
992 \begin_layout LyX-Code
993 \begin_inset Formula \xymatrix{ U \ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\
994 & X \times_{Z} Y \ar[d]^{q} \ar[r]_{p} & X \ar[d]_{f}\\
1003 \begin_layout Standard
1007 \begin_layout Plain Layout
1016 -pic normally permits labels to be shifted towards the tip or towards the
1017 start of an arrow by prefixing the label with a ratio, such as e.
1018 \begin_inset space \thinspace{}
1027 In LyX this works only for labels which are placed on top of the arrow,
1040 \begin_layout Standard
1041 For labels placed to the left or to the right of the arrow this does not
1047 \begin_layout Plain Layout
1056 -pic code such as e.
1057 \begin_inset space \thinspace{}
1077 is not correctly interpreted by LyX's math editor.
1078 Two workarounds are suggested in the last section of this note.
1081 \begin_layout Subsection
1085 \begin_layout Standard
1086 Modification of the design, the form or the positioning of arrows are introduced
1092 This is followed by a pair of matching brackets, where the form of the
1105 indicates, whether we want to modify the design, the or the curvature of
1107 Various modifications can be applied to an arrow at the same time.
1110 \begin_layout Subsubsection
1114 \begin_layout Standard
1115 Various designs such as
1131 are possible for the shaft of an arrow.
1132 These can be combined with various ends and various tips.
1133 In general, the design of an arrow is described by following the command
1144 -sign and a pair of braces {\SpecialChar \ldots{}
1145 } containing characters describing the end,
1146 the shaft and the tip of the arrow.
1147 These characters are chosen to give some form of ASCII-rendering of the
1155 produces an arrow with split end, a dotted shaft and double head.
1156 A number of other arrow designs is given in the table below.
1157 Note that the ends of embedding arrows
1158 \begin_inset Formula $\xymatrix{A\ar@{^{(}->}[r] & B}
1162 are described by raising or lowering opening parentheses, such as in
1167 \begin_inset Newline newline
1173 \begin_layout Standard
1174 \begin_inset Tabular
1175 <lyxtabular version="3" rows="11" columns="2">
1176 <features islongtable="true">
1177 <column alignment="center" valignment="top" width="0">
1178 <column alignment="center" valignment="top" width="0">
1180 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1183 \begin_layout Plain Layout
1189 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1192 \begin_layout Plain Layout
1200 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1203 \begin_layout Plain Layout
1204 \begin_inset Formula \xymatrix{\ \ar[r] & \ }
1214 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1217 \begin_layout Plain Layout
1229 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1232 \begin_layout Plain Layout
1233 \begin_inset Formula \xymatrix{\ \ar@{-->}[r] & \ }
1243 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1246 \begin_layout Plain Layout
1258 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1261 \begin_layout Plain Layout
1262 \begin_inset Formula \xymatrix{\ \ar@{..>}[r] & \ }
1272 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1275 \begin_layout Plain Layout
1287 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1290 \begin_layout Plain Layout
1291 \begin_inset Formula \xymatrix{\ \ar@{~>}[r] & \ }
1301 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1304 \begin_layout Plain Layout
1316 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1319 \begin_layout Plain Layout
1320 \begin_inset Formula \xymatrix{\ \ar@{->>}[r] & \ }
1330 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1333 \begin_layout Plain Layout
1345 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1348 \begin_layout Plain Layout
1349 \begin_inset Formula \xymatrix{\ \ar@{-->>}[r] & \ }
1359 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1362 \begin_layout Plain Layout
1374 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1377 \begin_layout Plain Layout
1378 \begin_inset Formula \xymatrix{\ \ar@{>->>}[r] & \ }
1388 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1391 \begin_layout Plain Layout
1403 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1406 \begin_layout Plain Layout
1407 \begin_inset Formula \xymatrix{\ \ar@{_{(}->}[r] & \ }
1417 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1420 \begin_layout Plain Layout
1432 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1435 \begin_layout Plain Layout
1436 \begin_inset Formula \xymatrix{\ \ar@{^{(}->}[r] & \ }
1446 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1449 \begin_layout Plain Layout
1461 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1464 \begin_layout Plain Layout
1465 \begin_inset Formula \xymatrix{\ \ar@{|-|}[r] & \ }
1475 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1478 \begin_layout Plain Layout
1496 \begin_layout Standard
1498 Following the @-character by either a 2, 3, _,or a ^, we can produce arrows
1499 with double, triple shaft or arrows showing only the lower or upper half
1500 of their tips and ends.
1501 Arrows need not have tips nor ends, as the last example shows :
1502 \begin_inset Newline newline
1508 \begin_layout Standard
1509 \begin_inset Tabular
1510 <lyxtabular version="3" rows="8" columns="2">
1511 <features islongtable="true">
1512 <column alignment="center" valignment="top" width="0">
1513 <column alignment="center" valignment="top" width="0">
1515 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1518 \begin_layout Plain Layout
1524 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1527 \begin_layout Plain Layout
1535 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1538 \begin_layout Plain Layout
1539 \begin_inset Formula \xymatrix{\ \ar@2[r] & \ }
1549 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1552 \begin_layout Plain Layout
1564 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1567 \begin_layout Plain Layout
1568 \begin_inset Formula \xymatrix{\ \ar@3[r] & \ }
1578 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1581 \begin_layout Plain Layout
1593 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1596 \begin_layout Plain Layout
1597 \begin_inset Formula \xymatrix{\ \ar@_{->}[r] & \ }
1607 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1610 \begin_layout Plain Layout
1622 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1625 \begin_layout Plain Layout
1626 \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] & \ }
1665 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1668 \begin_layout Plain Layout
1680 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1683 \begin_layout Plain Layout
1684 \begin_inset Formula \xymatrix{\ \ar@{^{<}-_{>}}[r] & \ }
1694 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1697 \begin_layout Plain Layout
1709 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1712 \begin_layout Plain Layout
1713 \begin_inset Formula \xymatrix{\ \ar@2{--}[r] & \ }
1723 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1726 \begin_layout Plain Layout
1744 \begin_layout Subsubsection
1745 Designing your own arrows
1748 \begin_layout Standard
1749 Within certain limits there is even a way to design your own arrows.
1750 Using some the characters
1754 one can even design one's own arrow tips using the
1760 command in the preamble.
1761 For explanations, we refer to the
1767 \begin_layout Plain Layout
1778 -manual, from which we take the example:
1781 \begin_layout Standard
1786 newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
1791 \begin_layout Standard
1793 This defines a new arrow tip, referred to as
1803 and which displays correctly in LyX as:
1804 \begin_inset Formula \[
1805 \xymatrix{A\ar@{-|>}[r] & \ \ B}
1813 \begin_layout Subsection
1817 \begin_layout Standard
1818 Arrows are shifted sideways with the modifier
1823 \begin_inset Formula $\ldots$
1830 where the ellipsis is replaced by a positive or negative measure.
1831 For instance, to design a pair of mutually opposing arrows between two
1832 nodes, we shift them to see them apart.
1833 Note that the direction of the shift (positive) is to the left if one looks
1838 \begin_layout Standard
1854 \begin_layout Standard
1857 \begin_inset space ~
1861 \begin_inset space ~
1865 \begin_inset Formula \[
1866 \xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1875 \begin_layout Subsubsection
1876 Inline or centered diagrams
1879 \begin_layout Standard
1880 Arrows and diagrams can be used inline, such as this one:
1881 \begin_inset Formula $\xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1886 When their code is written inside LyX as above, select it and choose either
1891 for inline appearance or
1896 Diagrams constructed inline can later be centered, or, conversely, centered
1897 diagrams can be changed to inline formulas with
1899 Edit\SpecialChar \menuseparator
1904 \SpecialChar \menuseparator
1908 \begin_layout Subsection
1912 \begin_layout Standard
1913 There are two simple methods to make arrows bend.
1914 The first is giving an explicit value by which the midpoint of the arrow's
1915 shaft is raised or depressed, the other is by forcing the arrow to leave
1916 its origin in a prescribed compass direction and to make him enter the
1917 target at another direction.
1918 The necessary bending of the arrow is determined automatically.
1919 We describe both methods.
1922 \begin_layout Subsubsection
1926 \begin_layout Standard
1927 For bending arrows we use the modifier @/
1928 \begin_inset Formula $\ldots$
1932 The ellipsis stands for a TeX-measure which needs to be entered as a lower
1938 , we could simply write, e.
1939 \begin_inset space \thinspace{}
1949 for an arrow bending
1953 downwards, this cannot directly be done in LyX.
1954 It is necessary, to enclose the measure in a pair of braces, such as e.
1955 \begin_inset space \thinspace{}
1966 As an example, here are two opposing arrows between
1967 \begin_inset Formula $A$
1971 \begin_inset Formula $B$
1974 , each bending by .5 pica, given by the following source code:
1977 \begin_layout Standard
1989 \begin_layout Standard
1990 \begin_inset Formula \[
1991 \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]}
1999 \begin_layout Subsubsection
2000 Specifying exit- and entrance directions
2003 \begin_layout Standard
2004 An alternative for making arrows bend is by specifying their compass direction
2005 as they are leaving their source and their direction from which they enter
2007 Instead of north, north-east, east, etc., the directions are named
2039 , standing for up, up-right, right, down-right, etc..
2040 A direction is specified as @(
2052 stands for the direction the first object is left and
2056 stands for the direction from which the target is entered.
2057 As an example, we show some bending arrows and a loop, which arises when
2058 we do not specify a target for an arrow, just its incoming and outgoing
2062 \begin_layout Standard
2063 \begin_inset Formula \[
2064 \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\
2073 \begin_layout LyX-Code
2081 \begin_inset Newline newline
2091 \begin_inset Newline newline
2099 \begin_layout Subsection
2103 \begin_layout Standard
2104 The above example is reminiscent of an automata diagram, except that in
2105 such a diagram states would be enclosed in small circles, with double circles
2106 denoting final states.
2110 \begin_layout Subsubsection
2114 \begin_layout Standard
2119 \begin_layout Plain Layout
2128 -Pic, entries can obtain a single or a double frame, such as
2129 \begin_inset Formula $\xymatrix{*+[F]{A}}
2134 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2138 by prefixing an entry with
2146 and enclosing the portion of the entry to be framed in braces.
2147 Normally, the frame will be very tight so that it must be widened by prefixing
2157 Round frames, such as
2158 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2163 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2167 are obtained by specifying the shape as
2172 So the latter figure was constructed as *++[o][F=]{B}.
2173 This way, the following automaton
2176 \begin_layout Standard
2177 \begin_inset Formula \[
2178 \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]}
2186 \begin_layout Standard
2191 \begin_layout LyX-Code
2201 \begin_layout LyX-Code
2207 \begin_layout LyX-Code
2215 \begin_layout LyX-Code
2219 \begin_layout Standard
2226 \SpecialChar \ldots{}
2231 will make a certain entry style the default, that can, of course be overridden
2232 for individual entries.
2237 entrymodifiers={++[o][F-]}
2239 , all following entries inside
2243 \begin_layout Plain Layout
2252 -matrices would be encircled.
2255 \begin_layout Subsubsection
2259 \begin_layout Standard
2260 Framing a whole rectangle inside an xymatrix is done with the macro pair
2280 The dimension of the rectangle is given as a dotted pair
2281 \begin_inset Formula $P_{0}.P_{1}$
2284 of points denoting the top left and lower right corners of the rectangle.
2285 Each point, in turn,is given as a doubly quoted comma separated pair
2286 \begin_inset Quotes eld
2290 \begin_inset Formula $x,y$
2294 \begin_inset Quotes erd
2298 \begin_inset Formula $x$
2302 \begin_inset Formula $y$
2306 These are followed by the framing commands, to produce figures such as
2308 \begin_inset Formula \[
2309 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2310 C & \save"1,1"."1,2"*++[F]\frm{}\restore}
2326 save"1,1"."2,1"*+[F=]
2339 produces the doubly framed rectangle, and the code for the extra wide horizonta
2351 save"1,1"."1,2"*++[F]
2365 This code can be placed in arbitrary cells of the xymatrix.
2369 \begin_layout Section
2370 Using LyX's math editor
2371 \begin_inset CommandInset label
2373 name "sec:math-editor"
2380 \begin_layout Standard
2381 As an alternative to writing the
2385 code, then transforming it into a math-editing environment by marking it
2394 , one may construct and modify the whole xypic-diagram inside LyX's math
2396 We describe the editing steps for a figure just like the one above.
2400 \begin_layout Subsection
2401 Caveat - how to enter braces
2404 \begin_layout Standard
2405 Recall that in LyX's math-editor any pair of braces
2413 that are to enclose a macro-parameter must be entered by typing just
2420 The closing brace is automatically supplied and in between a box into which
2421 to the parameter is entered.
2426 \begin_layout Plain Layout
2435 -diagrams, this applies in particular to arrow modifications that are normally
2440 \SpecialChar \ldots{}
2445 with the ellipsis standing for the description of end, shaft and tip of
2447 Inside the math-editor, enter just
2453 and let LyX provide the closing brace and the box into which to enter the
2454 description of the arrow.
2457 \begin_layout Standard
2458 Braces that are entered without the backslash
2464 will just appear as typed, but cannot be used to receive a macro parameter.
2465 They are useful, for instance to denote sets, e.
2466 \begin_inset space \thinspace{}
2481 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2487 \begin_layout Subsection
2488 Setting up the matrix
2491 \begin_layout Standard
2500 open a formula environment and enter:
2508 \begin_inset Formula $\times$
2515 \begin_layout Plain Layout
2525 Add extra rows by typing
2529 and add columns by typing
2535 \begin_layout Standard
2536 At any time, further rows or columns can be entered or deleted using commands
2539 Edit\SpecialChar \menuseparator
2543 their shortcuts, beginning with
2547 for the column commands or
2551 for the row commands.
2555 \begin_layout Subsection
2556 Entering nodes, arrows and labels
2559 \begin_layout Standard
2560 Type the nodes into the correct positions of the matrix.
2561 If you move the cursor out of the matrix, you should see a first rendering
2563 Next, add the arrows at the nodes from where they should emanate by typing
2580 can be any path made up from the characters
2597 Make sure that the path indeed leads to an existing node within the matrix.
2598 Otherwise, the figure will not display when the cursor leaves the editing
2602 \begin_layout Standard
2603 Next, label the arrows by attaching a label text as upper or lower indices
2604 to the end of the arrow's path.
2605 As always in LyX's math editor, an underscore
2609 opens a box for a lower index and a
2613 followed by a space opens a box for an upper index.
2614 You can enter any LaTeX-code as a label.
2617 \begin_layout Subsection
2621 \begin_layout Standard
2622 Finally, you can modify the appearance of the arrows by entering @-modifiers
2627 \SpecialChar \ldots{}
2636 \SpecialChar \ldots{}
2641 \SpecialChar \ldots{}
2642 ,\SpecialChar \ldots{}
2647 \SpecialChar \ldots{}
2653 The above caveat applies to the first form only.
2654 It must be entered as
2660 with the arrow description entered inside the LyX-supplied box.
2661 If this box remains empty, you have specified an empty arrow.
2662 This is a useful construction, too, as you will see in the next section.
2666 \begin_layout Standard
2667 The other modifiers,
2671 \SpecialChar \ldots{}
2680 \SpecialChar \ldots{}
2681 ,\SpecialChar \ldots{}
2690 \SpecialChar \ldots{}
2695 are typed as shown with the arrow description replacing the ellipsis.
2696 The code for bending arrows, which in
2725 is any valid TeX-measure that should be entered as upper or lower index
2726 to the first slash /.
2727 Make sure that the ending slash does not end up being part of the upper
2731 \begin_layout Subsection
2732 What if something goes wrong
2735 \begin_layout Standard
2736 When constructing a diagram, you should at times check it by just moving
2737 the cursor out of the editing area to see whether instant preview can successfu
2738 lly convert it into graphical output.
2739 If this does not happen, it may either be that instant preview for some
2740 reason is not aware that it should retranslate the graphics.
2741 Moving the cursor into the editing area and out again sometimes wakes up
2745 \begin_layout Standard
2746 A more serious reason could be a syntactical error in your input.
2747 If necessary, redo the last editing steps, using
2751 , or try to translate the LyX-file into
2761 View\SpecialChar \menuseparator
2765 There should be some error generated, which hopefully gives you a hint
2766 as to the source of the mistake.
2769 \begin_layout Section
2773 \begin_layout Standard
2774 Certain things do not work correctly inside LyX.
2775 The ones that we (used to) miss most are the horizontal and vertical scaling
2776 of diagrams, and the correct positioning of arrows.
2777 There are some workarounds that we are explaining here.
2781 \begin_layout Subsection
2782 Horizontal and vertical scaling
2785 \begin_layout Standard
2786 It is often convenient to stretch the horizontal or the vertical dimensions
2787 of an entire diagram by using spacing commands for rows and/or columns.
2792 \begin_layout Plain Layout
2801 -manual, for instance,
2807 \SpecialChar \ldots{}
2816 \begin_layout Plain Layout
2825 -matrix with row spacing of 1 pica.
2832 \SpecialChar \ldots{}
2837 \SpecialChar \ldots{}
2842 allows to modify the space between columns.
2843 Unfortunately, these commands do currently not work inside LyX, as the
2844 @-character is interpreted by LyX as ending the
2848 \begin_layout Plain Layout
2861 \begin_layout Standard
2866 \begin_layout Plain Layout
2876 \begin_inset space ~
2879 stores the values for row-spacing and column-spacing in the variables
2891 , add the following macro to the preamble (
2893 Layout\SpecialChar \menuseparator
2894 Document\SpecialChar \menuseparator
2898 \begin_inset Newpage pagebreak
2904 \begin_layout LyX-Code
2912 \begin_layout LyX-Code
2917 xymatrixrowsep@{#1}}
2920 \begin_layout LyX-Code
2924 \begin_layout Standard
2931 can be defined correspondingly by replacing
2944 Now, a figure can be scaled by entering
2950 \begin_layout Plain Layout
2960 Place the cursor inside the matrix, just before the first entry.
2978 Don't forget the backslashes and remember, that the closing brace is automatica
2979 lly supplied by LyX.
2980 Inside the braces enter the dimensions.
2986 Here you see a diagram which is squashed vertically and stretched horizontally
2998 \begin_layout Standard
2999 \begin_inset Formula \[
3000 \xyC{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
3001 C\ar@{}[ur]|{\text{{horizontal stretch}}}}
3009 \begin_layout Subsection
3013 \begin_layout Standard
3018 \begin_layout Plain Layout
3027 -command allows the correct positioning of labels along the shaft of arrows.
3028 This feature is sometimes necessary, when the default position of a label
3029 would otherwise clutter the picture, or would even coincide with other
3030 items, such as the intersection of the arrows in the figure below.
3031 In order to shift a label position alongside the shaft of an arrow,
3035 \begin_layout Plain Layout
3045 \begin_inset space ~
3048 allows to prefix the label by a decimal number in parentheses, specifying
3049 the fraction of distance alongside the arrow where the label is to be placed.
3050 For instance, the code
3058 , will place the label on the shaft, but only about one third of the way.
3062 \begin_layout Standard
3063 Doing the same with labels above or below arrows as
3079 , does not work from inside LyX.
3080 Instead, one has to replace the hat-symbol ^, resp.
3081 the underscore _ , by the macros
3115 It is, in fact, possible to enter several labels this way and those labels
3116 are placed correctly, even if the arrow bends.
3117 In the following figure, the bending arrow with its four labels has been
3141 \begin_layout Standard
3142 \begin_inset Formula \[
3143 \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}}\\
3144 \circ\ar[ur]\sb(0.3)\phi & \bullet}
3152 \begin_layout Subsection
3153 Invisible stretched arrows
3156 \begin_layout Standard
3157 A more general trick uses invisible arrows to place any object almost anywhere
3159 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3160 a decimal stretching ratio, e.
3161 \begin_inset space \thinspace{}
3174 Attach a label to this invisible arrow.
3178 \begin_layout Standard
3179 Thus, the down pointing arrow with its label
3180 \begin_inset Formula $\varphi$
3183 at (0.3) of its way along the shaft might as well have been produced by
3184 adding to the regular arrow
3191 \begin_inset Formula $\varphi$
3202 , reaching only 0.6 of the way.
3203 Its label will now appear at 0.3 of the way of the original visible arrow.
3207 \begin_layout Standard
3208 This workaround has two minor drawbacks: First, it does not work with bending
3210 Secondly, prolonging an invisible arrow beyond the normal dimension of
3211 the figure will invisibly extend the figure box, and thereby cause too
3212 much vertical space between the figure and the preceding or the following
3217 \begin_layout Standard
3218 Nevertheless, invisible arrows are an important tool, since they can, in
3219 principle, be used to place information at any chosen place in a diagram.
3220 In the above figure, for instance, we have used an invisible arrow to carry
3227 as label and at the earlier figure we had used an invisible arrow to carry
3229 \begin_inset Quotes eld
3237 \begin_inset Quotes erd
3240 into the center of the figure.
3243 \begin_layout Subsection
3250 \begin_layout Plain Layout
3264 \begin_layout Standard
3265 Here we have focused only on the
3271 command, which is just one of the features available in Kris Rose's amazing
3277 \begin_layout Plain Layout
3295 \begin_layout Plain Layout
3307 \begin_inset CommandInset citation
3313 demonstrates many of the advanced possibilities of that package.
3314 Beware, that its style is rather terse and you will likely need a lot of
3315 experimenting and modifying the many worked examples.
3317 \begin_inset CommandInset citation
3327 \begin_layout Plain Layout
3336 -pic to make braids, cobordism, string diagrams, and much more.
3337 A good and rather systematic introduction to
3343 \begin_layout Plain Layout
3355 \begin_inset CommandInset citation
3362 Even if you share with me the disadvantage of not being fluent in Esperanto,
3363 you will be able to understand most of it.
3367 \begin_layout Bibliography
3368 \begin_inset CommandInset bibitem
3369 LatexCommand bibitem
3380 \begin_layout Plain Layout
3396 Available as part of the
3404 \begin_layout Bibliography
3405 \begin_inset CommandInset bibitem
3406 LatexCommand bibitem
3408 key "instant-preview"
3413 \begin_inset Flex URL
3416 \begin_layout Plain Layout
3418 http://www.tug.org/tex-archive/help/Catalogue/entries/preview-latex.html
3426 \begin_layout Bibliography
3427 \begin_inset CommandInset bibitem
3428 LatexCommand bibitem
3435 \begin_inset Flex URL
3438 \begin_layout Plain Layout
3440 http://www.tug.org/tex-archive/help/Catalogue/entries/xypic.html
3448 \begin_layout Bibliography
3449 \begin_inset CommandInset bibitem
3450 LatexCommand bibitem
3457 \begin_inset Flex URL
3460 \begin_layout Plain Layout
3462 http://www.gnu.org/software/auctex/
3470 \begin_layout Bibliography
3471 \begin_inset CommandInset bibitem
3472 LatexCommand bibitem
3482 \begin_layout Plain Layout
3497 tutorial with an archive of examples
3500 \begin_inset Flex URL
3503 \begin_layout Plain Layout
3505 http://www.dpmms.cam.ac.uk/~al366/xytutorial.html
3513 \begin_layout Bibliography
3514 \begin_inset CommandInset bibitem
3515 LatexCommand bibitem
3525 \begin_layout Plain Layout
3540 Enkonduko pri Xymatrix
3544 \begin_inset Flex URL
3547 \begin_layout Plain Layout
3549 http://filip.ouvaton.org/xypic/xymatrix/index.html