1 #LyX 1.6.0beta3 created this file. For more info see http://www.lyx.org/
13 \xydef@\xymatrixrowsep@{#1}
19 \xydef@\xymatrixcolsep@{#1}
23 \newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
29 \font_typewriter default
30 \font_default_family default
36 \paperfontsize default
45 \paperorientation portrait
48 \paragraph_separation indent
50 \quotes_language english
53 \paperpagestyle default
54 \tracking_changes false
67 \begin_layout Plain Layout
84 \begin_layout Abstract
85 With the recent versions of LyX and with the
89 -style installed in the LaTeX-System, the graph drawing package
95 \begin_layout Plain Layout
106 -Pic can be conveniently used inside LyX.
107 Diagrams can be edited and displayed inside the main LyX editing window.
108 Here, we shall describe how to use the
118 inside LyX in order to draw, to edit and to preview diagrams as typically
119 used in category theory, algebra, and related fields.
123 \begin_layout Abstract
124 \begin_inset CommandInset toc
125 LatexCommand tableofcontents
132 \begin_layout Section
136 \begin_layout Standard
141 -package has long served as a convenient tool for easily constructing graphs
142 and diagrams in LaTeX.
143 Unfortunately, its use in LyX had long been restricted to the infamous
144 ERT-boxes, meaning that the LyX editor could only display the LaTeX-source
145 and not the finished diagram.
150 -style of LaTeX which is part of the AUCTeX project
151 \begin_inset CommandInset citation
157 , finally enables the editing and displaying of
161 -diagrams, constructed, displayed and interactively edited inside LyX.
164 \begin_layout Standard
165 \begin_inset VSpace defskip
171 \begin_layout Standard
172 \begin_inset Graphics
173 filename xyfigure.png
175 BoundingBox 0bp 0bp 580bp 440bp
183 \begin_layout Standard
184 \begin_inset VSpace defskip
190 \begin_layout Standard
191 In this note, we describe how
195 \begin_layout Plain Layout
204 -pic can be used from inside LyX, how diagrams can be created and edited.
205 We have tested the following using LyX versions 1.3.7 up to 1.6, running under
206 WindowsXP and under Windows Vista.
210 \begin_layout Standard
211 There are two modes of operations: For a start, and for some first tests,
212 it may be easiest to first enter the
216 \begin_layout Plain Layout
225 -Pic code inside the LyX-window, select it all and convert it to a graphical
226 representation by pressing
239 \begin_layout Plain Layout
248 -Pic more frequently, or if you want to modify your initial figure, you
249 will want to assemble and modify your figures using LyX's math editor.
253 \begin_layout Standard
254 Once the cursor is moved over a diagram, this is displayed as an array of
255 nodes and arrow-commands.
256 These can be changed interactively.
257 When the cursor leaves the editing area, the diagram reappears.
261 \begin_layout Standard
262 In the first two sections of this documentation, we explain how to use LyX
263 in the first mentioned mode and we introduce all
267 \begin_layout Plain Layout
276 -Pic features that might be of use for drawing commutative diagrams, graphs
278 Section 3 explains how to use the
282 \begin_layout Plain Layout
291 -Pic commands inside a math-editing area.
295 \begin_layout Standard
296 It is not our intention to write another introduction to
300 \begin_layout Plain Layout
309 -Pic, rather our motivation is to give an introduction how the most important
310 commands work inside LyX, since the keystrokes as explained in the
314 \begin_layout Plain Layout
324 \begin_inset CommandInset citation
330 will not always function correctly inside LyX.
334 \begin_layout Section
338 \begin_layout Standard
339 The following requires that the LaTeX-packages
347 are installed in the LaTeX system.
348 They are available from CTAN, see at
349 \begin_inset CommandInset citation
351 key "instant-preview"
357 \begin_inset CommandInset citation
364 After freshly installing them, it may be necessary, to run
366 Edit\SpecialChar \menuseparator
369 from the main LyX menu.
370 The steps to a first diagram output in LyX are then:
373 \begin_layout Enumerate
380 \begin_layout Enumerate
383 Edit\SpecialChar \menuseparator
384 Preferences\SpecialChar \menuseparator
385 Look and Feel\SpecialChar \menuseparator
388 and place a check-mark at
396 \begin_layout Enumerate
401 works by opening a LyX-document and entering any math-formula, e.g.
403 \begin_inset Formula $a+b=c$
410 \begin_layout Enumerate
411 Move the cursor out of the formula, and watch it change its appearance to
412 look just like in the finished dvi- or postscript document.
417 \begin_layout Enumerate
424 \begin_layout Enumerate
427 Layout\SpecialChar \menuseparator
428 Document\SpecialChar \menuseparator
434 \begin_inset Newline newline
442 \begin_layout Enumerate
443 Inside your LyX-Document, enter the text
446 \begin_inset Newline newline
458 \begin_layout Enumerate
459 Select the whole text and choose
461 Insert\SpecialChar \menuseparator
462 Math\SpecialChar \menuseparator
465 , or use the corresponding keyboard shortcut
473 \begin_layout Enumerate
474 Move the mouse cursor out of the editing box and wait for a split second
475 to see an arrow appear:
476 \begin_inset Formula $\xymatrix{A\ar [r] & B}
485 \begin_layout Section
489 \begin_layout Standard
490 The following diagram, which is taken from the documentation of
494 \begin_layout Plain Layout
504 \begin_inset CommandInset citation
510 by its creator Kristoffer H.
511 Rose, will provide an example for many of the features available with that
516 \begin_layout LyX-Code
520 \begin_inset Newline newline
532 \begin_inset Newline newline
542 \begin_inset Newline newline
558 \begin_inset Newline newline
566 \begin_layout LyX-Code
570 \begin_layout Standard
571 Again, to turn this code into a graphical output, select it all at once
578 \SpecialChar \ldots{}
579 up to the closing brace \SpecialChar \ldots{}
584 and turn it into display-math as explained above.
585 A moment after the cursor leaves the math-area, you should see the diagram
586 in its full graphical glory as shown below.
590 \begin_layout Standard
591 \begin_inset Formula $\xymatrix{U\ar @/_{1pc}/[ddr]_{\psi}\ar @/{}^{1pc}/[drr]^{\varphi}\ar @{.>}[dr]|-{(x,y)}\\
592 & X\times_{Z}Y\ar [d]^{q}\ar [r]_{p} & X\ar [d]_{f}\\
600 \begin_layout Subsection
601 The matrix layout of diagrams
604 \begin_layout Standard
609 uses a matrix to define the layout of the vertices of a diagram.
610 For the above example, we need a
611 \begin_inset Formula $3\times3$
614 -matrix of which 5 entries are used for the vertices
615 \begin_inset Formula $U$
619 \begin_inset Formula $X\times_{Z}Y$
623 \begin_inset Formula $X$
627 \begin_inset Formula $Y$
631 \begin_inset Formula $Z$
634 , the other positions remaining empty.
635 In this case, the following matrix determines the layout:
638 \begin_layout LyX-Code
642 \begin_inset Newline newline
650 \begin_inset Newline newline
660 \begin_inset Newline newline
666 \begin_layout Standard
667 The pattern should be familiar from LaTeX: We see three rows, the first
668 two being terminated by the end-of-line-marker
677 Each line consists of entries, separated by the ampersand
685 \begin_layout Subsection
689 \begin_layout Standard
690 Having entered the vertices, we add arrows between them.
695 -command to produce an arrow is
701 , it is entered into the cell of the matrix where the arrow is to start.
702 The target of the arrow is defined by direction commands
719 These can be combined to a path and enclosed in square brackets.
720 As an example, the arrows from the vertex
721 \begin_inset Formula $U$
724 in the upper left corner down and right to the vertices
725 \begin_inset Formula $X\times_{Z}Y$
729 \begin_inset Formula $Y$
733 \begin_inset Formula $X$
736 are, respectively, defined as
755 Thus the above diagram with all arrows added becomes:
758 \begin_layout LyX-Code
762 \begin_inset Newline newline
776 \begin_inset Newline newline
792 \begin_inset Newline newline
800 \begin_layout Standard
801 \begin_inset Formula \xymatrix{ U \ar [ddr] \ar [drr] \ar [dr]\\
802 & X \times_{Z} Y \ar [d] \ar [r] & X \ar [d]\\
811 \begin_layout LyX-Code
815 \begin_layout LyX-Code
819 \begin_layout Subsection
823 \begin_layout Standard
824 Labels are attached to arrows by affixing them as upper or lower indices
840 defines an arrow going one cell down, two to the right and having the label
842 \begin_inset Formula $\varphi$
846 To attach a label below the arrow, make it a lower index as in
855 This explanation is correct only for arrows pointing to the right.
856 More precisely, imagine looking along the arrow in the direction it is
858 Then an upper index places a label to the left and a lower index places
860 Consequently, an arrow pointing from right to left, such as
871 \begin_inset Formula $\alpha$
875 \begin_inset Formula $\beta$
878 above the arrow, i.e.
879 \begin_inset Formula $\xymatrix{\ & \ \ar [l]_{\beta}^{\alpha}.}
883 Using the character | instead of ^ or _ , it is even possible to place the
884 label right onto the arrow, obscuring part of its shaft.
888 \begin_layout Standard
889 Normally, a label is placed halfway between an arrow's start and target
891 In the first diagram, the central arrow starting in
892 \begin_inset Formula $U$
896 \begin_inset Formula $(x,y)$
899 in the middle of the arrow's shaft, rather than in the middle between the
900 two objects it connects.
901 This is achieved by prefixing the label with a minus sign, here:
910 \begin_layout LyX-Code
914 \begin_inset Newline newline
932 \begin_inset Newline newline
948 \begin_inset Newline newline
956 \begin_layout LyX-Code
957 \begin_inset Formula \xymatrix{ U \ar [ddr]_{\psi}\ar [drr]^{\varphi}\ar [dr]|-{(x,y)}\\
958 & X \times_{Z} Y \ar [d]^{q} \ar [r]_{p} & X \ar [d]_{f}\\
959 & Y \ar [r]^{g} & Z }
967 \begin_layout Standard
971 \begin_layout Plain Layout
980 -pic normally permits labels to be shifted towards the tip or towards the
981 start of an arrow by prefixing the label with a ratio, such as e.g.
987 In LyX this works only for labels which are placed on top of the arrow,
1000 \begin_layout Standard
1001 For labels placed to the left or to the right of the arrow this does not
1007 \begin_layout Plain Layout
1016 -pic code such as e.g.
1033 is not correctly interpreted by LyX's math editor.
1034 Two workarounds are suggested in the last section of this note.
1037 \begin_layout Subsection
1041 \begin_layout Standard
1042 Modification of the design, the form or the positioning of arrows are introduced
1048 This is followed by a pair of matching brackets, where the form of the
1061 indicates, whether we want to modify the design, the or the curvature of
1063 Various modifactions can be applied to an arrow at the same time.
1066 \begin_layout Subsubsection
1070 \begin_layout Standard
1071 Various designs such as
1087 are possible for the shaft of an arrow.
1088 These can be combined with various ends and various tips.
1089 In general, the design of an arrow is described by following the command
1100 -sign and a pair of braces {\SpecialChar \ldots{}
1101 } containing characters describing the end,
1102 the shaft and the tip of the arrow.
1103 These characters are chosen to give some form of ASCII-rendering of the
1111 produces an arrow with split end, a dotted shaft and double head.
1112 A number of other arrow designs is given in the table below.
1113 Note that the ends of embedding arrows
1114 \begin_inset Formula $\xymatrix{A\ar @{^{(}->}[r] & B}
1118 are described by raising or lowering opening parentheses, such as in
1123 \begin_inset Newline newline
1129 \begin_layout Standard
1130 \begin_inset Tabular
1131 <lyxtabular version="3" rows="11" columns="2">
1132 <features islongtable="true">
1133 <column alignment="center" valignment="top" width="0">
1134 <column alignment="center" valignment="top" width="0">
1136 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1139 \begin_layout Plain Layout
1145 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1148 \begin_layout Plain Layout
1156 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1159 \begin_layout Plain Layout
1160 \begin_inset Formula \xymatrix{\ \ar [r] & \ }
1170 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1173 \begin_layout Plain Layout
1185 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1188 \begin_layout Plain Layout
1189 \begin_inset Formula \xymatrix{\ \ar @{-->}[r] & \ }
1199 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1202 \begin_layout Plain Layout
1214 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1217 \begin_layout Plain Layout
1218 \begin_inset Formula \xymatrix{\ \ar @{..>}[r] & \ }
1228 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1231 \begin_layout Plain Layout
1243 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1246 \begin_layout Plain Layout
1247 \begin_inset Formula \xymatrix{\ \ar @{~>}[r] & \ }
1257 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1260 \begin_layout Plain Layout
1272 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1275 \begin_layout Plain Layout
1276 \begin_inset Formula \xymatrix{\ \ar @{->>}[r] & \ }
1286 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1289 \begin_layout Plain Layout
1301 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1304 \begin_layout Plain Layout
1305 \begin_inset Formula \xymatrix{\ \ar @{-->>}[r] & \ }
1315 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1318 \begin_layout Plain Layout
1330 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1333 \begin_layout Plain Layout
1334 \begin_inset Formula \xymatrix{\ \ar @{>->>}[r] & \ }
1344 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1347 \begin_layout Plain Layout
1359 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1362 \begin_layout Plain Layout
1363 \begin_inset Formula \xymatrix{\ \ar @{_{(}->}[r] & \ }
1373 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1376 \begin_layout Plain Layout
1388 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1391 \begin_layout Plain Layout
1392 \begin_inset Formula \xymatrix{\ \ar @{^{(}->}[r] & \ }
1402 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1405 \begin_layout Plain Layout
1417 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1420 \begin_layout Plain Layout
1421 \begin_inset Formula \xymatrix{\ \ar @{|-|}[r] & \ }
1431 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1434 \begin_layout Plain Layout
1452 \begin_layout Standard
1456 \begin_layout Plain Layout
1465 Following the @-character by either a 2, 3, _,or a ^, we can produce arrows
1466 with double, triple shaft or arrows showing only the lower or upper half
1467 of their tips and ends.
1468 Arrows need not have tips nor ends, as the last example shows :
1469 \begin_inset Newline newline
1475 \begin_layout Standard
1476 \begin_inset Tabular
1477 <lyxtabular version="3" rows="8" columns="2">
1478 <features islongtable="true">
1479 <column alignment="center" valignment="top" width="0">
1480 <column alignment="center" valignment="top" width="0">
1482 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1485 \begin_layout Plain Layout
1491 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1494 \begin_layout Plain Layout
1502 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1505 \begin_layout Plain Layout
1506 \begin_inset Formula \xymatrix{\ \ar @2[r] & \ }
1516 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1519 \begin_layout Plain Layout
1531 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1534 \begin_layout Plain Layout
1535 \begin_inset Formula \xymatrix{\ \ar @3[r] & \ }
1545 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1548 \begin_layout Plain Layout
1560 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1563 \begin_layout Plain Layout
1564 \begin_inset Formula \xymatrix{\ \ar @_{->}[r] & \ }
1574 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1577 \begin_layout Plain Layout
1589 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1592 \begin_layout Plain Layout
1593 \begin_inset Formula \xymatrix{\ \ar @^{->}[r] & \ }
1603 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1606 \begin_layout Plain Layout
1618 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1621 \begin_layout Plain Layout
1622 \begin_inset Formula \xymatrix{\ \ar @^{>>->>}[r] & \ }
1632 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1635 \begin_layout Plain Layout
1647 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1650 \begin_layout Plain Layout
1651 \begin_inset Formula \xymatrix{\ \ar @{^{<}-_{>}}[r] & \ }
1661 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1664 \begin_layout Plain Layout
1676 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1679 \begin_layout Plain Layout
1680 \begin_inset Formula \xymatrix{\ \ar @2{--}[r] & \ }
1690 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1693 \begin_layout Plain Layout
1711 \begin_layout Subsubsection
1712 Designing your own arrows
1715 \begin_layout Standard
1716 Within certain limits there is even a way to design your own arrows.
1717 Using some the characters
1721 one can even design one's own arrow tips using the
1727 command in the preample.
1728 For explanations, we refer to the
1734 \begin_layout Plain Layout
1745 -manual, from which we take the example:
1748 \begin_layout Standard
1753 newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
1758 \begin_layout Standard
1762 \begin_layout Plain Layout
1771 This defines a new arrow tip, referred to as
1781 and which displays correctly in LyX as:
1782 \begin_inset Formula \[
1783 \xymatrix{A\ar @{-|>}[r] & \ \ B}
1791 \begin_layout Subsection
1795 \begin_layout Standard
1796 Arrows are shifted sideways with the modifier
1801 \begin_inset Formula $\ldots$
1808 where the ellipsis is replaced by a positive or negative measure.
1809 For instance, to design a pair of mutually opposing arrows between two
1810 nodes, we shift them to see them apart.
1811 Note that the direction of the shift (positive) is to the left if one looks
1816 \begin_layout Standard
1832 \begin_layout Standard
1836 \begin_layout Plain Layout
1846 \begin_inset space ~
1850 \begin_inset space ~
1854 \begin_inset Formula \[
1855 \xymatrix{\circ\ar @<1ex>[r] & \circ\ar @<1ex>[l]}
1864 \begin_layout Subsubsection
1865 Inline or centered diagrams
1868 \begin_layout Standard
1869 Arrows and diagrams can be used inline, such as this one:
1870 \begin_inset Formula $\xymatrix{\circ\ar @<1ex>[r] & \circ\ar @<1ex>[l]}
1875 When their code is written inside LyX as above, select it and choose either
1880 for inline appearence or
1885 Diagrams constructed inline can later be centered, or, conversely, centered
1886 diagrams can be changed to inline formulas with
1888 Edit\SpecialChar \menuseparator
1893 \SpecialChar \menuseparator
1897 \begin_layout Subsection
1901 \begin_layout Standard
1902 There are two simple methods to make arrows bend.
1903 The first is giving an explicit value by which the midpoint of the arrow's
1904 shaft is raised or depressed, the other is by forcing the arrow to leave
1905 its origin in a prescribed compass direction and to make him enter the
1906 target at another direction.
1907 The necessary bending of the arrow is determined automatically.
1908 We describe both methods.
1911 \begin_layout Subsubsection
1915 \begin_layout Standard
1916 For bending arrows we use the modifier @/
1917 \begin_inset Formula $\ldots$
1921 The ellipsis stands for a TeX-measure which needs to be entered as a lower
1927 , we could simply write, e.g.
1934 for an arrow bending
1938 downwards, this cannot directly be done in LyX.
1939 It is necessary, to enclose the measure in a pair of braces, such as e.g.
1947 As an example, here are two opposing arrows between
1948 \begin_inset Formula $A$
1952 \begin_inset Formula $B$
1955 , each bending by .5 pica, given by the following source code:
1958 \begin_layout Standard
1970 \begin_layout Standard
1971 \begin_inset Formula \[
1972 \xymatrix{A\ar @/{}_{.5pc}/[r] & B\ar @/{}_{.5pc}/[l]}
1980 \begin_layout Subsubsection
1981 Specifying exit- and entrance directions.
1985 \begin_layout Standard
1986 An alternative for making arrows bend is by specifying their compass direction
1987 as they are leaving their source and their direction from which they enter
1989 Instead of north, north-east, east, etc., the directions are named
2021 , standing for up, up-right, right, down-right, etc..
2022 A direction is specified as @(
2034 stands for the direction the first object is left and
2038 stands for the direction from which the target is entered.
2039 As an example, we show some bending arrows and a loop, which arises when
2040 we do not specify a target for an arrow, just its incoming and outgoing
2044 \begin_layout Standard
2045 \begin_inset Formula \[
2046 \xymatrix{A\ar @(dr,dl)[r]\ar @(dr,dl)[rr] & B\ar @(d,r)[dl] & C\\
2055 \begin_layout LyX-Code
2063 \begin_inset Newline newline
2073 \begin_inset Newline newline
2081 \begin_layout Subsection
2085 \begin_layout Standard
2086 The above example is reminiscent of an automata diagram, except that in
2087 such a diagram states would be enclosed in small circles, with double circles
2088 denoting final states.
2092 \begin_layout Subsubsection
2096 \begin_layout Standard
2101 \begin_layout Plain Layout
2110 -Pic, entries can obtain a single or a double frame, such as
2111 \begin_inset Formula $\xymatrix{*+[F]{A}}
2116 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2120 by prefixing an entry with
2128 and enclosing the portion of the entry to be framed in braces.
2129 Normally, the frame will be very tight so that it must be widened by prefixing
2139 Round frames, such as
2140 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2145 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2149 are obtained by specifying the shape as
2154 So the latter figure was constructed as *++[o][F=]{B}.
2155 This way, the following automaton
2158 \begin_layout Standard
2159 \begin_inset Formula \[
2160 \xymatrix{\txt {start}\ar [r] & *++[o][F]{1}\ar [r] & *++[o][F=]{2}\ar @(ur,dr)\ar @(ur,ul)[l]}
2168 \begin_layout Standard
2172 \begin_layout Plain Layout
2184 \begin_layout LyX-Code
2194 \begin_layout LyX-Code
2200 \begin_layout LyX-Code
2208 \begin_layout LyX-Code
2212 \begin_layout Standard
2219 \SpecialChar \ldots{}
2224 will make a certain entry style the default, that can, of course be overridden
2225 for individual entries.
2230 entrymodifiers={++[o][F-]}
2232 , all following entries inside
2236 \begin_layout Plain Layout
2245 -matrices would be encircled.
2248 \begin_layout Subsubsection
2252 \begin_layout Standard
2253 Framing a whole rectangle inside an xymatrix is done with the macro pair
2273 The dimension of the rectangle is given as a dotted pair
2274 \begin_inset Formula $P_{0}.P_{1}$
2277 of points denoting the top left and lower right corners of the rectangle.
2278 Each point, in turn,is given as a doubly quoted comma separated pair
2279 \begin_inset Quotes eld
2283 \begin_inset Formula $x,y$
2287 \begin_inset Quotes erd
2291 \begin_inset Formula $x$
2295 \begin_inset Formula $y$
2299 These are followed by the framing commands, to produce figures such as
2301 \begin_inset Formula \[
2302 \xymatrix{A & B\ar @(d,r)[dl]\sp (0.2)\phi\sp (0.7)\psi\save "1,1"."2,1"*+[F=]\frm {}\restore \,\\
2303 C & \save "1,1"."1,2"*++[F]\frm {}\restore }
2319 save"1,1"."2,1"*+[F=]
2332 produces the doubly framed rectangle, and the code for the extra wide horizonta
2344 save"1,1"."1,2"*++[F]
2358 This code can be placed in arbitrary cells of the xymatrix.
2362 \begin_layout Section
2363 Using LyX's math editor
2366 \begin_layout Standard
2367 As an alternative to writing the
2371 code, then transforming it into a math-editing environment by marking it
2380 , one may construct and modify the whole xypic-diagram inside LyX's math
2382 We describe the editing steps for a figure just like the one above.
2386 \begin_layout Subsection
2387 Caveat - how to enter braces
2390 \begin_layout Standard
2391 Recall that in LyX's math-editor any pair of braces
2399 that are to enclose a macro-parameter must be entered by typing just
2406 The closing brace is automatically supplied and in between a box into which
2407 to the parameter is entered.
2412 \begin_layout Plain Layout
2421 -diagrams, this applies in particular to arrow modifications that are normally
2426 \SpecialChar \ldots{}
2431 with the ellipsis standing for the description of end, shaft and tip of
2433 Inside the math-editor, enter just
2439 and let LyX provide the closing brace and the box into which to enter the
2440 description of the arrow.
2443 \begin_layout Standard
2444 Braces that are entered without the backslash
2450 will just appear as typed, but cannot be used to receive a macro parameter.
2451 They are useful, for instance to denote sets, e.g.
2463 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2469 \begin_layout Subsection
2470 Setting up the matrix
2473 \begin_layout Standard
2482 open a formula environment and enter:
2490 \begin_inset Formula $\times$
2497 \begin_layout Plain Layout
2507 Add extra rows by typing
2511 and add columns by typing
2517 \begin_layout Standard
2518 At any time, further rows or columns can be entered or deleted using commands
2521 Edit\SpecialChar \menuseparator
2525 their shortcuts, beginning with
2529 for the column commands or
2533 for the row commands.
2537 \begin_layout Subsection
2538 Entering nodes, arrows and labels
2541 \begin_layout Standard
2542 Type the nodes into the correct positions of the matrix.
2543 If you move the cursor out of the matrix, you should see a first rendering
2545 Next, add the arrows at the nodes from where they should emanate by typing
2562 can be any path made up from the characters
2579 Make sure that the path indeed leads to an existing node within the matrix.
2580 Otherwise, the figure will not display when the cursor leaves the editing
2584 \begin_layout Standard
2585 Next, label the arrows by attaching a label text as upper or lower indices
2586 to the end of the arrow's path.
2587 As always in LyX's math editor, an underscore
2591 opens a box for a lower index and a
2595 followed by a space opens a box for an upper index.
2596 You can enter any LaTeX-code as a label.
2600 \begin_layout Subsection
2604 \begin_layout Standard
2605 Finally, modify the appearance of the arrows by entering @-modifiers @{\SpecialChar \ldots{}
2607 @<\SpecialChar \ldots{}
2608 >, @(\SpecialChar \ldots{}
2609 ,\SpecialChar \ldots{}
2610 ) or @/\SpecialChar \ldots{}
2612 The above caveat applies to the first form only.
2613 It must be entered as
2619 with the arrow description entered inside the LyX-supplied box.
2620 If this box remains empty, you have specified an empty arrow.
2621 This is a useful construction, too, as you will see in the next section.
2625 \begin_layout Standard
2626 The other modifiers, @<\SpecialChar \ldots{}
2627 >, @(\SpecialChar \ldots{}
2628 ,\SpecialChar \ldots{}
2629 ) and @/\SpecialChar \ldots{}
2630 / are typed as shown with the arrow
2631 description replacing the ellipsis.
2632 The code for bending arrows, which in
2648 is any valid TeX-measure, should be entered as upper or lower index to
2650 Make sure that the ending slash does not end up being part of the upper
2654 \begin_layout Subsection
2655 What if something goes wrong
2658 \begin_layout Standard
2659 When constructing a diagram, you should at times check it by just moving
2660 the cursor out of the editing area to see whether instant preview can successfu
2661 lly convert it into graphical output.
2662 If this does not happen, it may either be that instant preview for some
2663 reason is not aware that it should retranslate the graphics.
2664 Moving the cursor into the editing area and out again sometimes wakes up
2668 \begin_layout Standard
2669 A more serious reason could be a syntactical error in your input.
2670 If necessary, redo the last editing steps, using Ctrl-z, or try to translate
2671 the LyX-file into dvi using Ctrl-d or
2673 View\SpecialChar \menuseparator
2677 There should be some error generated, which hopefully gives you a hint
2678 as to the source of the mistake.
2681 \begin_layout Section
2685 \begin_layout Standard
2686 Certain things do not work correctly inside LyX.
2687 The ones that we (used to) miss most are the horizontal and vertical scaling
2688 of diagrams, and the correct positioning of arrows.
2689 There are some workarounds that we are explaining here.
2693 \begin_layout Subsection
2694 Horizontal and vertical scaling
2697 \begin_layout Standard
2698 It is often convenient to stretch the horizontal or the vertical dimensions
2699 of an entire diagram by using spacing commands for rows and/or columns.
2704 \begin_layout Plain Layout
2713 -manual, for instance,
2719 \SpecialChar \ldots{}
2728 \begin_layout Plain Layout
2737 -matrix with row spacing of 1 pica.
2744 \SpecialChar \ldots{}
2749 \SpecialChar \ldots{}
2754 allows to modify the space between columns.
2755 Unfortunately, these commands do currently not work inside LyX, as the
2756 @-character is interpreted by LyX as ending the
2760 \begin_layout Plain Layout
2773 \begin_layout Standard
2778 \begin_layout Plain Layout
2788 \begin_inset space ~
2791 stores the values for row-spacing and column-spacing in the variables
2803 , add the following macro to the preamble (
2805 Layout\SpecialChar \menuseparator
2806 Document\SpecialChar \menuseparator
2810 \begin_layout LyX-Code
2816 \begin_layout LyX-Code
2824 \begin_layout LyX-Code
2830 \begin_layout LyX-Code
2838 \begin_layout LyX-Code
2844 \begin_layout LyX-Code
2850 \begin_layout LyX-Code
2854 \begin_layout Standard
2861 can be defined correspondingly by replacing
2874 Now, a figure can be scaled by entering
2880 \begin_layout Plain Layout
2890 Place the cursor inside the matrix, just before the first entry.
2908 Dont't forget the backslashes and remember, that the closing brace is automatic
2909 ally supplied by LyX.
2910 Inside the braces enter the dimensions.
2916 Here you see a diagram which is squashed vertically and stretched horizontally
2928 \begin_layout Standard
2929 \begin_inset Formula \[
2930 \xyC {.5pc}\xyC {9pc}\xymatrix{A\ar [r]\ar [d] & B\\
2931 C\ar @{}[ur]|{\text{{horizontal stretch}}}}
2939 \begin_layout Subsection
2943 \begin_layout Standard
2948 \begin_layout Plain Layout
2957 -vcommand allows the correct positioning of labels along the shaft of arrows.
2958 This feature is sometimes necessary, when the default position of a label
2959 would otherwise clutter the picture, or would even coincide with other
2960 items, such as the intersection of the arrows in the figure below.
2961 In order to shift a label position alongside the shaft of an arrow,
2965 \begin_layout Plain Layout
2975 \begin_inset space ~
2978 allows to prefix the label by a decimal number in parentheses, specifying
2979 the fraction of distance alongside the arrow where the label is to be placed.
2980 For instance, the code
2988 , will place the label on the shaft, but only about one third of the way.
2992 \begin_layout Standard
2993 Doing the same with labels above or below arrows as
3009 , does not work from inside LyX.
3010 Instead, one has to replace the hat-symbol ^, resp.
3011 the underscore _ , by the macros
3045 It is, in fact, possible to enter several labels this way and those labels
3046 are placed correctly, even if the arrow bends.
3047 In the following figure, the bending arrow with its four labels has been
3071 \begin_layout Standard
3072 \begin_inset Formula \[
3073 \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}}\\
3074 \circ\ar [ur]\sb (0.3)\phi & \bullet}
3082 \begin_layout Subsection
3083 Invisible stretched arrows
3086 \begin_layout Standard
3087 A more general trick uses invisible arrows to place any object almost anywhere
3089 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3090 a decimal stretching ratio, e.g.
3100 Attach a label to this invisible arrow.
3104 \begin_layout Standard
3105 Thus, the down pointing arrow with its label
3106 \begin_inset Formula $\varphi$
3109 at (0.3) of its way along the shaft might as well have been produced by
3110 adding to the regular arrow
3117 \begin_inset Formula $\varphi$
3128 , reaching only 0.6 of the way.
3129 Its label will now appear at 0.3 of the way of the original visible arrow.
3133 \begin_layout Standard
3134 This workaround has two minor drawbacks: First, it does not work with bending
3136 Secondly, prolonging an invisible arrow beyond the normal dimension of
3137 the figure will invisibly extend the figure box, and thereby cause too
3138 much vertical space between the figure and the preceding or the following
3143 \begin_layout Standard
3144 Nevertheless, invisible arrows are an important tool, since they can, in
3145 principle, be used to place information at any chosen place in a diagram.
3146 In the above figure, for instance, we have used an invisible arrow to carry
3153 as label and at the earlier figure we had used an invisible arrow to carry
3155 \begin_inset Quotes eld
3163 \begin_inset Quotes erd
3166 into the center of the figure.
3169 \begin_layout Bibliography
3170 \begin_inset CommandInset bibitem
3171 LatexCommand bibitem
3182 \begin_layout Plain Layout
3198 Available as part of the
3206 \begin_layout Bibliography
3207 \begin_inset CommandInset bibitem
3208 LatexCommand bibitem
3210 key "instant-preview"
3215 \begin_inset Flex URL
3218 \begin_layout Plain Layout
3220 http://www.tug.org/tex-archive/help/Catalogue/entries/preview-latex.html
3228 \begin_layout Bibliography
3229 \begin_inset CommandInset bibitem
3230 LatexCommand bibitem
3237 \begin_inset Flex URL
3240 \begin_layout Plain Layout
3242 http://www.tug.org/tex-archive/help/Catalogue/entries/xypic.html
3250 \begin_layout Bibliography
3251 \begin_inset CommandInset bibitem
3252 LatexCommand bibitem
3259 \begin_inset Flex URL
3262 \begin_layout Plain Layout
3264 http://www.gnu.org/software/auctex/