1 #LyX 2.0.0svn 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
44 \default_output_format default
45 \bibtex_command default
46 \index_command default
50 \pdf_title "Using XY-pc in LyX"
51 \pdf_author "H. Peter Gumm"
52 \pdf_subject "LyX's XY-pic manual"
53 \pdf_keywords "LyX, documentation"
55 \pdf_bookmarksnumbered true
56 \pdf_bookmarksopen true
57 \pdf_bookmarksopenlevel 2
62 \pdf_pdfusetitle false
63 \pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue,pdfpagelayout=OneColumn, pdfnewwindow=true,pdfstartview=XYZ, plainpages=false, pdfpagelabels"
71 \paperorientation portrait
79 \paragraph_separation indent
80 \paragraph_indentation default
81 \quotes_language english
84 \paperpagestyle default
85 \tracking_changes false
96 \begin_layout Plain Layout
113 \begin_layout Abstract
114 With the recent versions of LyX and with the
118 -style installed in the LaTeX-System, the graph drawing package
124 \begin_layout Plain Layout
135 -Pic can be conveniently used inside LyX.
136 Diagrams can be edited and displayed inside the main LyX editing window.
137 Here, we shall describe how to use the
147 inside LyX in order to draw, to edit and to preview diagrams as typically
148 used in category theory, algebra, and related fields.
152 \begin_layout Abstract
153 \begin_inset CommandInset toc
154 LatexCommand tableofcontents
161 \begin_layout Section
165 \begin_layout Standard
170 -package has long served as a convenient tool for easily constructing graphs
171 and diagrams in LaTeX.
172 Unfortunately, its use in LyX had long been restricted to the infamous
173 TeX code boxes, meaning that the LyX editor could only display the LaTeX-source
174 and not the finished diagram.
179 -style of LaTeX which is part of the AUCTeX project
180 \begin_inset CommandInset citation
186 , finally enables the editing and displaying of
190 -diagrams, constructed, displayed and interactively edited inside LyX.
193 \begin_layout Standard
194 \begin_inset VSpace defskip
200 \begin_layout Standard
202 \begin_inset Graphics
203 filename xyfigure.png
205 BoundingBox 0bp 0bp 580bp 440bp
213 \begin_layout Standard
214 \begin_inset VSpace defskip
220 \begin_layout Standard
221 In this note, we describe how
225 \begin_layout Plain Layout
234 -pic can be used from inside LyX, how diagrams can be created and edited.
235 We have tested the following using LyX versions 1.3.7 up to 1.6, running under
237 \begin_inset space \thinspace{}
240 XP and under Windows Vista.
244 \begin_layout Standard
245 There are two modes of operations: For a start, and for some first tests,
246 it may be easiest to first enter the
250 \begin_layout Plain Layout
259 -Pic code inside the LyX-window, select it all and convert it to a graphical
260 representation by pressing
273 \begin_layout Plain Layout
282 -Pic more frequently, or if you want to modify your initial figure, you
283 will want to assemble and modify your figures using LyX's math editor.
287 \begin_layout Standard
288 Once the cursor is moved over a diagram, this is displayed as an array of
289 nodes and arrow-commands.
290 These can be changed interactively.
291 When the cursor leaves the editing area, the diagram reappears.
295 \begin_layout Standard
296 In the first two sections of this documentation, we explain how to use LyX
297 in the first mentioned mode and we introduce all
301 \begin_layout Plain Layout
310 -Pic features that might be of use for drawing commutative diagrams, graphs
313 \begin_inset CommandInset ref
315 reference "sec:math-editor"
319 explains how to use the
323 \begin_layout Plain Layout
332 -Pic commands inside a math-editing area.
336 \begin_layout Standard
337 It is not our intention to write another introduction to
341 \begin_layout Plain Layout
350 -Pic, rather our motivation is to give an introduction how the most important
351 commands work inside LyX, since the keystrokes as explained in the
355 \begin_layout Plain Layout
365 \begin_inset CommandInset citation
371 will not always function correctly inside LyX.
375 \begin_layout Section
379 \begin_layout Standard
380 The following requires that the LaTeX-packages
388 are installed in the LaTeX system.
389 They are available from CTAN, see at
390 \begin_inset CommandInset citation
392 key "instant-preview"
398 \begin_inset CommandInset citation
405 After freshly installing them, it may be necessary, to run
407 Edit\SpecialChar \menuseparator
410 from the main LyX menu.
411 The steps to a first diagram output in LyX are then:
414 \begin_layout Enumerate
421 \begin_layout Enumerate
424 Edit\SpecialChar \menuseparator
425 Preferences\SpecialChar \menuseparator
426 Look and Feel\SpecialChar \menuseparator
429 and place a check-mark at
437 \begin_layout Enumerate
442 works by opening a LyX-document and entering any math-formula, e.
443 \begin_inset space \thinspace{}
448 \begin_inset Formula $a+b=c$
455 \begin_layout Enumerate
456 Move the cursor out of the formula, and watch it change its appearance to
457 look just like in the finished DVI- or PostScript document.
462 \begin_layout Enumerate
467 \begin_layout Plain Layout
482 \begin_layout Enumerate
483 Inside your LyX-Document, enter the text
486 \begin_inset Newline newline
498 \begin_layout Enumerate
499 Select the whole text and choose
501 Insert\SpecialChar \menuseparator
502 Math\SpecialChar \menuseparator
505 , or use the corresponding keyboard shortcut
513 \begin_layout Enumerate
514 Move the mouse cursor out of the editing box and wait for a split second
515 to see an arrow appear:
516 \begin_inset Formula $\xymatrix{A\ar[r] & B}
525 \begin_layout Section
529 \begin_layout Standard
530 The following diagram, which is taken from the documentation of
534 \begin_layout Plain Layout
544 \begin_inset CommandInset citation
550 by its creator Kristoffer H.
551 Rose, will provide an example for many of the features available with that
556 \begin_layout LyX-Code
560 \begin_inset Newline newline
572 \begin_inset Newline newline
582 \begin_inset Newline newline
598 \begin_inset Newline newline
606 \begin_layout LyX-Code
610 \begin_layout Standard
611 Again, to turn this code into a graphical output, select it all at once
618 \SpecialChar \ldots{}
619 up to the closing brace \SpecialChar \ldots{}
624 and turn it into display-math as explained above.
625 A moment after the cursor leaves the math-area, you should see the diagram
626 in its full graphical glory as shown below.
630 \begin_layout Standard
631 \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\
632 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
641 \begin_layout Subsection
642 The matrix layout of diagrams
645 \begin_layout Standard
650 uses a matrix to define the layout of the vertices of a diagram.
651 For the above example, we need a
652 \begin_inset Formula $3\times3$
655 -matrix of which 5 entries are used for the vertices
656 \begin_inset Formula $U$
660 \begin_inset Formula $X\times_{Z}Y$
664 \begin_inset Formula $X$
668 \begin_inset Formula $Y$
672 \begin_inset Formula $Z$
675 , the other positions remaining empty.
676 In this case, the following matrix determines the layout:
679 \begin_layout LyX-Code
683 \begin_inset Newline newline
691 \begin_inset Newline newline
701 \begin_inset Newline newline
707 \begin_layout Standard
708 The pattern should be familiar from LaTeX: We see three rows, the first
709 two being terminated by the end-of-line-marker
718 Each line consists of entries, separated by the ampersand
726 \begin_layout Subsection
730 \begin_layout Standard
731 Having entered the vertices, we add arrows between them.
736 -command to produce an arrow is
742 , it is entered into the cell of the matrix where the arrow is to start.
743 The target of the arrow is defined by direction commands
760 These can be combined to a path and enclosed in square brackets.
761 As an example, the arrows from the vertex
762 \begin_inset Formula $U$
765 in the upper left corner down and right to the vertices
766 \begin_inset Formula $X\times_{Z}Y$
770 \begin_inset Formula $Y$
774 \begin_inset Formula $X$
777 are, respectively, defined as
796 Thus the above diagram with all arrows added becomes:
799 \begin_layout LyX-Code
803 \begin_inset Newline newline
817 \begin_inset Newline newline
833 \begin_inset Newline newline
841 \begin_layout Standard
842 \begin_inset Formula \xymatrix{ U \ar[ddr] \ar[drr] \ar[dr]\\
843 & X \times_{Z} Y \ar[d] \ar[r] & X \ar[d]\\
853 \begin_layout LyX-Code
857 \begin_layout LyX-Code
861 \begin_layout Subsection
865 \begin_layout Standard
866 Labels are attached to arrows by affixing them as upper or lower indices
882 defines an arrow going one cell down, two to the right and having the label
884 \begin_inset Formula $\varphi$
888 To attach a label below the arrow, make it a lower index as in
897 This explanation is correct only for arrows pointing to the right.
898 More precisely, imagine looking along the arrow in the direction it is
900 Then an upper index places a label to the left and a lower index places
902 Consequently, an arrow pointing from right to left, such as
913 \begin_inset Formula $\alpha$
917 \begin_inset Formula $\beta$
921 \begin_inset space \thinspace{}
925 \begin_inset space \space{}
929 \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.}
933 Using the character | instead of ^ or _ , it is even possible to place the
934 label right onto the arrow, obscuring part of its shaft.
938 \begin_layout Standard
939 Normally, a label is placed halfway between an arrow's start and target
941 In the first diagram, the central arrow starting in
942 \begin_inset Formula $U$
946 \begin_inset Formula $(x,y)$
949 in the middle of the arrow's shaft, rather than in the middle between the
950 two objects it connects.
951 This is achieved by prefixing the label with a minus sign, here:
960 \begin_layout LyX-Code
964 \begin_inset Newline newline
982 \begin_inset Newline newline
998 \begin_inset Newline newline
1006 \begin_layout LyX-Code
1007 \begin_inset Formula \xymatrix{ U \ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\
1008 & X \times_{Z} Y \ar[d]^{q} \ar[r]_{p} & X \ar[d]_{f}\\
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 modifications 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" longtabularalignment="center">
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" longtabularalignment="center">
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 preamble.
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 appearance 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
2018 \begin_layout Standard
2019 An alternative for making arrows bend is by specifying their compass direction
2020 as they are leaving their source and their direction from which they enter
2022 Instead of north, north-east, east, etc., the directions are named
2054 , standing for up, up-right, right, down-right, etc..
2055 A direction is specified as @(
2067 stands for the direction the first object is left and
2071 stands for the direction from which the target is entered.
2072 As an example, we show some bending arrows and a loop, which arises when
2073 we do not specify a target for an arrow, just its incoming and outgoing
2077 \begin_layout Standard
2078 \begin_inset Formula \[
2079 \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
2207 \begin_layout LyX-Code
2217 \begin_layout LyX-Code
2223 \begin_layout LyX-Code
2231 \begin_layout LyX-Code
2235 \begin_layout Standard
2242 \SpecialChar \ldots{}
2247 will make a certain entry style the default, that can, of course be overridden
2248 for individual entries.
2253 entrymodifiers={++[o][F-]}
2255 , all following entries inside
2259 \begin_layout Plain Layout
2268 -matrices would be encircled.
2271 \begin_layout Subsubsection
2275 \begin_layout Standard
2276 Framing a whole rectangle inside an xymatrix is done with the macro pair
2296 The dimension of the rectangle is given as a dotted pair
2297 \begin_inset Formula $P_{0}.P_{1}$
2300 of points denoting the top left and lower right corners of the rectangle.
2301 Each point, in turn,is given as a doubly quoted comma separated pair
2302 \begin_inset Quotes eld
2306 \begin_inset Formula $x,y$
2310 \begin_inset Quotes erd
2314 \begin_inset Formula $x$
2318 \begin_inset Formula $y$
2322 These are followed by the framing commands, to produce figures such as
2324 \begin_inset Formula \[
2325 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2326 C & \save"1,1"."1,2"*++[F]\frm{}\restore
2343 save"1,1"."2,1"*+[F=]
2356 produces the doubly framed rectangle, and the code for the extra wide horizonta
2368 save"1,1"."1,2"*++[F]
2382 This code can be placed in arbitrary cells of the xymatrix.
2386 \begin_layout Section
2387 Using LyX's math editor
2388 \begin_inset CommandInset label
2390 name "sec:math-editor"
2397 \begin_layout Standard
2398 As an alternative to writing the
2402 code, then transforming it into a math-editing environment by marking it
2411 , one may construct and modify the whole xypic-diagram inside LyX's math
2413 We describe the editing steps for a figure just like the one above.
2417 \begin_layout Subsection
2418 Caveat - how to enter braces
2421 \begin_layout Standard
2422 Recall that in LyX's math-editor any pair of braces
2430 that are to enclose a macro-parameter must be entered by typing just
2437 The closing brace is automatically supplied and in between a box into which
2438 to the parameter is entered.
2443 \begin_layout Plain Layout
2452 -diagrams, this applies in particular to arrow modifications that are normally
2457 \SpecialChar \ldots{}
2462 with the ellipsis standing for the description of end, shaft and tip of
2464 Inside the math-editor, enter just
2470 and let LyX provide the closing brace and the box into which to enter the
2471 description of the arrow.
2474 \begin_layout Standard
2475 Braces that are entered without the backslash
2481 will just appear as typed, but cannot be used to receive a macro parameter.
2482 They are useful, for instance to denote sets, e.
2483 \begin_inset space \thinspace{}
2498 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2504 \begin_layout Subsection
2505 Setting up the matrix
2508 \begin_layout Standard
2517 open a formula environment and enter:
2525 \begin_inset Formula $\times$
2532 \begin_layout Plain Layout
2542 Add extra rows by typing
2546 and add columns by typing
2552 \begin_layout Standard
2553 At any time, further rows or columns can be entered or deleted using commands
2556 Edit\SpecialChar \menuseparator
2560 their shortcuts, beginning with
2564 for the column commands or
2568 for the row commands.
2572 \begin_layout Subsection
2573 Entering nodes, arrows and labels
2576 \begin_layout Standard
2577 Type the nodes into the correct positions of the matrix.
2578 If you move the cursor out of the matrix, you should see a first rendering
2580 Next, add the arrows at the nodes from where they should emanate by typing
2597 can be any path made up from the characters
2614 Make sure that the path indeed leads to an existing node within the matrix.
2615 Otherwise, the figure will not display when the cursor leaves the editing
2619 \begin_layout Standard
2620 Next, label the arrows by attaching a label text as upper or lower indices
2621 to the end of the arrow's path.
2622 As always in LyX's math editor, an underscore
2626 opens a box for a lower index and a
2630 followed by a space opens a box for an upper index.
2631 You can enter any LaTeX-code as a label.
2634 \begin_layout Subsection
2638 \begin_layout Standard
2639 Finally, you can modify the appearance of the arrows by entering @-modifiers
2644 \SpecialChar \ldots{}
2653 \SpecialChar \ldots{}
2658 \SpecialChar \ldots{}
2659 ,\SpecialChar \ldots{}
2664 \SpecialChar \ldots{}
2670 The above caveat applies to the first form only.
2671 It must be entered as
2677 with the arrow description entered inside the LyX-supplied box.
2678 If this box remains empty, you have specified an empty arrow.
2679 This is a useful construction, too, as you will see in the next section.
2683 \begin_layout Standard
2684 The other modifiers,
2688 \SpecialChar \ldots{}
2697 \SpecialChar \ldots{}
2698 ,\SpecialChar \ldots{}
2707 \SpecialChar \ldots{}
2712 are typed as shown with the arrow description replacing the ellipsis.
2713 The code for bending arrows, which in
2742 is any valid TeX-measure that should be entered as upper or lower index
2743 to the first slash /.
2744 Make sure that the ending slash does not end up being part of the upper
2748 \begin_layout Subsection
2749 What if something goes wrong
2752 \begin_layout Standard
2753 When constructing a diagram, you should at times check it by just moving
2754 the cursor out of the editing area to see whether instant preview can successfu
2755 lly convert it into graphical output.
2756 If this does not happen, it may either be that instant preview for some
2757 reason is not aware that it should retranslate the graphics.
2758 Moving the cursor into the editing area and out again sometimes wakes up
2762 \begin_layout Standard
2763 A more serious reason could be a syntactical error in your input.
2764 If necessary, redo the last editing steps, using
2768 , or try to translate the LyX-file into
2778 View\SpecialChar \menuseparator
2782 There should be some error generated, which hopefully gives you a hint
2783 as to the source of the mistake.
2786 \begin_layout Section
2790 \begin_layout Standard
2791 Certain things do not work correctly inside LyX.
2792 The ones that we (used to) miss most are the horizontal and vertical scaling
2793 of diagrams, and the correct positioning of arrows.
2794 There are some workarounds that we are explaining here.
2798 \begin_layout Subsection
2799 Horizontal and vertical scaling
2802 \begin_layout Standard
2803 It is often convenient to stretch the horizontal or the vertical dimensions
2804 of an entire diagram by using spacing commands for rows and/or columns.
2809 \begin_layout Plain Layout
2818 -manual, for instance,
2824 \SpecialChar \ldots{}
2833 \begin_layout Plain Layout
2842 -matrix with row spacing of 1 pica.
2849 \SpecialChar \ldots{}
2854 \SpecialChar \ldots{}
2859 allows to modify the space between columns.
2860 Unfortunately, these commands do currently not work inside LyX, as the
2861 @-character is interpreted by LyX as ending the
2865 \begin_layout Plain Layout
2878 \begin_layout Standard
2883 \begin_layout Plain Layout
2893 \begin_inset space ~
2896 stores the values for row-spacing and column-spacing in the variables
2908 , add the following macro to the preamble (
2910 Layout\SpecialChar \menuseparator
2911 Document\SpecialChar \menuseparator
2915 \begin_inset Newpage pagebreak
2921 \begin_layout LyX-Code
2929 \begin_layout LyX-Code
2934 xymatrixrowsep@{#1}}
2937 \begin_layout LyX-Code
2941 \begin_layout Standard
2948 can be defined correspondingly by replacing
2961 Now, a figure can be scaled by entering
2967 \begin_layout Plain Layout
2977 Place the cursor inside the matrix, just before the first entry.
2995 Don't forget the backslashes and remember, that the closing brace is automatica
2996 lly supplied by LyX.
2997 Inside the braces enter the dimensions.
3003 Here you see a diagram which is squashed vertically and stretched horizontally
3015 \begin_layout Standard
3016 \begin_inset Formula \[
3017 \xyC{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
3018 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3027 \begin_layout Subsection
3031 \begin_layout Standard
3036 \begin_layout Plain Layout
3045 -command allows the correct positioning of labels along the shaft of arrows.
3046 This feature is sometimes necessary, when the default position of a label
3047 would otherwise clutter the picture, or would even coincide with other
3048 items, such as the intersection of the arrows in the figure below.
3049 In order to shift a label position alongside the shaft of an arrow,
3053 \begin_layout Plain Layout
3063 \begin_inset space ~
3066 allows to prefix the label by a decimal number in parentheses, specifying
3067 the fraction of distance alongside the arrow where the label is to be placed.
3068 For instance, the code
3076 , will place the label on the shaft, but only about one third of the way.
3080 \begin_layout Standard
3081 Doing the same with labels above or below arrows as
3097 , does not work from inside LyX.
3098 Instead, one has to replace the hat-symbol ^, resp.
3099 the underscore _ , by the macros
3133 It is, in fact, possible to enter several labels this way and those labels
3134 are placed correctly, even if the arrow bends.
3135 In the following figure, the bending arrow with its four labels has been
3159 \begin_layout Standard
3160 \begin_inset Formula \[
3161 \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}}\\
3162 \circ\ar[ur]\sb(0.3)\phi & \bullet
3171 \begin_layout Subsection
3172 Invisible stretched arrows
3175 \begin_layout Standard
3176 A more general trick uses invisible arrows to place any object almost anywhere
3178 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3179 a decimal stretching ratio, e.
3180 \begin_inset space \thinspace{}
3193 Attach a label to this invisible arrow.
3197 \begin_layout Standard
3198 Thus, the down pointing arrow with its label
3199 \begin_inset Formula $\varphi$
3202 at (0.3) of its way along the shaft might as well have been produced by
3203 adding to the regular arrow
3210 \begin_inset Formula $\varphi$
3221 , reaching only 0.6 of the way.
3222 Its label will now appear at 0.3 of the way of the original visible arrow.
3226 \begin_layout Standard
3227 This workaround has two minor drawbacks: First, it does not work with bending
3229 Secondly, prolonging an invisible arrow beyond the normal dimension of
3230 the figure will invisibly extend the figure box, and thereby cause too
3231 much vertical space between the figure and the preceding or the following
3236 \begin_layout Standard
3237 Nevertheless, invisible arrows are an important tool, since they can, in
3238 principle, be used to place information at any chosen place in a diagram.
3239 In the above figure, for instance, we have used an invisible arrow to carry
3246 as label and at the earlier figure we had used an invisible arrow to carry
3248 \begin_inset Quotes eld
3256 \begin_inset Quotes erd
3259 into the center of the figure.
3262 \begin_layout Subsection
3269 \begin_layout Plain Layout
3283 \begin_layout Standard
3284 Here we have focused only on the
3290 command, which is just one of the features available in Kris Rose's amazing
3296 \begin_layout Plain Layout
3314 \begin_layout Plain Layout
3326 \begin_inset CommandInset citation
3332 demonstrates many of the advanced possibilities of that package.
3333 Beware, that its style is rather terse and you will likely need a lot of
3334 experimenting and modifying the many worked examples.
3336 \begin_inset CommandInset citation
3346 \begin_layout Plain Layout
3355 -pic to make braids, cobordism, string diagrams, and much more.
3356 A good and rather systematic introduction to
3362 \begin_layout Plain Layout
3374 \begin_inset CommandInset citation
3381 Even if you share with me the disadvantage of not being fluent in Esperanto,
3382 you will be able to understand most of it.
3386 \begin_layout Bibliography
3387 \labelwidthstring References
3388 \begin_inset CommandInset bibitem
3389 LatexCommand bibitem
3400 \begin_layout Plain Layout
3416 Available as part of the
3424 \begin_layout Bibliography
3425 \labelwidthstring References
3426 \begin_inset CommandInset bibitem
3427 LatexCommand bibitem
3429 key "instant-preview"
3434 \begin_inset Flex URL
3437 \begin_layout Plain Layout
3439 http://www.tug.org/tex-archive/help/Catalogue/entries/preview-latex.html
3447 \begin_layout Bibliography
3448 \labelwidthstring References
3449 \begin_inset CommandInset bibitem
3450 LatexCommand bibitem
3457 \begin_inset Flex URL
3460 \begin_layout Plain Layout
3462 http://www.tug.org/tex-archive/help/Catalogue/entries/xypic.html
3470 \begin_layout Bibliography
3471 \labelwidthstring References
3472 \begin_inset CommandInset bibitem
3473 LatexCommand bibitem
3480 \begin_inset Flex URL
3483 \begin_layout Plain Layout
3485 http://www.gnu.org/software/auctex/
3493 \begin_layout Bibliography
3494 \labelwidthstring References
3495 \begin_inset CommandInset bibitem
3496 LatexCommand bibitem
3506 \begin_layout Plain Layout
3521 tutorial with an archive of examples
3524 \begin_inset Flex URL
3527 \begin_layout Plain Layout
3529 http://www.dpmms.cam.ac.uk/~al366/xytutorial.html
3537 \begin_layout Bibliography
3538 \labelwidthstring References
3539 \begin_inset CommandInset bibitem
3540 LatexCommand bibitem
3550 \begin_layout Plain Layout
3565 Enkonduko pri Xymatrix
3569 \begin_inset Flex URL
3572 \begin_layout Plain Layout
3574 http://filip.ouvaton.org/xypic/xymatrix/index.html