1 #LyX 2.1 created this file. For more info see http://www.lyx.org/
7 % DO NOT ALTER THIS PREAMBLE!!!
9 % This preamble is designed to ensure that the file prints
10 % out as advertised. If you mess with this preamble,
11 % parts of this document may not print out as expected. If you
12 % have problems LaTeXing this file, please contact
13 % the documentation team
14 % email: lyx-docs@lists.lyx.org
18 % define new commands used in sec. 5.1
20 \xydef@\xymatrixrowsep@{#1}}
22 \xydef@\xymatrixcolsep@{#1}}
24 \newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
26 % a pdf-bookmark for the TOC is added
27 \let\myTOC\tableofcontents
28 \renewcommand\tableofcontents{%
29 \pdfbookmark[1]{\contentsname}{}
32 % redefine the \LyX macro for PDF bookmarks
33 \def\LyX{\texorpdfstring{%
34 L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}
41 % set fonts for nicer pdf view
42 \IfFileExists{lmodern.sty}
43 {\usepackage{lmodern}}{}
45 \fi % end if pdflatex is used
48 \use_default_options false
49 \maintain_unincluded_children false
51 \language_package default
56 \font_typewriter default
58 \font_default_family default
59 \use_non_tex_fonts false
65 \default_output_format default
67 \bibtex_command default
68 \index_command default
72 \pdf_title "Using XY-pc in LyX"
73 \pdf_author "H. Peter Gumm"
74 \pdf_subject "LyX's XY-pic manual"
75 \pdf_keywords "LyX, documentation"
77 \pdf_bookmarksnumbered true
78 \pdf_bookmarksopen true
79 \pdf_bookmarksopenlevel 2
84 \pdf_pdfusetitle false
85 \pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue,pdfpagelayout=OneColumn, pdfnewwindow=true,pdfstartview=XYZ, plainpages=false"
88 \use_package amsmath 1
89 \use_package amssymb 1
91 \use_package mathdots 1
92 \use_package mathtools 0
94 \use_package stackrel 0
95 \use_package stmaryrd 0
96 \use_package undertilde 0
98 \cite_engine_type numerical
102 \paperorientation portrait
106 \notefontcolor #0000ff
113 \paragraph_separation indent
114 \paragraph_indentation default
115 \quotes_language english
118 \paperpagestyle default
119 \tracking_changes false
120 \output_changes false
133 \begin_layout Plain Layout
150 \begin_layout Abstract
151 With the recent versions of LyX and with the
155 -style installed in the LaTeX-System, the graph drawing package
161 \begin_layout Plain Layout
172 -pic can be conveniently used inside LyX.
173 Diagrams can be edited and displayed inside the main LyX editing window.
174 Here, we shall describe how to use the
184 inside LyX in order to draw, to edit and to preview diagrams as typically
185 used in category theory, algebra, and related fields.
189 \begin_layout Abstract
190 \begin_inset CommandInset toc
191 LatexCommand tableofcontents
198 \begin_layout Section
202 \begin_layout Standard
207 -package has long served as a convenient tool for easily constructing graphs
208 and diagrams in LaTeX.
209 Unfortunately, its use in LyX had long been restricted to the infamous
210 TeX code boxes, meaning that the LyX editor could only display the LaTeX-source
211 and not the finished diagram.
216 -style of LaTeX which is part of the AUCTeX project
217 \begin_inset CommandInset citation
223 , finally enables the editing and displaying of
227 -diagrams, constructed, displayed and interactively edited inside LyX.
230 \begin_layout Standard
231 \begin_inset VSpace defskip
237 \begin_layout Standard
239 \begin_inset Graphics
240 filename xyfigure.png
248 \begin_layout Standard
249 \begin_inset VSpace defskip
255 \begin_layout Standard
256 In this note, we describe how
260 \begin_layout Plain Layout
269 -pic can be used from inside LyX, how diagrams can be created and edited.
270 We have tested the following using LyX versions 1.3.7 up to 1.6, running under
272 \begin_inset space \thinspace{}
275 XP and under Windows Vista.
279 \begin_layout Standard
280 There are two modes of operations: For a start, and for some first tests,
281 it may be easiest to first enter the
285 \begin_layout Plain Layout
294 -pic code inside the LyX-window, select it all and convert it to a graphical
295 representation by pressing
308 \begin_layout Plain Layout
317 -pic more frequently, or if you want to modify your initial figure, you
318 will want to assemble and modify your figures using LyX's math editor.
322 \begin_layout Standard
323 Once the cursor is moved over a diagram, this is displayed as an array of
324 nodes and arrow-commands.
325 These can be changed interactively.
326 When the cursor leaves the editing area, the diagram reappears.
330 \begin_layout Standard
331 In the first two sections of this documentation, we explain how to use LyX
332 in the first mentioned mode and we introduce all
336 \begin_layout Plain Layout
345 -pic features that might be of use for drawing commutative diagrams, graphs
348 \begin_inset CommandInset ref
350 reference "sec:math-editor"
354 explains how to use the
358 \begin_layout Plain Layout
367 -pic commands inside a math-editing area.
371 \begin_layout Standard
372 It is not our intention to write another introduction to
376 \begin_layout Plain Layout
385 -pic, rather our motivation is to give an introduction how the most important
386 commands work inside LyX, since the keystrokes as explained in the
390 \begin_layout Plain Layout
400 \begin_inset CommandInset citation
406 will not always function correctly inside LyX.
410 \begin_layout Section
414 \begin_layout Standard
415 The following requires that the LaTeX-packages
423 are installed in the LaTeX system.
424 They are available from CTAN, see at
425 \begin_inset CommandInset citation
427 key "instant-preview"
433 \begin_inset CommandInset citation
440 After freshly installing them, it may be necessary, to run
442 Tools\SpecialChar \menuseparator
445 from the main LyX menu.
446 The steps to a first diagram output in LyX are then:
449 \begin_layout Enumerate
456 \begin_layout Enumerate
459 Tools\SpecialChar \menuseparator
460 Preferences\SpecialChar \menuseparator
461 Look and Feel\SpecialChar \menuseparator
471 \begin_layout Enumerate
474 Document\SpecialChar \menuseparator
475 Settings\SpecialChar \menuseparator
484 Use AMS Math package automatically
493 \begin_layout Enumerate
498 works by opening a LyX-document and entering any math-formula, e.
499 \begin_inset space \thinspace{}
503 \begin_inset space \space{}
507 \begin_inset Formula $a+b=c$
514 \begin_layout Enumerate
515 Move the cursor out of the formula, and watch it change its appearance to
516 look just like in the finished DVI- or PostScript document.
521 \begin_layout Enumerate
526 \begin_layout Plain Layout
541 \begin_layout Enumerate
542 Inside your LyX-Document, enter the text
545 \begin_inset Newline newline
557 \begin_layout Enumerate
558 Select the whole text and choose
560 Insert\SpecialChar \menuseparator
561 Math\SpecialChar \menuseparator
564 , or use the corresponding keyboard shortcut
572 \begin_layout Enumerate
573 Move the mouse cursor out of the editing box and wait for a split second
574 to see an arrow appear:
575 \begin_inset Formula $\xymatrix{A\ar[r] & B}
583 \begin_layout Section
587 \begin_layout Standard
588 The following diagram, which is taken from the documentation of
592 \begin_layout Plain Layout
602 \begin_inset CommandInset citation
608 by its creator Kristoffer H.
609 Rose, will provide an example for many of the features available with that
614 \begin_layout LyX-Code
618 \begin_inset Newline newline
630 \begin_inset Newline newline
640 \begin_inset Newline newline
656 \begin_inset Newline newline
664 \begin_layout LyX-Code
668 \begin_layout Standard
669 Again, to turn this code into a graphical output, select it all at once
676 \SpecialChar \ldots{}
677 up to the closing brace \SpecialChar \ldots{}
682 and turn it into display-math as explained above.
683 A moment after the cursor leaves the math-area, you should see the diagram
684 in its full graphical glory as shown below.
688 \begin_layout Standard
689 \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\
690 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
699 \begin_layout Subsection
700 The matrix layout of diagrams
703 \begin_layout Standard
708 uses a matrix to define the layout of the vertices of a diagram.
709 For the above example, we need a
710 \begin_inset Formula $3\times3$
713 -matrix of which 5 entries are used for the vertices
714 \begin_inset Formula $U$
718 \begin_inset Formula $X\times_{Z}Y$
722 \begin_inset Formula $X$
726 \begin_inset Formula $Y$
730 \begin_inset Formula $Z$
733 , the other positions remaining empty.
734 In this case, the following matrix determines the layout:
737 \begin_layout LyX-Code
741 \begin_inset Newline newline
749 \begin_inset Newline newline
759 \begin_inset Newline newline
765 \begin_layout Standard
766 The pattern should be familiar from LaTeX: We see three rows, the first
767 two being terminated by the end-of-line-marker
776 Each line consists of entries, separated by the ampersand
784 \begin_layout Subsection
788 \begin_layout Standard
789 Having entered the vertices, we add arrows between them.
794 -command to produce an arrow is
800 , it is entered into the cell of the matrix where the arrow is to start.
801 The target of the arrow is defined by direction commands
818 These can be combined to a path and enclosed in square brackets.
819 As an example, the arrows from the vertex
820 \begin_inset Formula $U$
823 in the upper left corner down and right to the vertices
824 \begin_inset Formula $X\times_{Z}Y$
828 \begin_inset Formula $Y$
832 \begin_inset Formula $X$
835 are, respectively, defined as
854 Thus the above diagram with all arrows added becomes:
857 \begin_layout LyX-Code
861 \begin_inset Newline newline
875 \begin_inset Newline newline
891 \begin_inset Newline newline
899 \begin_layout LyX-Code
900 \begin_inset Formula $\xymatrix{U\ar[ddr]\ar[drr]\ar[dr]\\
901 & X\times_{Z}Y\ar[d]\ar[r] & X\ar[d]\\
910 \begin_layout LyX-Code
914 \begin_layout LyX-Code
918 \begin_layout Subsection
922 \begin_layout Standard
923 Labels are attached to arrows by affixing them as upper or lower indices
939 defines an arrow going one cell down, two to the right and having the label
941 \begin_inset Formula $\varphi$
945 To attach a label below the arrow, make it a lower index as in
954 This explanation is correct only for arrows pointing to the right.
955 More precisely, imagine looking along the arrow in the direction it is
957 Then an upper index places a label to the left and a lower index places
959 Consequently, an arrow pointing from right to left, such as
970 \begin_inset Formula $\alpha$
974 \begin_inset Formula $\beta$
978 \begin_inset space \thinspace{}
982 \begin_inset space \space{}
986 \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.}
990 Using the character | instead of ^ or _ , it is even possible to place the
991 label right onto the arrow, obscuring part of its shaft.
995 \begin_layout Standard
996 Normally, a label is placed halfway between an arrow's start and target
998 In the first diagram, the central arrow starting in
999 \begin_inset Formula $U$
1003 \begin_inset Formula $(x,y)$
1006 in the middle of the arrow's shaft, rather than in the middle between the
1007 two objects it connects.
1008 This is achieved by prefixing the label with a minus sign, here:
1017 \begin_layout LyX-Code
1021 \begin_inset Newline newline
1039 \begin_inset Newline newline
1055 \begin_inset Newline newline
1063 \begin_layout LyX-Code
1064 \begin_inset Formula $\xymatrix{U\ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\
1065 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
1074 \begin_layout Standard
1078 \begin_layout Plain Layout
1087 -pic normally permits labels to be shifted towards the tip or towards the
1088 start of an arrow by prefixing the label with a ratio, such as e.
1089 \begin_inset space \thinspace{}
1093 \begin_inset space \space{}
1101 In LyX this works only for labels which are placed on top of the arrow,
1114 \begin_layout Standard
1115 For labels placed to the left or to the right of the arrow this does not
1121 \begin_layout Plain Layout
1130 -pic code such as e.
1131 \begin_inset space \thinspace{}
1135 \begin_inset space \space{}
1154 is not correctly interpreted by LyX's math editor.
1155 Two workarounds are suggested in the last section of this note.
1158 \begin_layout Subsection
1162 \begin_layout Standard
1163 Modification of the design, the form or the positioning of arrows are introduced
1169 This is followed by a pair of matching brackets, where the form of the
1182 indicates, whether we want to modify the design, the or the curvature of
1184 Various modifications can be applied to an arrow at the same time.
1187 \begin_layout Subsubsection
1191 \begin_layout Standard
1192 Various designs such as
1208 are possible for the shaft of an arrow.
1209 These can be combined with various ends and various tips.
1210 In general, the design of an arrow is described by following the command
1221 -sign and a pair of braces {\SpecialChar \ldots{}
1222 } containing characters describing the end,
1223 the shaft and the tip of the arrow.
1224 These characters are chosen to give some form of ASCII-rendering of the
1232 produces an arrow with split end, a dotted shaft and double head.
1233 A number of other arrow designs is given in the table below.
1234 Note that the ends of embedding arrows
1235 \begin_inset Formula $\xymatrix{A\ar@{^{(}->}[r] & B}
1239 are described by raising or lowering opening parentheses, such as in
1246 \begin_layout Standard
1248 \begin_inset Tabular
1249 <lyxtabular version="3" rows="11" columns="2">
1250 <features rotate="0" tabularvalignment="middle">
1251 <column alignment="center" valignment="top" width="0pt">
1252 <column alignment="center" valignment="top" width="0">
1254 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1257 \begin_layout Plain Layout
1263 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1266 \begin_layout Plain Layout
1274 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1277 \begin_layout Plain Layout
1278 \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] & \ }
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] & \ }
1343 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1346 \begin_layout Plain Layout
1358 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1361 \begin_layout Plain Layout
1362 \begin_inset Formula $\xymatrix{\ \ar@{~>}[r] & \ }
1371 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1374 \begin_layout Plain Layout
1386 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1389 \begin_layout Plain Layout
1390 \begin_inset Formula $\xymatrix{\ \ar@{->>}[r] & \ }
1399 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1402 \begin_layout Plain Layout
1414 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1417 \begin_layout Plain Layout
1418 \begin_inset Formula $\xymatrix{\ \ar@{-->>}[r] & \ }
1427 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1430 \begin_layout Plain Layout
1442 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1445 \begin_layout Plain Layout
1446 \begin_inset Formula $\xymatrix{\ \ar@{>->>}[r] & \ }
1455 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1458 \begin_layout Plain Layout
1470 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1473 \begin_layout Plain Layout
1474 \begin_inset Formula $\xymatrix{\ \ar@{_{(}->}[r] & \ }
1483 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1486 \begin_layout Plain Layout
1498 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1501 \begin_layout Plain Layout
1502 \begin_inset Formula $\xymatrix{\ \ar@{^{(}->}[r] & \ }
1511 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1514 \begin_layout Plain Layout
1526 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1529 \begin_layout Plain Layout
1530 \begin_inset Formula $\xymatrix{\ \ar@{|-|}[r] & \ }
1539 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1542 \begin_layout Plain Layout
1560 \begin_layout Standard
1562 Following the @-character by either a 2, 3, _ or a ^, we can produce arrows
1563 with double, triple shaft or arrows showing only the lower or upper half
1564 of their tips and ends.
1565 Arrows need not have tips nor ends, as the last example shows:
1568 \begin_layout Standard
1570 \begin_inset Tabular
1571 <lyxtabular version="3" rows="8" columns="2">
1572 <features rotate="0" tabularvalignment="middle">
1573 <column alignment="center" valignment="top" width="0">
1574 <column alignment="center" valignment="top" width="0">
1576 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1579 \begin_layout Plain Layout
1585 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1588 \begin_layout Plain Layout
1596 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1599 \begin_layout Plain Layout
1600 \begin_inset Formula $\xymatrix{\ \ar@2[r] & \ }
1609 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1612 \begin_layout Plain Layout
1624 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1627 \begin_layout Plain Layout
1628 \begin_inset Formula $\xymatrix{\ \ar@3[r] & \ }
1637 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1640 \begin_layout Plain Layout
1652 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1655 \begin_layout Plain Layout
1656 \begin_inset Formula $\xymatrix{\ \ar@_{->}[r] & \ }
1665 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1668 \begin_layout Plain Layout
1680 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1683 \begin_layout Plain Layout
1684 \begin_inset Formula $\xymatrix{\ \ar@^{->}[r] & \ }
1693 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1696 \begin_layout Plain Layout
1708 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1711 \begin_layout Plain Layout
1712 \begin_inset Formula $\xymatrix{\ \ar@^{>>->>}[r] & \ }
1721 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1724 \begin_layout Plain Layout
1729 ar@^{>\SpecialChar \textcompwordmark{}
1730 >->\SpecialChar \textcompwordmark{}
1738 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1741 \begin_layout Plain Layout
1742 \begin_inset Formula $\xymatrix{\ \ar@{^{<}-_{>}}[r] & \ }
1751 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1754 \begin_layout Plain Layout
1766 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1769 \begin_layout Plain Layout
1770 \begin_inset Formula $\xymatrix{\ \ar@2{--}[r] & \ }
1779 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1782 \begin_layout Plain Layout
1800 \begin_layout Subsubsection
1801 Designing your own arrows
1804 \begin_layout Standard
1805 Within certain limits there is even a way to design your own arrows.
1806 Using some the characters
1810 one can even design one's own arrow tips using the
1816 command in the preamble.
1817 For explanations, we refer to the
1823 \begin_layout Plain Layout
1834 -manual, from which we take the example:
1837 \begin_layout Standard
1842 newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
1847 \begin_layout Standard
1849 This defines a new arrow tip, referred to as
1859 and which displays correctly in LyX as:
1860 \begin_inset Formula
1862 \xymatrix{A\ar@{-|>}[r] & \ \ B}
1870 \begin_layout Subsection
1874 \begin_layout Standard
1875 Arrows are shifted sideways with the modifier
1880 \begin_inset Formula $\ldots$
1887 where the ellipsis is replaced by a positive or negative measure.
1888 For instance, to design a pair of mutually opposing arrows between two
1889 nodes, we shift them to see them apart.
1890 Note that the direction of the shift (positive) is to the left if one looks
1895 \begin_layout Standard
1911 \begin_layout Standard
1914 \begin_inset Formula
1916 \xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1924 \begin_layout Subsubsection
1925 Inline or centered diagrams
1928 \begin_layout Standard
1929 Arrows and diagrams can be used inline, such as this one:
1930 \begin_inset Formula $\xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1935 When their code is written inside LyX as above, select it and choose either
1940 for inline appearance or
1945 Diagrams constructed inline can later be centered, or, conversely, centered
1946 diagrams can be changed to inline formulas with
1948 Edit\SpecialChar \menuseparator
1953 \SpecialChar \menuseparator
1954 Change Formula Type.
1957 \begin_layout Subsection
1961 \begin_layout Standard
1962 There are two simple methods to make arrows bend.
1963 The first is giving an explicit value by which the midpoint of the arrow's
1964 shaft is raised or depressed, the other is by forcing the arrow to leave
1965 its origin in a prescribed compass direction and to make him enter the
1966 target at another direction.
1967 The necessary bending of the arrow is determined automatically.
1968 We describe both methods.
1971 \begin_layout Subsubsection
1975 \begin_layout Standard
1976 For bending arrows we use the modifier @/
1977 \begin_inset Formula $\ldots$
1981 The ellipsis stands for a TeX-measure which needs to be entered as a lower
1987 , we could simply write, e.
1988 \begin_inset space \thinspace{}
1992 \begin_inset space \space{}
2001 for an arrow bending
2005 downwards, this cannot directly be done in LyX.
2006 It is necessary, to enclose the measure in a pair of braces, such as e.
2007 \begin_inset space \thinspace{}
2011 \begin_inset space \space{}
2021 As an example, here are two opposing arrows between
2022 \begin_inset Formula $A$
2026 \begin_inset Formula $B$
2029 , each bending by .5 pica, given by the following source code:
2032 \begin_layout Standard
2044 \begin_layout Standard
2045 \begin_inset Formula
2047 \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]}
2055 \begin_layout Subsubsection
2056 Specifying exit- and entrance directions
2059 \begin_layout Standard
2060 An alternative for making arrows bend is by specifying their compass direction
2061 as they are leaving their source and their direction from which they enter
2063 Instead of north, north-east, east, etc., the directions are named
2095 , standing for up, up-right, right, down-right, etc..
2096 A direction is specified as @(
2108 stands for the direction the first object is left and
2112 stands for the direction from which the target is entered.
2113 As an example, we show some bending arrows and a loop, which arises when
2114 we do not specify a target for an arrow, just its incoming and outgoing
2118 \begin_layout Standard
2119 \begin_inset Formula
2121 \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\
2131 \begin_layout LyX-Code
2139 \begin_inset Newline newline
2149 \begin_inset Newline newline
2157 \begin_layout Subsection
2161 \begin_layout Standard
2162 The above example is reminiscent of an automata diagram, except that in
2163 such a diagram states would be enclosed in small circles, with double circles
2164 denoting final states.
2168 \begin_layout Subsubsection
2172 \begin_layout Standard
2177 \begin_layout Plain Layout
2186 -pic, entries can obtain a single or a double frame, such as
2187 \begin_inset Formula $\xymatrix{*+[F]{A}}
2192 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2196 by prefixing an entry with
2204 and enclosing the portion of the entry to be framed in braces.
2205 Normally, the frame will be very tight so that it must be widened by prefixing
2215 Round frames, such as
2216 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2221 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2225 are obtained by specifying the shape as
2230 So the latter figure was constructed as *++[o][F=]{B}.
2231 This way, the following automaton
2234 \begin_layout Standard
2235 \begin_inset Formula
2237 \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]}
2245 \begin_layout Standard
2250 \begin_layout LyX-Code
2260 \begin_layout LyX-Code
2266 \begin_layout LyX-Code
2274 \begin_layout LyX-Code
2278 \begin_layout Standard
2285 \SpecialChar \ldots{}
2290 will make a certain entry style the default, that can, of course be overridden
2291 for individual entries.
2296 entrymodifiers={++[o][F-]}
2298 , all following entries inside
2302 \begin_layout Plain Layout
2311 -matrices would be encircled.
2314 \begin_layout Subsubsection
2318 \begin_layout Standard
2319 Framing a whole rectangle inside an xymatrix is done with the macro pair
2339 The dimension of the rectangle is given as a dotted pair
2340 \begin_inset Formula $P_{0}.P_{1}$
2343 of points denoting the top left and lower right corners of the rectangle.
2344 Each point, in turn,is given as a doubly quoted comma separated pair
2345 \begin_inset Quotes eld
2349 \begin_inset Formula $x,y$
2353 \begin_inset Quotes erd
2357 \begin_inset Formula $x$
2361 \begin_inset Formula $y$
2365 These are followed by the framing commands, to produce figures such as
2367 \begin_inset Formula
2369 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2370 C & \save"1,1"."1,2"*++[F]\frm{}\restore
2387 save"1,1"."2,1"*+[F=]
2400 produces the doubly framed rectangle, and the code for the extra wide horizonta
2412 save"1,1"."1,2"*++[F]
2426 This code can be placed in arbitrary cells of the xymatrix.
2430 \begin_layout Section
2431 Using LyX's math editor
2432 \begin_inset CommandInset label
2434 name "sec:math-editor"
2441 \begin_layout Standard
2442 As an alternative to writing the
2446 code, then transforming it into a math-editing environment by marking it
2455 , one may construct and modify the whole xypic-diagram inside LyX's math
2457 We describe the editing steps for a figure just like the one above.
2461 \begin_layout Subsection
2462 Caveat - how to enter braces
2465 \begin_layout Standard
2466 Recall that in LyX's math-editor any pair of braces
2474 that are to enclose a macro-parameter must be entered by typing just
2481 The closing brace is automatically supplied and in between a box into which
2482 to the parameter is entered.
2487 \begin_layout Plain Layout
2496 -diagrams, this applies in particular to arrow modifications that are normally
2501 \SpecialChar \ldots{}
2506 with the ellipsis standing for the description of end, shaft and tip of
2508 Inside the math-editor, enter just
2514 and let LyX provide the closing brace and the box into which to enter the
2515 description of the arrow.
2518 \begin_layout Standard
2519 Braces that are entered without the backslash
2525 will just appear as typed, but cannot be used to receive a macro parameter.
2526 They are useful, for instance to denote sets, e.
2527 \begin_inset space \thinspace{}
2531 \begin_inset space \space{}
2545 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2551 \begin_layout Subsection
2552 Setting up the matrix
2555 \begin_layout Standard
2564 open a formula environment and enter:
2572 \begin_inset Formula $\times$
2579 \begin_layout Plain Layout
2589 Add extra rows by typing
2593 and add columns by typing
2599 \begin_layout Standard
2600 At any time, further rows or columns can be entered or deleted using commands
2603 Edit\SpecialChar \menuseparator
2607 their shortcuts, beginning with
2611 for the column commands or
2615 for the row commands.
2616 A more direct way uses the icons in the math toolbar once it has been activated
2619 View\SpecialChar \menuseparator
2623 \begin_layout Subsection
2624 Entering nodes, arrows and labels
2627 \begin_layout Standard
2628 Type the nodes into the correct positions of the matrix.
2629 If you move the cursor out of the matrix, you should see a first rendering
2631 Next, add the arrows at the nodes from where they should emanate by typing
2648 can be any path made up from the characters
2665 Make sure that the path indeed leads to an existing node within the matrix.
2666 Otherwise, the figure will not display when the cursor leaves the editing
2670 \begin_layout Standard
2671 Next, label the arrows by attaching a label text as upper or lower indices
2672 to the end of the arrow's path.
2673 As always in LyX's math editor, an underscore
2677 opens a box for a lower index and a
2681 followed by a space opens a box for an upper index.
2682 You can enter any LaTeX-code as a label.
2685 \begin_layout Subsection
2689 \begin_layout Standard
2690 Finally, you can modify the appearance of the arrows by entering @-modifiers
2695 \SpecialChar \ldots{}
2704 \SpecialChar \ldots{}
2709 \SpecialChar \ldots{}
2710 ,\SpecialChar \ldots{}
2715 \SpecialChar \ldots{}
2721 The above caveat applies to the first form only.
2722 It must be entered as
2728 with the arrow description entered inside the LyX-supplied box.
2729 If this box remains empty, you have specified an empty arrow.
2730 This is a useful construction, too, as you will see in the next section.
2734 \begin_layout Standard
2735 The other modifiers,
2739 \SpecialChar \ldots{}
2748 \SpecialChar \ldots{}
2749 ,\SpecialChar \ldots{}
2758 \SpecialChar \ldots{}
2763 are typed as shown with the arrow description replacing the ellipsis.
2764 The code for bending arrows, which in
2793 is any valid TeX-measure that should be entered as upper or lower index
2794 to the first slash /.
2795 Make sure that the ending slash does not end up being part of the upper
2799 \begin_layout Subsection
2800 What if something goes wrong
2803 \begin_layout Standard
2804 When constructing a diagram, you should at times check it by just moving
2805 the cursor out of the editing area to see whether instant preview can successfu
2806 lly convert it into graphical output.
2807 If this does not happen, it may either be that instant preview for some
2808 reason is not aware that it should retranslate the graphics.
2809 Moving the cursor into the editing area and out again sometimes wakes up
2813 \begin_layout Standard
2814 A more serious reason could be a syntactical error in your input (in that
2815 case, the math edition area disappears completely).
2816 If necessary, undo the last editing steps, using
2820 , or try to translate the LyX-file into
2830 View\SpecialChar \menuseparator
2834 There should be some error generated, which hopefully gives you a hint
2835 as to the source of the mistake.
2838 \begin_layout Section
2842 \begin_layout Standard
2843 Certain things do not work correctly inside LyX.
2844 The ones that we (used to) miss most are the horizontal and vertical scaling
2845 of diagrams, and the correct positioning of arrows.
2846 There are some workarounds that we are explaining here.
2850 \begin_layout Subsection
2851 Horizontal and vertical scaling
2854 \begin_layout Standard
2855 It is often convenient to stretch the horizontal or the vertical dimensions
2856 of an entire diagram by using spacing commands for rows and/or columns.
2861 \begin_layout Plain Layout
2871 \begin_inset CommandInset citation
2883 \SpecialChar \ldots{}
2892 \begin_layout Plain Layout
2901 -matrix with row spacing of 1
2902 \begin_inset space ~
2912 \SpecialChar \ldots{}
2917 \SpecialChar \ldots{}
2922 allows to modify the space between columns.
2923 Unfortunately, one cannot type
2924 \begin_inset Quotes eld
2934 \begin_inset Quotes erd
2937 into a formula to get the desired matrix because the @-character is interpreted
2938 by LyX as ending the
2945 But there are two other ways of getting the desired matrix:
2948 \begin_layout Itemize
2950 \begin_inset space \space{}
2959 as normal document text, then either highlight it and press
2965 to get a formula, or copy it into an existing formula.
2966 You can now continue as normal.
2967 \begin_inset Newline newline
2971 \begin_inset Note Greyedout
2974 \begin_layout Plain Layout
2979 This method only works for single spacing settings, so using
2980 \begin_inset Newline newline
2993 xymatrix@M=1pt@C=1dd
2996 The method also don't work if you use '!' to get a fixed grid with a defined
2998 \begin_inset space \space{}
3019 \begin_inset Newline newline
3022 For the following matrix, the command
3029 \begin_inset Formula
3031 \xymatrix@C=9pc{A\ar[r]\ar[d] & B\\
3032 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3041 \begin_layout Itemize
3045 \begin_layout Plain Layout
3055 \begin_inset space ~
3058 stores the values for row-spacing and column-spacing in the variables
3059 \begin_inset Newline newline
3075 So one can add the following macro to the preamble (
3077 Layout\SpecialChar \menuseparator
3078 Document\SpecialChar \menuseparator
3085 \begin_layout LyX-Code
3093 \begin_layout LyX-Code
3098 xymatrixrowsep@{#1}}
3101 \begin_layout Standard
3108 can be defined correspondingly by replacing
3121 Now, a figure can be scaled by entering
3123 xyR{ into the formula before the
3127 \begin_layout Plain Layout
3137 Place the cursor inside the matrix, just before the first entry.
3155 Don't forget the backslashes and remember, that the closing brace is automatica
3156 lly supplied by LyX.
3157 Inside the braces enter the dimensions.
3158 \begin_inset Newline newline
3162 \begin_inset Note Greyedout
3165 \begin_layout Plain Layout
3170 these commands affect all following
3174 \begin_layout Plain Layout
3184 Therefore don't forget to reset the values to default after the usage of
3197 \begin_inset Newline newline
3205 Here you see a diagram which is squashed vertically and stretched horizontally
3215 \begin_inset Formula
3217 \xyR{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
3218 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3225 \begin_inset Formula $\xyR{2pc}\xyC{2pc}$
3229 \begin_inset Note Note
3232 \begin_layout Plain Layout
3242 \begin_layout Subsection
3246 \begin_layout Standard
3251 \begin_layout Plain Layout
3260 -command allows the correct positioning of labels along the shaft of arrows.
3261 This feature is sometimes necessary, when the default position of a label
3262 would otherwise clutter the picture, or would even coincide with other
3263 items, such as the intersection of the arrows in the figure below.
3264 In order to shift a label position alongside the shaft of an arrow,
3268 \begin_layout Plain Layout
3278 \begin_inset space ~
3281 allows to prefix the label by a decimal number in parentheses, specifying
3282 the fraction of distance alongside the arrow where the label is to be placed.
3283 For instance, the code
3291 , will place the label on the shaft, but only about one third of the way.
3295 \begin_layout Standard
3296 Doing the same with labels above or below arrows as
3312 , does not work from inside LyX.
3313 Instead, one has to replace the hat-symbol ^, resp.
3314 the underscore _ , by the macros
3348 It is, in fact, possible to enter several labels this way and those labels
3349 are placed correctly, even if the arrow bends.
3350 In the following figure, the bending arrow with its four labels has been
3374 \begin_layout Standard
3375 \begin_inset Formula
3377 \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}}\\
3378 \circ\ar[ur]\sb(0.3)\phi & \bullet
3387 \begin_layout Subsection
3388 Invisible stretched arrows
3391 \begin_layout Standard
3392 A more general trick uses invisible arrows to place any object almost anywhere
3394 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3395 a decimal stretching ratio, e.
3396 \begin_inset space \thinspace{}
3400 \begin_inset space \space{}
3412 Attach a label to this invisible arrow.
3416 \begin_layout Standard
3417 Thus, the down pointing arrow with its label
3418 \begin_inset Formula $\varphi$
3421 at (0.3) of its way along the shaft might as well have been produced by
3422 adding to the regular arrow
3429 \begin_inset Formula $\varphi$
3440 , reaching only 0.6 of the way.
3441 Its label will now appear at 0.3 of the way of the original visible arrow.
3445 \begin_layout Standard
3446 This workaround has two minor drawbacks: First, it does not work with bending
3448 Secondly, prolonging an invisible arrow beyond the normal dimension of
3449 the figure will invisibly extend the figure box, and thereby cause too
3450 much vertical space between the figure and the preceding or the following
3455 \begin_layout Standard
3456 Nevertheless, invisible arrows are an important tool, since they can, in
3457 principle, be used to place information at any chosen place in a diagram.
3458 In the above figure, for instance, we have used an invisible arrow to carry
3465 as label and at the earlier figure we had used an invisible arrow to carry
3467 \begin_inset Quotes eld
3475 \begin_inset Quotes erd
3478 into the center of the figure.
3481 \begin_layout Subsection
3489 \begin_layout Standard
3490 Here we have focused only on the
3496 command, which is just one of the features available in Kris Rose's amazing
3502 \begin_layout Plain Layout
3520 \begin_layout Plain Layout
3532 \begin_inset CommandInset citation
3538 demonstrates many of the advanced possibilities of that package.
3539 Beware, that its style is rather terse and you will likely need a lot of
3540 experimenting and modifying the many worked examples.
3542 \begin_inset CommandInset citation
3552 \begin_layout Plain Layout
3561 -pic to make braids, cobordism, string diagrams, and much more.
3562 You might want to look on
3566 example shipped with LyX, which demonstrates how to use more advanced
3570 \begin_layout Plain Layout
3590 \begin_layout Standard
3591 \begin_inset Newpage newpage
3597 \begin_layout Bibliography
3598 \begin_inset CommandInset bibitem
3599 LatexCommand bibitem
3609 \begin_layout Plain Layout
3623 \begin_inset Newline newline
3627 \begin_inset Flex URL
3630 \begin_layout Plain Layout
3632 http://mirrors.ctan.org/macros/generic/diagrams/xypic/xy/doc/xyguide.pdf
3640 \begin_layout Bibliography
3641 \begin_inset CommandInset bibitem
3642 LatexCommand bibitem
3643 key "xypic reference"
3648 Rose and Ross Moore:
3652 \begin_layout Plain Layout
3663 -pic Reference Manual
3666 \begin_inset Newline newline
3670 \begin_inset Flex URL
3673 \begin_layout Plain Layout
3675 http://mirrors.ctan.org/macros/generic/diagrams/xypic/xy/doc/xyrefer.pdf
3683 \begin_layout Bibliography
3684 \begin_inset CommandInset bibitem
3685 LatexCommand bibitem
3690 Homepage of the package
3694 \begin_layout Plain Layout
3708 \begin_inset Flex URL
3711 \begin_layout Plain Layout
3713 http://www.ctan.org/pkg/xypic
3721 \begin_layout Bibliography
3722 \begin_inset CommandInset bibitem
3723 LatexCommand bibitem
3724 key "instant-preview"
3728 Homepage of preview-latex:
3729 \begin_inset Newline newline
3733 \begin_inset Flex URL
3736 \begin_layout Plain Layout
3738 http://www.gnu.org/software/auctex/preview-latex.html
3746 \begin_layout Bibliography
3747 \begin_inset CommandInset bibitem
3748 LatexCommand bibitem
3757 \begin_inset Flex URL
3760 \begin_layout Plain Layout
3762 http://www.gnu.org/software/auctex/
3770 \begin_layout Bibliography
3771 \begin_inset CommandInset bibitem
3772 LatexCommand bibitem
3781 \begin_layout Plain Layout
3796 tutorial with an archive of examples
3799 \begin_inset Newline newline
3803 \begin_inset Flex URL
3806 \begin_layout Plain Layout
3808 http://www.math.columbia.edu/~lauda/xy/