1 #LyX 1.6.2svn created this file. For more info see http://www.lyx.org/
9 % 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 ERT-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
228 WindowsXP and under Windows Vista.
232 \begin_layout Standard
233 There are two modes of operations: For a start, and for some first tests,
234 it may be easiest to first enter the
238 \begin_layout Plain Layout
247 -Pic code inside the LyX-window, select it all and convert it to a graphical
248 representation by pressing
261 \begin_layout Plain Layout
270 -Pic more frequently, or if you want to modify your initial figure, you
271 will want to assemble and modify your figures using LyX's math editor.
275 \begin_layout Standard
276 Once the cursor is moved over a diagram, this is displayed as an array of
277 nodes and arrow-commands.
278 These can be changed interactively.
279 When the cursor leaves the editing area, the diagram reappears.
283 \begin_layout Standard
284 In the first two sections of this documentation, we explain how to use LyX
285 in the first mentioned mode and we introduce all
289 \begin_layout Plain Layout
298 -Pic features that might be of use for drawing commutative diagrams, graphs
301 \begin_inset CommandInset ref
303 reference "sec:math-editor"
307 explains how to use the
311 \begin_layout Plain Layout
320 -Pic commands inside a math-editing area.
324 \begin_layout Standard
325 It is not our intention to write another introduction to
329 \begin_layout Plain Layout
338 -Pic, rather our motivation is to give an introduction how the most important
339 commands work inside LyX, since the keystrokes as explained in the
343 \begin_layout Plain Layout
353 \begin_inset CommandInset citation
359 will not always function correctly inside LyX.
363 \begin_layout Section
367 \begin_layout Standard
368 The following requires that the LaTeX-packages
376 are installed in the LaTeX system.
377 They are available from CTAN, see at
378 \begin_inset CommandInset citation
380 key "instant-preview"
386 \begin_inset CommandInset citation
393 After freshly installing them, it may be necessary, to run
395 Edit\SpecialChar \menuseparator
398 from the main LyX menu.
399 The steps to a first diagram output in LyX are then:
402 \begin_layout Enumerate
409 \begin_layout Enumerate
412 Edit\SpecialChar \menuseparator
413 Preferences\SpecialChar \menuseparator
414 Look and Feel\SpecialChar \menuseparator
417 and place a check-mark at
425 \begin_layout Enumerate
430 works by opening a LyX-document and entering any math-formula, e.
431 \begin_inset space \thinspace{}
436 \begin_inset Formula $a+b=c$
443 \begin_layout Enumerate
444 Move the cursor out of the formula, and watch it change its appearance to
445 look just like in the finished dvi- or postscript document.
450 \begin_layout Enumerate
457 \begin_layout Enumerate
458 Inside your LyX-Document, enter the text
461 \begin_inset Newline newline
473 \begin_layout Enumerate
474 Select the whole text and choose
476 Insert\SpecialChar \menuseparator
477 Math\SpecialChar \menuseparator
480 , or use the corresponding keyboard shortcut
488 \begin_layout Enumerate
489 Move the mouse cursor out of the editing box and wait for a split second
490 to see an arrow appear:
491 \begin_inset Formula $\xymatrix{A\ar[r] & B}
499 \begin_layout Enumerate
500 In some cases you need to change your document preamble (e.g.
508 Layout\SpecialChar \menuseparator
509 Document\SpecialChar \menuseparator
515 \begin_inset Newline newline
521 \begin_inset Newline newline
528 \begin_layout Section
532 \begin_layout Standard
533 The following diagram, which is taken from the documentation of
537 \begin_layout Plain Layout
547 \begin_inset CommandInset citation
553 by its creator Kristoffer H.
554 Rose, will provide an example for many of the features available with that
559 \begin_layout LyX-Code
563 \begin_inset Newline newline
575 \begin_inset Newline newline
585 \begin_inset Newline newline
601 \begin_inset Newline newline
609 \begin_layout LyX-Code
613 \begin_layout Standard
614 Again, to turn this code into a graphical output, select it all at once
621 \SpecialChar \ldots{}
622 up to the closing brace \SpecialChar \ldots{}
627 and turn it into display-math as explained above.
628 A moment after the cursor leaves the math-area, you should see the diagram
629 in its full graphical glory as shown below.
633 \begin_layout Standard
634 \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\
635 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
643 \begin_layout Subsection
644 The matrix layout of diagrams
647 \begin_layout Standard
652 uses a matrix to define the layout of the vertices of a diagram.
653 For the above example, we need a
654 \begin_inset Formula $3\times3$
657 -matrix of which 5 entries are used for the vertices
658 \begin_inset Formula $U$
662 \begin_inset Formula $X\times_{Z}Y$
666 \begin_inset Formula $X$
670 \begin_inset Formula $Y$
674 \begin_inset Formula $Z$
677 , the other positions remaining empty.
678 In this case, the following matrix determines the layout:
681 \begin_layout LyX-Code
685 \begin_inset Newline newline
693 \begin_inset Newline newline
703 \begin_inset Newline newline
709 \begin_layout Standard
710 The pattern should be familiar from LaTeX: We see three rows, the first
711 two being terminated by the end-of-line-marker
720 Each line consists of entries, separated by the ampersand
728 \begin_layout Subsection
732 \begin_layout Standard
733 Having entered the vertices, we add arrows between them.
738 -command to produce an arrow is
744 , it is entered into the cell of the matrix where the arrow is to start.
745 The target of the arrow is defined by direction commands
762 These can be combined to a path and enclosed in square brackets.
763 As an example, the arrows from the vertex
764 \begin_inset Formula $U$
767 in the upper left corner down and right to the vertices
768 \begin_inset Formula $X\times_{Z}Y$
772 \begin_inset Formula $Y$
776 \begin_inset Formula $X$
779 are, respectively, defined as
798 Thus the above diagram with all arrows added becomes:
801 \begin_layout LyX-Code
805 \begin_inset Newline newline
819 \begin_inset Newline newline
835 \begin_inset Newline newline
843 \begin_layout Standard
844 \begin_inset Formula \xymatrix{ U \ar[ddr] \ar[drr] \ar[dr]\\
845 & X \times_{Z} Y \ar[d] \ar[r] & X \ar[d]\\
854 \begin_layout LyX-Code
858 \begin_layout LyX-Code
862 \begin_layout Subsection
866 \begin_layout Standard
867 Labels are attached to arrows by affixing them as upper or lower indices
883 defines an arrow going one cell down, two to the right and having the label
885 \begin_inset Formula $\varphi$
889 To attach a label below the arrow, make it a lower index as in
898 This explanation is correct only for arrows pointing to the right.
899 More precisely, imagine looking along the arrow in the direction it is
901 Then an upper index places a label to the left and a lower index places
903 Consequently, an arrow pointing from right to left, such as
914 \begin_inset Formula $\alpha$
918 \begin_inset Formula $\beta$
922 \begin_inset space \thinspace{}
926 \begin_inset space \space{}
930 \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.}
934 Using the character | instead of ^ or _ , it is even possible to place the
935 label right onto the arrow, obscuring part of its shaft.
939 \begin_layout Standard
940 Normally, a label is placed halfway between an arrow's start and target
942 In the first diagram, the central arrow starting in
943 \begin_inset Formula $U$
947 \begin_inset Formula $(x,y)$
950 in the middle of the arrow's shaft, rather than in the middle between the
951 two objects it connects.
952 This is achieved by prefixing the label with a minus sign, here:
961 \begin_layout LyX-Code
965 \begin_inset Newline newline
983 \begin_inset Newline newline
999 \begin_inset Newline newline
1007 \begin_layout LyX-Code
1008 \begin_inset Formula \xymatrix{ U \ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\
1009 & X \times_{Z} Y \ar[d]^{q} \ar[r]_{p} & X \ar[d]_{f}\\
1010 & Y \ar[r]^{g} & Z }
1018 \begin_layout Standard
1022 \begin_layout Plain Layout
1031 -pic normally permits labels to be shifted towards the tip or towards the
1032 start of an arrow by prefixing the label with a ratio, such as e.
1033 \begin_inset space \thinspace{}
1042 In LyX this works only for labels which are placed on top of the arrow,
1055 \begin_layout Standard
1056 For labels placed to the left or to the right of the arrow this does not
1062 \begin_layout Plain Layout
1071 -pic code such as e.
1072 \begin_inset space \thinspace{}
1092 is not correctly interpreted by LyX's math editor.
1093 Two workarounds are suggested in the last section of this note.
1096 \begin_layout Subsection
1100 \begin_layout Standard
1101 Modification of the design, the form or the positioning of arrows are introduced
1107 This is followed by a pair of matching brackets, where the form of the
1120 indicates, whether we want to modify the design, the or the curvature of
1122 Various modifactions can be applied to an arrow at the same time.
1125 \begin_layout Subsubsection
1129 \begin_layout Standard
1130 Various designs such as
1146 are possible for the shaft of an arrow.
1147 These can be combined with various ends and various tips.
1148 In general, the design of an arrow is described by following the command
1159 -sign and a pair of braces {\SpecialChar \ldots{}
1160 } containing characters describing the end,
1161 the shaft and the tip of the arrow.
1162 These characters are chosen to give some form of ASCII-rendering of the
1170 produces an arrow with split end, a dotted shaft and double head.
1171 A number of other arrow designs is given in the table below.
1172 Note that the ends of embedding arrows
1173 \begin_inset Formula $\xymatrix{A\ar@{^{(}->}[r] & B}
1177 are described by raising or lowering opening parentheses, such as in
1182 \begin_inset Newline newline
1188 \begin_layout Standard
1189 \begin_inset Tabular
1190 <lyxtabular version="3" rows="11" columns="2">
1191 <features islongtable="true">
1192 <column alignment="center" valignment="top" width="0">
1193 <column alignment="center" valignment="top" width="0">
1195 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1198 \begin_layout Plain Layout
1204 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1207 \begin_layout Plain Layout
1215 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1218 \begin_layout Plain Layout
1219 \begin_inset Formula \xymatrix{\ \ar[r] & \ }
1229 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1232 \begin_layout Plain Layout
1244 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1247 \begin_layout Plain Layout
1248 \begin_inset Formula \xymatrix{\ \ar@{-->}[r] & \ }
1258 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1261 \begin_layout Plain Layout
1273 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1276 \begin_layout Plain Layout
1277 \begin_inset Formula \xymatrix{\ \ar@{..>}[r] & \ }
1287 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1290 \begin_layout Plain Layout
1302 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1305 \begin_layout Plain Layout
1306 \begin_inset Formula \xymatrix{\ \ar@{~>}[r] & \ }
1316 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1319 \begin_layout Plain Layout
1331 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1334 \begin_layout Plain Layout
1335 \begin_inset Formula \xymatrix{\ \ar@{->>}[r] & \ }
1345 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1348 \begin_layout Plain Layout
1360 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1363 \begin_layout Plain Layout
1364 \begin_inset Formula \xymatrix{\ \ar@{-->>}[r] & \ }
1374 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1377 \begin_layout Plain Layout
1389 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1392 \begin_layout Plain Layout
1393 \begin_inset Formula \xymatrix{\ \ar@{>->>}[r] & \ }
1403 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1406 \begin_layout Plain Layout
1418 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1421 \begin_layout Plain Layout
1422 \begin_inset Formula \xymatrix{\ \ar@{_{(}->}[r] & \ }
1432 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1435 \begin_layout Plain Layout
1447 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1450 \begin_layout Plain Layout
1451 \begin_inset Formula \xymatrix{\ \ar@{^{(}->}[r] & \ }
1461 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1464 \begin_layout Plain Layout
1476 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1479 \begin_layout Plain Layout
1480 \begin_inset Formula \xymatrix{\ \ar@{|-|}[r] & \ }
1490 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1493 \begin_layout Plain Layout
1511 \begin_layout Standard
1513 Following the @-character by either a 2, 3, _,or a ^, we can produce arrows
1514 with double, triple shaft or arrows showing only the lower or upper half
1515 of their tips and ends.
1516 Arrows need not have tips nor ends, as the last example shows :
1517 \begin_inset Newline newline
1523 \begin_layout Standard
1524 \begin_inset Tabular
1525 <lyxtabular version="3" rows="8" columns="2">
1526 <features islongtable="true">
1527 <column alignment="center" valignment="top" width="0">
1528 <column alignment="center" valignment="top" width="0">
1530 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1533 \begin_layout Plain Layout
1539 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1542 \begin_layout Plain Layout
1550 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1553 \begin_layout Plain Layout
1554 \begin_inset Formula \xymatrix{\ \ar@2[r] & \ }
1564 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1567 \begin_layout Plain Layout
1579 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1582 \begin_layout Plain Layout
1583 \begin_inset Formula \xymatrix{\ \ar@3[r] & \ }
1593 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1596 \begin_layout Plain Layout
1608 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1611 \begin_layout Plain Layout
1612 \begin_inset Formula \xymatrix{\ \ar@_{->}[r] & \ }
1622 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1625 \begin_layout Plain Layout
1637 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1640 \begin_layout Plain Layout
1641 \begin_inset Formula \xymatrix{\ \ar@^{->}[r] & \ }
1651 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1654 \begin_layout Plain Layout
1666 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1669 \begin_layout Plain Layout
1670 \begin_inset Formula \xymatrix{\ \ar@^{>>->>}[r] & \ }
1680 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1683 \begin_layout Plain Layout
1695 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1698 \begin_layout Plain Layout
1699 \begin_inset Formula \xymatrix{\ \ar@{^{<}-_{>}}[r] & \ }
1709 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1712 \begin_layout Plain Layout
1724 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1727 \begin_layout Plain Layout
1728 \begin_inset Formula \xymatrix{\ \ar@2{--}[r] & \ }
1738 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1741 \begin_layout Plain Layout
1759 \begin_layout Subsubsection
1760 Designing your own arrows
1763 \begin_layout Standard
1764 Within certain limits there is even a way to design your own arrows.
1765 Using some the characters
1769 one can even design one's own arrow tips using the
1775 command in the preample.
1776 For explanations, we refer to the
1782 \begin_layout Plain Layout
1793 -manual, from which we take the example:
1796 \begin_layout Standard
1801 newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
1806 \begin_layout Standard
1808 This defines a new arrow tip, referred to as
1818 and which displays correctly in LyX as:
1819 \begin_inset Formula \[
1820 \xymatrix{A\ar@{-|>}[r] & \ \ B}
1828 \begin_layout Subsection
1832 \begin_layout Standard
1833 Arrows are shifted sideways with the modifier
1838 \begin_inset Formula $\ldots$
1845 where the ellipsis is replaced by a positive or negative measure.
1846 For instance, to design a pair of mutually opposing arrows between two
1847 nodes, we shift them to see them apart.
1848 Note that the direction of the shift (positive) is to the left if one looks
1853 \begin_layout Standard
1869 \begin_layout Standard
1872 \begin_inset space ~
1876 \begin_inset space ~
1880 \begin_inset Formula \[
1881 \xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1890 \begin_layout Subsubsection
1891 Inline or centered diagrams
1894 \begin_layout Standard
1895 Arrows and diagrams can be used inline, such as this one:
1896 \begin_inset Formula $\xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1901 When their code is written inside LyX as above, select it and choose either
1906 for inline appearence or
1911 Diagrams constructed inline can later be centered, or, conversely, centered
1912 diagrams can be changed to inline formulas with
1914 Edit\SpecialChar \menuseparator
1919 \SpecialChar \menuseparator
1923 \begin_layout Subsection
1927 \begin_layout Standard
1928 There are two simple methods to make arrows bend.
1929 The first is giving an explicit value by which the midpoint of the arrow's
1930 shaft is raised or depressed, the other is by forcing the arrow to leave
1931 its origin in a prescribed compass direction and to make him enter the
1932 target at another direction.
1933 The necessary bending of the arrow is determined automatically.
1934 We describe both methods.
1937 \begin_layout Subsubsection
1941 \begin_layout Standard
1942 For bending arrows we use the modifier @/
1943 \begin_inset Formula $\ldots$
1947 The ellipsis stands for a TeX-measure which needs to be entered as a lower
1953 , we could simply write, e.
1954 \begin_inset space \thinspace{}
1964 for an arrow bending
1968 downwards, this cannot directly be done in LyX.
1969 It is necessary, to enclose the measure in a pair of braces, such as e.
1970 \begin_inset space \thinspace{}
1981 As an example, here are two opposing arrows between
1982 \begin_inset Formula $A$
1986 \begin_inset Formula $B$
1989 , each bending by .5 pica, given by the following source code:
1992 \begin_layout Standard
2004 \begin_layout Standard
2005 \begin_inset Formula \[
2006 \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]}
2014 \begin_layout Subsubsection
2015 Specifying exit- and entrance directions.
2019 \begin_layout Standard
2020 An alternative for making arrows bend is by specifying their compass direction
2021 as they are leaving their source and their direction from which they enter
2023 Instead of north, north-east, east, etc., the directions are named
2055 , standing for up, up-right, right, down-right, etc..
2056 A direction is specified as @(
2068 stands for the direction the first object is left and
2072 stands for the direction from which the target is entered.
2073 As an example, we show some bending arrows and a loop, which arises when
2074 we do not specify a target for an arrow, just its incoming and outgoing
2078 \begin_layout Standard
2079 \begin_inset Formula \[
2080 \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\
2089 \begin_layout LyX-Code
2097 \begin_inset Newline newline
2107 \begin_inset Newline newline
2115 \begin_layout Subsection
2119 \begin_layout Standard
2120 The above example is reminiscent of an automata diagram, except that in
2121 such a diagram states would be enclosed in small circles, with double circles
2122 denoting final states.
2126 \begin_layout Subsubsection
2130 \begin_layout Standard
2135 \begin_layout Plain Layout
2144 -Pic, entries can obtain a single or a double frame, such as
2145 \begin_inset Formula $\xymatrix{*+[F]{A}}
2150 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2154 by prefixing an entry with
2162 and enclosing the portion of the entry to be framed in braces.
2163 Normally, the frame will be very tight so that it must be widened by prefixing
2173 Round frames, such as
2174 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2179 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2183 are obtained by specifying the shape as
2188 So the latter figure was constructed as *++[o][F=]{B}.
2189 This way, the following automaton
2192 \begin_layout Standard
2193 \begin_inset Formula \[
2194 \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]}
2202 \begin_layout Standard
2206 \begin_layout Plain Layout
2218 \begin_layout LyX-Code
2228 \begin_layout LyX-Code
2234 \begin_layout LyX-Code
2242 \begin_layout LyX-Code
2246 \begin_layout Standard
2253 \SpecialChar \ldots{}
2258 will make a certain entry style the default, that can, of course be overridden
2259 for individual entries.
2264 entrymodifiers={++[o][F-]}
2266 , all following entries inside
2270 \begin_layout Plain Layout
2279 -matrices would be encircled.
2282 \begin_layout Subsubsection
2286 \begin_layout Standard
2287 Framing a whole rectangle inside an xymatrix is done with the macro pair
2307 The dimension of the rectangle is given as a dotted pair
2308 \begin_inset Formula $P_{0}.P_{1}$
2311 of points denoting the top left and lower right corners of the rectangle.
2312 Each point, in turn,is given as a doubly quoted comma separated pair
2313 \begin_inset Quotes eld
2317 \begin_inset Formula $x,y$
2321 \begin_inset Quotes erd
2325 \begin_inset Formula $x$
2329 \begin_inset Formula $y$
2333 These are followed by the framing commands, to produce figures such as
2335 \begin_inset Formula \[
2336 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2337 C & \save"1,1"."1,2"*++[F]\frm{}\restore}
2353 save"1,1"."2,1"*+[F=]
2366 produces the doubly framed rectangle, and the code for the extra wide horizonta
2378 save"1,1"."1,2"*++[F]
2392 This code can be placed in arbitrary cells of the xymatrix.
2396 \begin_layout Section
2397 Using LyX's math editor
2398 \begin_inset CommandInset label
2400 name "sec:math-editor"
2407 \begin_layout Standard
2408 As an alternative to writing the
2412 code, then transforming it into a math-editing environment by marking it
2421 , one may construct and modify the whole xypic-diagram inside LyX's math
2423 We describe the editing steps for a figure just like the one above.
2427 \begin_layout Subsection
2428 Caveat - how to enter braces
2431 \begin_layout Standard
2432 Recall that in LyX's math-editor any pair of braces
2440 that are to enclose a macro-parameter must be entered by typing just
2447 The closing brace is automatically supplied and in between a box into which
2448 to the parameter is entered.
2453 \begin_layout Plain Layout
2462 -diagrams, this applies in particular to arrow modifications that are normally
2467 \SpecialChar \ldots{}
2472 with the ellipsis standing for the description of end, shaft and tip of
2474 Inside the math-editor, enter just
2480 and let LyX provide the closing brace and the box into which to enter the
2481 description of the arrow.
2484 \begin_layout Standard
2485 Braces that are entered without the backslash
2491 will just appear as typed, but cannot be used to receive a macro parameter.
2492 They are useful, for instance to denote sets, e.
2493 \begin_inset space \thinspace{}
2508 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2514 \begin_layout Subsection
2515 Setting up the matrix
2518 \begin_layout Standard
2527 open a formula environment and enter:
2535 \begin_inset Formula $\times$
2542 \begin_layout Plain Layout
2552 Add extra rows by typing
2556 and add columns by typing
2562 \begin_layout Standard
2563 At any time, further rows or columns can be entered or deleted using commands
2566 Edit\SpecialChar \menuseparator
2570 their shortcuts, beginning with
2574 for the column commands or
2578 for the row commands.
2582 \begin_layout Subsection
2583 Entering nodes, arrows and labels
2586 \begin_layout Standard
2587 Type the nodes into the correct positions of the matrix.
2588 If you move the cursor out of the matrix, you should see a first rendering
2590 Next, add the arrows at the nodes from where they should emanate by typing
2607 can be any path made up from the characters
2624 Make sure that the path indeed leads to an existing node within the matrix.
2625 Otherwise, the figure will not display when the cursor leaves the editing
2629 \begin_layout Standard
2630 Next, label the arrows by attaching a label text as upper or lower indices
2631 to the end of the arrow's path.
2632 As always in LyX's math editor, an underscore
2636 opens a box for a lower index and a
2640 followed by a space opens a box for an upper index.
2641 You can enter any LaTeX-code as a label.
2645 \begin_layout Subsection
2649 \begin_layout Standard
2650 Finally, modify the appearance of the arrows by entering @-modifiers @{\SpecialChar \ldots{}
2652 @<\SpecialChar \ldots{}
2653 >, @(\SpecialChar \ldots{}
2654 ,\SpecialChar \ldots{}
2655 ) or @/\SpecialChar \ldots{}
2657 The above caveat applies to the first form only.
2658 It must be entered as
2664 with the arrow description entered inside the LyX-supplied box.
2665 If this box remains empty, you have specified an empty arrow.
2666 This is a useful construction, too, as you will see in the next section.
2670 \begin_layout Standard
2671 The other modifiers, @<\SpecialChar \ldots{}
2672 >, @(\SpecialChar \ldots{}
2673 ,\SpecialChar \ldots{}
2674 ) and @/\SpecialChar \ldots{}
2675 / are typed as shown with the arrow
2676 description replacing the ellipsis.
2677 The code for bending arrows, which in
2693 is any valid TeX-measure, should be entered as upper or lower index to
2695 Make sure that the ending slash does not end up being part of the upper
2699 \begin_layout Subsection
2700 What if something goes wrong
2703 \begin_layout Standard
2704 When constructing a diagram, you should at times check it by just moving
2705 the cursor out of the editing area to see whether instant preview can successfu
2706 lly convert it into graphical output.
2707 If this does not happen, it may either be that instant preview for some
2708 reason is not aware that it should retranslate the graphics.
2709 Moving the cursor into the editing area and out again sometimes wakes up
2713 \begin_layout Standard
2714 A more serious reason could be a syntactical error in your input.
2715 If necessary, redo the last editing steps, using Ctrl-z, or try to translate
2716 the LyX-file into dvi using Ctrl-d or
2718 View\SpecialChar \menuseparator
2722 There should be some error generated, which hopefully gives you a hint
2723 as to the source of the mistake.
2726 \begin_layout Section
2730 \begin_layout Standard
2731 Certain things do not work correctly inside LyX.
2732 The ones that we (used to) miss most are the horizontal and vertical scaling
2733 of diagrams, and the correct positioning of arrows.
2734 There are some workarounds that we are explaining here.
2738 \begin_layout Subsection
2739 Horizontal and vertical scaling
2742 \begin_layout Standard
2743 It is often convenient to stretch the horizontal or the vertical dimensions
2744 of an entire diagram by using spacing commands for rows and/or columns.
2749 \begin_layout Plain Layout
2758 -manual, for instance,
2764 \SpecialChar \ldots{}
2773 \begin_layout Plain Layout
2782 -matrix with row spacing of 1 pica.
2789 \SpecialChar \ldots{}
2794 \SpecialChar \ldots{}
2799 allows to modify the space between columns.
2800 Unfortunately, these commands do currently not work inside LyX, as the
2801 @-character is interpreted by LyX as ending the
2805 \begin_layout Plain Layout
2818 \begin_layout Standard
2823 \begin_layout Plain Layout
2833 \begin_inset space ~
2836 stores the values for row-spacing and column-spacing in the variables
2848 , add the following macro to the preamble (
2850 Layout\SpecialChar \menuseparator
2851 Document\SpecialChar \menuseparator
2855 \begin_inset Newpage pagebreak
2861 \begin_layout LyX-Code
2869 \begin_layout LyX-Code
2874 xymatrixrowsep@{#1}}
2877 \begin_layout LyX-Code
2881 \begin_layout Standard
2888 can be defined correspondingly by replacing
2901 Now, a figure can be scaled by entering
2907 \begin_layout Plain Layout
2917 Place the cursor inside the matrix, just before the first entry.
2935 Dont't forget the backslashes and remember, that the closing brace is automatic
2936 ally supplied by LyX.
2937 Inside the braces enter the dimensions.
2943 Here you see a diagram which is squashed vertically and stretched horizontally
2955 \begin_layout Standard
2956 \begin_inset Formula \[
2957 \xyC{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
2958 C\ar@{}[ur]|{\text{{horizontal stretch}}}}
2966 \begin_layout Subsection
2970 \begin_layout Standard
2975 \begin_layout Plain Layout
2984 -vcommand allows the correct positioning of labels along the shaft of arrows.
2985 This feature is sometimes necessary, when the default position of a label
2986 would otherwise clutter the picture, or would even coincide with other
2987 items, such as the intersection of the arrows in the figure below.
2988 In order to shift a label position alongside the shaft of an arrow,
2992 \begin_layout Plain Layout
3002 \begin_inset space ~
3005 allows to prefix the label by a decimal number in parentheses, specifying
3006 the fraction of distance alongside the arrow where the label is to be placed.
3007 For instance, the code
3015 , will place the label on the shaft, but only about one third of the way.
3019 \begin_layout Standard
3020 Doing the same with labels above or below arrows as
3036 , does not work from inside LyX.
3037 Instead, one has to replace the hat-symbol ^, resp.
3038 the underscore _ , by the macros
3072 It is, in fact, possible to enter several labels this way and those labels
3073 are placed correctly, even if the arrow bends.
3074 In the following figure, the bending arrow with its four labels has been
3098 \begin_layout Standard
3099 \begin_inset Formula \[
3100 \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}}\\
3101 \circ\ar[ur]\sb(0.3)\phi & \bullet}
3109 \begin_layout Subsection
3110 Invisible stretched arrows
3113 \begin_layout Standard
3114 A more general trick uses invisible arrows to place any object almost anywhere
3116 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3117 a decimal stretching ratio, e.
3118 \begin_inset space \thinspace{}
3131 Attach a label to this invisible arrow.
3135 \begin_layout Standard
3136 Thus, the down pointing arrow with its label
3137 \begin_inset Formula $\varphi$
3140 at (0.3) of its way along the shaft might as well have been produced by
3141 adding to the regular arrow
3148 \begin_inset Formula $\varphi$
3159 , reaching only 0.6 of the way.
3160 Its label will now appear at 0.3 of the way of the original visible arrow.
3164 \begin_layout Standard
3165 This workaround has two minor drawbacks: First, it does not work with bending
3167 Secondly, prolonging an invisible arrow beyond the normal dimension of
3168 the figure will invisibly extend the figure box, and thereby cause too
3169 much vertical space between the figure and the preceding or the following
3174 \begin_layout Standard
3175 Nevertheless, invisible arrows are an important tool, since they can, in
3176 principle, be used to place information at any chosen place in a diagram.
3177 In the above figure, for instance, we have used an invisible arrow to carry
3184 as label and at the earlier figure we had used an invisible arrow to carry
3186 \begin_inset Quotes eld
3194 \begin_inset Quotes erd
3197 into the center of the figure.
3200 \begin_layout Subsection
3204 \begin_layout Standard
3205 Advanced painting can be done when using the
3208 Nice collection of examples from Aaron Lauda can be found at
3209 \begin_inset Flex URL
3212 \begin_layout Plain Layout
3214 http://www.dpmms.cam.ac.uk/~al366/xytutorial.html
3222 \begin_layout Bibliography
3223 \begin_inset CommandInset bibitem
3224 LatexCommand bibitem
3235 \begin_layout Plain Layout
3251 Available as part of the
3259 \begin_layout Bibliography
3260 \begin_inset CommandInset bibitem
3261 LatexCommand bibitem
3263 key "instant-preview"
3268 \begin_inset Flex URL
3271 \begin_layout Plain Layout
3273 http://www.tug.org/tex-archive/help/Catalogue/entries/preview-latex.html
3281 \begin_layout Bibliography
3282 \begin_inset CommandInset bibitem
3283 LatexCommand bibitem
3290 \begin_inset Flex URL
3293 \begin_layout Plain Layout
3295 http://www.tug.org/tex-archive/help/Catalogue/entries/xypic.html
3303 \begin_layout Bibliography
3304 \begin_inset CommandInset bibitem
3305 LatexCommand bibitem
3312 \begin_inset Flex URL
3315 \begin_layout Plain Layout
3317 http://www.gnu.org/software/auctex/