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
92 \use_package mathdots 1
93 \use_package mathtools 0
95 \use_package stackrel 0
96 \use_package stmaryrd 0
97 \use_package undertilde 0
99 \cite_engine_type default
103 \paperorientation portrait
107 \notefontcolor #0000ff
114 \paragraph_separation indent
115 \paragraph_indentation default
116 \quotes_language english
119 \paperpagestyle default
120 \tracking_changes false
121 \output_changes false
134 \begin_layout Plain Layout
151 \begin_layout Abstract
152 With the recent versions of LyX and with the
156 -style installed in the LaTeX-System, the graph drawing package
162 \begin_layout Plain Layout
173 -pic can be conveniently used inside LyX.
174 Diagrams can be edited and displayed inside the main LyX editing window.
175 Here, we shall describe how to use the
185 inside LyX in order to draw, to edit and to preview diagrams as typically
186 used in category theory, algebra, and related fields.
190 \begin_layout Abstract
191 \begin_inset CommandInset toc
192 LatexCommand tableofcontents
199 \begin_layout Section
203 \begin_layout Standard
208 -package has long served as a convenient tool for easily constructing graphs
209 and diagrams in LaTeX.
210 Unfortunately, its use in LyX had long been restricted to the infamous
211 TeX code boxes, meaning that the LyX editor could only display the LaTeX-source
212 and not the finished diagram.
217 -style of LaTeX which is part of the AUCTeX project
218 \begin_inset CommandInset citation
224 , finally enables the editing and displaying of
228 -diagrams, constructed, displayed and interactively edited inside LyX.
231 \begin_layout Standard
232 \begin_inset VSpace defskip
238 \begin_layout Standard
240 \begin_inset Graphics
241 filename xyfigure.png
249 \begin_layout Standard
250 \begin_inset VSpace defskip
256 \begin_layout Standard
257 In this note, we describe how
261 \begin_layout Plain Layout
270 -pic can be used from inside LyX, how diagrams can be created and edited.
271 We have tested the following using LyX versions 1.3.7 up to 1.6, running under
273 \begin_inset space \thinspace{}
276 XP and under Windows Vista.
280 \begin_layout Standard
281 There are two modes of operations: For a start, and for some first tests,
282 it may be easiest to first enter the
286 \begin_layout Plain Layout
295 -pic code inside the LyX-window, select it all and convert it to a graphical
296 representation by pressing
309 \begin_layout Plain Layout
318 -pic more frequently, or if you want to modify your initial figure, you
319 will want to assemble and modify your figures using LyX's math editor.
323 \begin_layout Standard
324 Once the cursor is moved over a diagram, this is displayed as an array of
325 nodes and arrow-commands.
326 These can be changed interactively.
327 When the cursor leaves the editing area, the diagram reappears.
331 \begin_layout Standard
332 In the first two sections of this documentation, we explain how to use LyX
333 in the first mentioned mode and we introduce all
337 \begin_layout Plain Layout
346 -pic features that might be of use for drawing commutative diagrams, graphs
349 \begin_inset CommandInset ref
351 reference "sec:math-editor"
355 explains how to use the
359 \begin_layout Plain Layout
368 -pic commands inside a math-editing area.
372 \begin_layout Standard
373 It is not our intention to write another introduction to
377 \begin_layout Plain Layout
386 -pic, rather our motivation is to give an introduction how the most important
387 commands work inside LyX, since the keystrokes as explained in the
391 \begin_layout Plain Layout
401 \begin_inset CommandInset citation
407 will not always function correctly inside LyX.
411 \begin_layout Section
415 \begin_layout Standard
416 The following requires that the LaTeX-packages
424 are installed in the LaTeX system.
425 They are available from CTAN, see at
426 \begin_inset CommandInset citation
428 key "instant-preview"
434 \begin_inset CommandInset citation
441 After freshly installing them, it may be necessary, to run
443 Tools\SpecialChar \menuseparator
446 from the main LyX menu.
447 The steps to a first diagram output in LyX are then:
450 \begin_layout Enumerate
457 \begin_layout Enumerate
460 Tools\SpecialChar \menuseparator
461 Preferences\SpecialChar \menuseparator
462 Look and Feel\SpecialChar \menuseparator
472 \begin_layout Enumerate
475 Document\SpecialChar \menuseparator
476 Settings\SpecialChar \menuseparator
485 Use AMS Math package automatically
494 \begin_layout Enumerate
499 works by opening a LyX-document and entering any math-formula, e.
500 \begin_inset space \thinspace{}
504 \begin_inset space \space{}
508 \begin_inset Formula $a+b=c$
515 \begin_layout Enumerate
516 Move the cursor out of the formula, and watch it change its appearance to
517 look just like in the finished DVI- or PostScript document.
522 \begin_layout Enumerate
527 \begin_layout Plain Layout
542 \begin_layout Enumerate
543 Inside your LyX-Document, enter the text
546 \begin_inset Newline newline
558 \begin_layout Enumerate
559 Select the whole text and choose
561 Insert\SpecialChar \menuseparator
562 Math\SpecialChar \menuseparator
565 , or use the corresponding keyboard shortcut
573 \begin_layout Enumerate
574 Move the mouse cursor out of the editing box and wait for a split second
575 to see an arrow appear:
576 \begin_inset Formula $\xymatrix{A\ar[r] & B}
584 \begin_layout Section
588 \begin_layout Standard
589 The following diagram, which is taken from the documentation of
593 \begin_layout Plain Layout
603 \begin_inset CommandInset citation
609 by its creator Kristoffer H.
610 Rose, will provide an example for many of the features available with that
615 \begin_layout LyX-Code
619 \begin_inset Newline newline
631 \begin_inset Newline newline
641 \begin_inset Newline newline
657 \begin_inset Newline newline
665 \begin_layout LyX-Code
669 \begin_layout Standard
670 Again, to turn this code into a graphical output, select it all at once
677 \SpecialChar \ldots{}
678 up to the closing brace \SpecialChar \ldots{}
683 and turn it into display-math as explained above.
684 A moment after the cursor leaves the math-area, you should see the diagram
685 in its full graphical glory as shown below.
689 \begin_layout Standard
690 \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\
691 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
700 \begin_layout Subsection
701 The matrix layout of diagrams
704 \begin_layout Standard
709 uses a matrix to define the layout of the vertices of a diagram.
710 For the above example, we need a
711 \begin_inset Formula $3\times3$
714 -matrix of which 5 entries are used for the vertices
715 \begin_inset Formula $U$
719 \begin_inset Formula $X\times_{Z}Y$
723 \begin_inset Formula $X$
727 \begin_inset Formula $Y$
731 \begin_inset Formula $Z$
734 , the other positions remaining empty.
735 In this case, the following matrix determines the layout:
738 \begin_layout LyX-Code
742 \begin_inset Newline newline
750 \begin_inset Newline newline
760 \begin_inset Newline newline
766 \begin_layout Standard
767 The pattern should be familiar from LaTeX: We see three rows, the first
768 two being terminated by the end-of-line-marker
777 Each line consists of entries, separated by the ampersand
785 \begin_layout Subsection
789 \begin_layout Standard
790 Having entered the vertices, we add arrows between them.
795 -command to produce an arrow is
801 , it is entered into the cell of the matrix where the arrow is to start.
802 The target of the arrow is defined by direction commands
819 These can be combined to a path and enclosed in square brackets.
820 As an example, the arrows from the vertex
821 \begin_inset Formula $U$
824 in the upper left corner down and right to the vertices
825 \begin_inset Formula $X\times_{Z}Y$
829 \begin_inset Formula $Y$
833 \begin_inset Formula $X$
836 are, respectively, defined as
855 Thus the above diagram with all arrows added becomes:
858 \begin_layout LyX-Code
862 \begin_inset Newline newline
876 \begin_inset Newline newline
892 \begin_inset Newline newline
900 \begin_layout LyX-Code
901 \begin_inset Formula $\xymatrix{U\ar[ddr]\ar[drr]\ar[dr]\\
902 & X\times_{Z}Y\ar[d]\ar[r] & X\ar[d]\\
911 \begin_layout LyX-Code
915 \begin_layout LyX-Code
919 \begin_layout Subsection
923 \begin_layout Standard
924 Labels are attached to arrows by affixing them as upper or lower indices
940 defines an arrow going one cell down, two to the right and having the label
942 \begin_inset Formula $\varphi$
946 To attach a label below the arrow, make it a lower index as in
955 This explanation is correct only for arrows pointing to the right.
956 More precisely, imagine looking along the arrow in the direction it is
958 Then an upper index places a label to the left and a lower index places
960 Consequently, an arrow pointing from right to left, such as
971 \begin_inset Formula $\alpha$
975 \begin_inset Formula $\beta$
979 \begin_inset space \thinspace{}
983 \begin_inset space \space{}
987 \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.}
991 Using the character | instead of ^ or _ , it is even possible to place the
992 label right onto the arrow, obscuring part of its shaft.
996 \begin_layout Standard
997 Normally, a label is placed halfway between an arrow's start and target
999 In the first diagram, the central arrow starting in
1000 \begin_inset Formula $U$
1004 \begin_inset Formula $(x,y)$
1007 in the middle of the arrow's shaft, rather than in the middle between the
1008 two objects it connects.
1009 This is achieved by prefixing the label with a minus sign, here:
1018 \begin_layout LyX-Code
1022 \begin_inset Newline newline
1040 \begin_inset Newline newline
1056 \begin_inset Newline newline
1064 \begin_layout LyX-Code
1065 \begin_inset Formula $\xymatrix{U\ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\
1066 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
1075 \begin_layout Standard
1079 \begin_layout Plain Layout
1088 -pic normally permits labels to be shifted towards the tip or towards the
1089 start of an arrow by prefixing the label with a ratio, such as e.
1090 \begin_inset space \thinspace{}
1094 \begin_inset space \space{}
1102 In LyX this works only for labels which are placed on top of the arrow,
1115 \begin_layout Standard
1116 For labels placed to the left or to the right of the arrow this does not
1122 \begin_layout Plain Layout
1131 -pic code such as e.
1132 \begin_inset space \thinspace{}
1136 \begin_inset space \space{}
1155 is not correctly interpreted by LyX's math editor.
1156 Two workarounds are suggested in the last section of this note.
1159 \begin_layout Subsection
1163 \begin_layout Standard
1164 Modification of the design, the form or the positioning of arrows are introduced
1170 This is followed by a pair of matching brackets, where the form of the
1183 indicates, whether we want to modify the design, the or the curvature of
1185 Various modifications can be applied to an arrow at the same time.
1188 \begin_layout Subsubsection
1192 \begin_layout Standard
1193 Various designs such as
1209 are possible for the shaft of an arrow.
1210 These can be combined with various ends and various tips.
1211 In general, the design of an arrow is described by following the command
1222 -sign and a pair of braces {\SpecialChar \ldots{}
1223 } containing characters describing the end,
1224 the shaft and the tip of the arrow.
1225 These characters are chosen to give some form of ASCII-rendering of the
1233 produces an arrow with split end, a dotted shaft and double head.
1234 A number of other arrow designs is given in the table below.
1235 Note that the ends of embedding arrows
1236 \begin_inset Formula $\xymatrix{A\ar@{^{(}->}[r] & B}
1240 are described by raising or lowering opening parentheses, such as in
1247 \begin_layout Standard
1249 \begin_inset Tabular
1250 <lyxtabular version="3" rows="11" columns="2">
1251 <features rotate="0" tabularvalignment="middle">
1252 <column alignment="center" valignment="top" width="0pt">
1253 <column alignment="center" valignment="top">
1255 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1258 \begin_layout Plain Layout
1264 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1267 \begin_layout Plain Layout
1275 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1278 \begin_layout Plain Layout
1279 \begin_inset Formula $\xymatrix{\ \ar[r] & \ }
1288 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1291 \begin_layout Plain Layout
1303 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1306 \begin_layout Plain Layout
1307 \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] & \ }
1344 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1347 \begin_layout Plain Layout
1359 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1362 \begin_layout Plain Layout
1363 \begin_inset Formula $\xymatrix{\ \ar@{~>}[r] & \ }
1372 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1375 \begin_layout Plain Layout
1387 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1390 \begin_layout Plain Layout
1391 \begin_inset Formula $\xymatrix{\ \ar@{->>}[r] & \ }
1400 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1403 \begin_layout Plain Layout
1415 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1418 \begin_layout Plain Layout
1419 \begin_inset Formula $\xymatrix{\ \ar@{-->>}[r] & \ }
1428 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1431 \begin_layout Plain Layout
1443 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1446 \begin_layout Plain Layout
1447 \begin_inset Formula $\xymatrix{\ \ar@{>->>}[r] & \ }
1456 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1459 \begin_layout Plain Layout
1471 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1474 \begin_layout Plain Layout
1475 \begin_inset Formula $\xymatrix{\ \ar@{_{(}->}[r] & \ }
1484 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1487 \begin_layout Plain Layout
1499 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1502 \begin_layout Plain Layout
1503 \begin_inset Formula $\xymatrix{\ \ar@{^{(}->}[r] & \ }
1512 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1515 \begin_layout Plain Layout
1527 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1530 \begin_layout Plain Layout
1531 \begin_inset Formula $\xymatrix{\ \ar@{|-|}[r] & \ }
1540 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1543 \begin_layout Plain Layout
1561 \begin_layout Standard
1563 Following the @-character by either a 2, 3, _ or a ^, we can produce arrows
1564 with double, triple shaft or arrows showing only the lower or upper half
1565 of their tips and ends.
1566 Arrows need not have tips nor ends, as the last example shows:
1569 \begin_layout Standard
1571 \begin_inset Tabular
1572 <lyxtabular version="3" rows="8" columns="2">
1573 <features rotate="0" tabularvalignment="middle">
1574 <column alignment="center" valignment="top">
1575 <column alignment="center" valignment="top">
1577 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1580 \begin_layout Plain Layout
1586 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1589 \begin_layout Plain Layout
1597 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1600 \begin_layout Plain Layout
1601 \begin_inset Formula $\xymatrix{\ \ar@2[r] & \ }
1610 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1613 \begin_layout Plain Layout
1625 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1628 \begin_layout Plain Layout
1629 \begin_inset Formula $\xymatrix{\ \ar@3[r] & \ }
1638 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1641 \begin_layout Plain Layout
1653 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1656 \begin_layout Plain Layout
1657 \begin_inset Formula $\xymatrix{\ \ar@_{->}[r] & \ }
1666 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1669 \begin_layout Plain Layout
1681 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1684 \begin_layout Plain Layout
1685 \begin_inset Formula $\xymatrix{\ \ar@^{->}[r] & \ }
1694 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1697 \begin_layout Plain Layout
1709 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1712 \begin_layout Plain Layout
1713 \begin_inset Formula $\xymatrix{\ \ar@^{>>->>}[r] & \ }
1722 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1725 \begin_layout Plain Layout
1730 ar@^{>\SpecialChar \textcompwordmark{}
1731 >->\SpecialChar \textcompwordmark{}
1739 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1742 \begin_layout Plain Layout
1743 \begin_inset Formula $\xymatrix{\ \ar@{^{<}-_{>}}[r] & \ }
1752 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1755 \begin_layout Plain Layout
1767 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1770 \begin_layout Plain Layout
1771 \begin_inset Formula $\xymatrix{\ \ar@2{--}[r] & \ }
1780 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1783 \begin_layout Plain Layout
1801 \begin_layout Subsubsection
1802 Designing your own arrows
1805 \begin_layout Standard
1806 Within certain limits there is even a way to design your own arrows.
1807 Using some the characters
1811 one can even design one's own arrow tips using the
1817 command in the preamble.
1818 For explanations, we refer to the
1824 \begin_layout Plain Layout
1835 -manual, from which we take the example:
1838 \begin_layout Standard
1843 newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
1848 \begin_layout Standard
1850 This defines a new arrow tip, referred to as
1860 and which displays correctly in LyX as:
1861 \begin_inset Formula
1863 \xymatrix{A\ar@{-|>}[r] & \ \ B}
1871 \begin_layout Subsection
1875 \begin_layout Standard
1876 Arrows are shifted sideways with the modifier
1881 \begin_inset Formula $\ldots$
1888 where the ellipsis is replaced by a positive or negative measure.
1889 For instance, to design a pair of mutually opposing arrows between two
1890 nodes, we shift them to see them apart.
1891 Note that the direction of the shift (positive) is to the left if one looks
1896 \begin_layout Standard
1912 \begin_layout Standard
1915 \begin_inset Formula
1917 \xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1925 \begin_layout Subsubsection
1926 Inline or centered diagrams
1929 \begin_layout Standard
1930 Arrows and diagrams can be used inline, such as this one:
1931 \begin_inset Formula $\xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1936 When their code is written inside LyX as above, select it and choose either
1941 for inline appearance or
1946 Diagrams constructed inline can later be centered, or, conversely, centered
1947 diagrams can be changed to inline formulas with
1949 Edit\SpecialChar \menuseparator
1954 \SpecialChar \menuseparator
1955 Change Formula Type.
1958 \begin_layout Subsection
1962 \begin_layout Standard
1963 There are two simple methods to make arrows bend.
1964 The first is giving an explicit value by which the midpoint of the arrow's
1965 shaft is raised or depressed, the other is by forcing the arrow to leave
1966 its origin in a prescribed compass direction and to make him enter the
1967 target at another direction.
1968 The necessary bending of the arrow is determined automatically.
1969 We describe both methods.
1972 \begin_layout Subsubsection
1976 \begin_layout Standard
1977 For bending arrows we use the modifier @/
1978 \begin_inset Formula $\ldots$
1982 The ellipsis stands for a TeX-measure which needs to be entered as a lower
1988 , we could simply write, e.
1989 \begin_inset space \thinspace{}
1993 \begin_inset space \space{}
2002 for an arrow bending
2006 downwards, this cannot directly be done in LyX.
2007 It is necessary, to enclose the measure in a pair of braces, such as e.
2008 \begin_inset space \thinspace{}
2012 \begin_inset space \space{}
2022 As an example, here are two opposing arrows between
2023 \begin_inset Formula $A$
2027 \begin_inset Formula $B$
2030 , each bending by .5 pica, given by the following source code:
2033 \begin_layout Standard
2045 \begin_layout Standard
2046 \begin_inset Formula
2048 \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]}
2056 \begin_layout Subsubsection
2057 Specifying exit- and entrance directions
2060 \begin_layout Standard
2061 An alternative for making arrows bend is by specifying their compass direction
2062 as they are leaving their source and their direction from which they enter
2064 Instead of north, north-east, east, etc., the directions are named
2096 , standing for up, up-right, right, down-right, etc..
2097 A direction is specified as @(
2109 stands for the direction the first object is left and
2113 stands for the direction from which the target is entered.
2114 As an example, we show some bending arrows and a loop, which arises when
2115 we do not specify a target for an arrow, just its incoming and outgoing
2119 \begin_layout Standard
2120 \begin_inset Formula
2122 \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\
2132 \begin_layout LyX-Code
2140 \begin_inset Newline newline
2150 \begin_inset Newline newline
2158 \begin_layout Subsection
2162 \begin_layout Standard
2163 The above example is reminiscent of an automata diagram, except that in
2164 such a diagram states would be enclosed in small circles, with double circles
2165 denoting final states.
2169 \begin_layout Subsubsection
2173 \begin_layout Standard
2178 \begin_layout Plain Layout
2187 -pic, entries can obtain a single or a double frame, such as
2188 \begin_inset Formula $\xymatrix{*+[F]{A}}
2193 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2197 by prefixing an entry with
2205 and enclosing the portion of the entry to be framed in braces.
2206 Normally, the frame will be very tight so that it must be widened by prefixing
2216 Round frames, such as
2217 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2222 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2226 are obtained by specifying the shape as
2231 So the latter figure was constructed as *++[o][F=]{B}.
2232 This way, the following automaton
2235 \begin_layout Standard
2236 \begin_inset Formula
2238 \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]}
2246 \begin_layout Standard
2251 \begin_layout LyX-Code
2261 \begin_layout LyX-Code
2267 \begin_layout LyX-Code
2275 \begin_layout LyX-Code
2279 \begin_layout Standard
2286 \SpecialChar \ldots{}
2291 will make a certain entry style the default, that can, of course be overridden
2292 for individual entries.
2297 entrymodifiers={++[o][F-]}
2299 , all following entries inside
2303 \begin_layout Plain Layout
2312 -matrices would be encircled.
2315 \begin_layout Subsubsection
2319 \begin_layout Standard
2320 Framing a whole rectangle inside an xymatrix is done with the macro pair
2340 The dimension of the rectangle is given as a dotted pair
2341 \begin_inset Formula $P_{0}.P_{1}$
2344 of points denoting the top left and lower right corners of the rectangle.
2345 Each point, in turn,is given as a doubly quoted comma separated pair
2346 \begin_inset Quotes eld
2350 \begin_inset Formula $x,y$
2354 \begin_inset Quotes erd
2358 \begin_inset Formula $x$
2362 \begin_inset Formula $y$
2366 These are followed by the framing commands, to produce figures such as
2368 \begin_inset Formula
2370 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2371 C & \save"1,1"."1,2"*++[F]\frm{}\restore
2388 save"1,1"."2,1"*+[F=]
2401 produces the doubly framed rectangle, and the code for the extra wide horizonta
2413 save"1,1"."1,2"*++[F]
2427 This code can be placed in arbitrary cells of the xymatrix.
2431 \begin_layout Section
2432 Using LyX's math editor
2433 \begin_inset CommandInset label
2435 name "sec:math-editor"
2442 \begin_layout Standard
2443 As an alternative to writing the
2447 code, then transforming it into a math-editing environment by marking it
2456 , one may construct and modify the whole xypic-diagram inside LyX's math
2458 We describe the editing steps for a figure just like the one above.
2462 \begin_layout Subsection
2463 Caveat - how to enter braces
2466 \begin_layout Standard
2467 Recall that in LyX's math-editor any pair of braces
2475 that are to enclose a macro-parameter must be entered by typing just
2482 The closing brace is automatically supplied and in between a box into which
2483 to the parameter is entered.
2488 \begin_layout Plain Layout
2497 -diagrams, this applies in particular to arrow modifications that are normally
2502 \SpecialChar \ldots{}
2507 with the ellipsis standing for the description of end, shaft and tip of
2509 Inside the math-editor, enter just
2515 and let LyX provide the closing brace and the box into which to enter the
2516 description of the arrow.
2519 \begin_layout Standard
2520 Braces that are entered without the backslash
2526 will just appear as typed, but cannot be used to receive a macro parameter.
2527 They are useful, for instance to denote sets, e.
2528 \begin_inset space \thinspace{}
2532 \begin_inset space \space{}
2546 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2552 \begin_layout Subsection
2553 Setting up the matrix
2556 \begin_layout Standard
2565 open a formula environment and enter:
2573 \begin_inset Formula $\times$
2580 \begin_layout Plain Layout
2590 Add extra rows by typing
2594 and add columns by typing
2600 \begin_layout Standard
2601 At any time, further rows or columns can be entered or deleted using commands
2604 Edit\SpecialChar \menuseparator
2608 their shortcuts, beginning with
2612 for the column commands or
2616 for the row commands.
2617 A more direct way uses the icons in the math toolbar once it has been activated
2620 View\SpecialChar \menuseparator
2624 \begin_layout Subsection
2625 Entering nodes, arrows and labels
2628 \begin_layout Standard
2629 Type the nodes into the correct positions of the matrix.
2630 If you move the cursor out of the matrix, you should see a first rendering
2632 Next, add the arrows at the nodes from where they should emanate by typing
2649 can be any path made up from the characters
2666 Make sure that the path indeed leads to an existing node within the matrix.
2667 Otherwise, the figure will not display when the cursor leaves the editing
2671 \begin_layout Standard
2672 Next, label the arrows by attaching a label text as upper or lower indices
2673 to the end of the arrow's path.
2674 As always in LyX's math editor, an underscore
2678 opens a box for a lower index and a
2682 followed by a space opens a box for an upper index.
2683 You can enter any LaTeX-code as a label.
2686 \begin_layout Subsection
2690 \begin_layout Standard
2691 Finally, you can modify the appearance of the arrows by entering @-modifiers
2696 \SpecialChar \ldots{}
2705 \SpecialChar \ldots{}
2710 \SpecialChar \ldots{}
2711 ,\SpecialChar \ldots{}
2716 \SpecialChar \ldots{}
2722 The above caveat applies to the first form only.
2723 It must be entered as
2729 with the arrow description entered inside the LyX-supplied box.
2730 If this box remains empty, you have specified an empty arrow.
2731 This is a useful construction, too, as you will see in the next section.
2735 \begin_layout Standard
2736 The other modifiers,
2740 \SpecialChar \ldots{}
2749 \SpecialChar \ldots{}
2750 ,\SpecialChar \ldots{}
2759 \SpecialChar \ldots{}
2764 are typed as shown with the arrow description replacing the ellipsis.
2765 The code for bending arrows, which in
2794 is any valid TeX-measure that should be entered as upper or lower index
2795 to the first slash /.
2796 Make sure that the ending slash does not end up being part of the upper
2800 \begin_layout Subsection
2801 What if something goes wrong
2804 \begin_layout Standard
2805 When constructing a diagram, you should at times check it by just moving
2806 the cursor out of the editing area to see whether instant preview can successfu
2807 lly convert it into graphical output.
2808 If this does not happen, it may either be that instant preview for some
2809 reason is not aware that it should retranslate the graphics.
2810 Moving the cursor into the editing area and out again sometimes wakes up
2814 \begin_layout Standard
2815 A more serious reason could be a syntactical error in your input (in that
2816 case, the math edition area disappears completely).
2817 If necessary, undo the last editing steps, using
2821 , or try to translate the LyX-file into
2831 View\SpecialChar \menuseparator
2835 There should be some error generated, which hopefully gives you a hint
2836 as to the source of the mistake.
2839 \begin_layout Section
2843 \begin_layout Standard
2844 Certain things do not work correctly inside LyX.
2845 The ones that we (used to) miss most are the horizontal and vertical scaling
2846 of diagrams, and the correct positioning of arrows.
2847 There are some workarounds that we are explaining here.
2851 \begin_layout Subsection
2852 Horizontal and vertical scaling
2855 \begin_layout Standard
2856 It is often convenient to stretch the horizontal or the vertical dimensions
2857 of an entire diagram by using spacing commands for rows and/or columns.
2862 \begin_layout Plain Layout
2872 \begin_inset CommandInset citation
2884 \SpecialChar \ldots{}
2893 \begin_layout Plain Layout
2902 -matrix with row spacing of 1
2903 \begin_inset space ~
2913 \SpecialChar \ldots{}
2918 \SpecialChar \ldots{}
2923 allows to modify the space between columns.
2924 Unfortunately, one cannot type
2925 \begin_inset Quotes eld
2935 \begin_inset Quotes erd
2938 into a formula to get the desired matrix because the @-character is interpreted
2939 by LyX as ending the
2946 But there are two other ways of getting the desired matrix:
2949 \begin_layout Itemize
2951 \begin_inset space \space{}
2960 as normal document text, then either highlight it and press
2966 to get a formula, or copy it into an existing formula.
2967 You can now continue as normal.
2968 \begin_inset Newline newline
2972 \begin_inset Note Greyedout
2975 \begin_layout Plain Layout
2980 This method only works for single spacing settings, so using
2981 \begin_inset Newline newline
2994 xymatrix@M=1pt@C=1dd
2997 The method also don't work if you use '!' to get a fixed grid with a defined
2999 \begin_inset space \space{}
3020 \begin_inset Newline newline
3023 For the following matrix, the command
3030 \begin_inset Formula
3032 \xymatrix@C=9pc{A\ar[r]\ar[d] & B\\
3033 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3042 \begin_layout Itemize
3046 \begin_layout Plain Layout
3056 \begin_inset space ~
3059 stores the values for row-spacing and column-spacing in the variables
3060 \begin_inset Newline newline
3076 So one can add the following macro to the preamble (
3078 Layout\SpecialChar \menuseparator
3079 Document\SpecialChar \menuseparator
3086 \begin_layout LyX-Code
3094 \begin_layout LyX-Code
3099 xymatrixrowsep@{#1}}
3102 \begin_layout Standard
3109 can be defined correspondingly by replacing
3122 Now, a figure can be scaled by entering
3124 xyR{ into the formula before the
3128 \begin_layout Plain Layout
3138 Place the cursor inside the matrix, just before the first entry.
3156 Don't forget the backslashes and remember, that the closing brace is automatica
3157 lly supplied by LyX.
3158 Inside the braces enter the dimensions.
3159 \begin_inset Newline newline
3163 \begin_inset Note Greyedout
3166 \begin_layout Plain Layout
3171 these commands affect all following
3175 \begin_layout Plain Layout
3185 Therefore don't forget to reset the values to default after the usage of
3198 \begin_inset Newline newline
3206 Here you see a diagram which is squashed vertically and stretched horizontally
3216 \begin_inset Formula
3218 \xyR{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
3219 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3226 \begin_inset Formula $\xyR{2pc}\xyC{2pc}$
3230 \begin_inset Note Note
3233 \begin_layout Plain Layout
3243 \begin_layout Subsection
3247 \begin_layout Standard
3252 \begin_layout Plain Layout
3261 -command allows the correct positioning of labels along the shaft of arrows.
3262 This feature is sometimes necessary, when the default position of a label
3263 would otherwise clutter the picture, or would even coincide with other
3264 items, such as the intersection of the arrows in the figure below.
3265 In order to shift a label position alongside the shaft of an arrow,
3269 \begin_layout Plain Layout
3279 \begin_inset space ~
3282 allows to prefix the label by a decimal number in parentheses, specifying
3283 the fraction of distance alongside the arrow where the label is to be placed.
3284 For instance, the code
3292 , will place the label on the shaft, but only about one third of the way.
3296 \begin_layout Standard
3297 Doing the same with labels above or below arrows as
3313 , does not work from inside LyX.
3314 Instead, one has to replace the hat-symbol ^, resp.
3315 the underscore _ , by the macros
3349 It is, in fact, possible to enter several labels this way and those labels
3350 are placed correctly, even if the arrow bends.
3351 In the following figure, the bending arrow with its four labels has been
3375 \begin_layout Standard
3376 \begin_inset Formula
3378 \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}}\\
3379 \circ\ar[ur]\sb(0.3)\phi & \bullet
3388 \begin_layout Subsection
3389 Invisible stretched arrows
3392 \begin_layout Standard
3393 A more general trick uses invisible arrows to place any object almost anywhere
3395 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3396 a decimal stretching ratio, e.
3397 \begin_inset space \thinspace{}
3401 \begin_inset space \space{}
3413 Attach a label to this invisible arrow.
3417 \begin_layout Standard
3418 Thus, the down pointing arrow with its label
3419 \begin_inset Formula $\varphi$
3422 at (0.3) of its way along the shaft might as well have been produced by
3423 adding to the regular arrow
3430 \begin_inset Formula $\varphi$
3441 , reaching only 0.6 of the way.
3442 Its label will now appear at 0.3 of the way of the original visible arrow.
3446 \begin_layout Standard
3447 This workaround has two minor drawbacks: First, it does not work with bending
3449 Secondly, prolonging an invisible arrow beyond the normal dimension of
3450 the figure will invisibly extend the figure box, and thereby cause too
3451 much vertical space between the figure and the preceding or the following
3456 \begin_layout Standard
3457 Nevertheless, invisible arrows are an important tool, since they can, in
3458 principle, be used to place information at any chosen place in a diagram.
3459 In the above figure, for instance, we have used an invisible arrow to carry
3466 as label and at the earlier figure we had used an invisible arrow to carry
3468 \begin_inset Quotes eld
3476 \begin_inset Quotes erd
3479 into the center of the figure.
3482 \begin_layout Subsection
3490 \begin_layout Standard
3491 Here we have focused only on the
3497 command, which is just one of the features available in Kris Rose's amazing
3503 \begin_layout Plain Layout
3521 \begin_layout Plain Layout
3533 \begin_inset CommandInset citation
3539 demonstrates many of the advanced possibilities of that package.
3540 Beware, that its style is rather terse and you will likely need a lot of
3541 experimenting and modifying the many worked examples.
3543 \begin_inset CommandInset citation
3553 \begin_layout Plain Layout
3562 -pic to make braids, cobordism, string diagrams, and much more.
3563 You might want to look on
3567 example shipped with LyX, which demonstrates how to use more advanced
3571 \begin_layout Plain Layout
3583 \begin_inset space ~
3595 \begin_layout Standard
3596 \begin_inset Newpage newpage
3602 \begin_layout Bibliography
3603 \begin_inset CommandInset bibitem
3604 LatexCommand bibitem
3614 \begin_layout Plain Layout
3628 \begin_inset Newline newline
3632 \begin_inset Flex URL
3635 \begin_layout Plain Layout
3637 http://mirrors.ctan.org/macros/generic/diagrams/xypic/xy/doc/xyguide.pdf
3645 \begin_layout Bibliography
3646 \begin_inset CommandInset bibitem
3647 LatexCommand bibitem
3648 key "xypic reference"
3653 Rose and Ross Moore:
3657 \begin_layout Plain Layout
3668 -pic Reference Manual
3671 \begin_inset Newline newline
3675 \begin_inset Flex URL
3678 \begin_layout Plain Layout
3680 http://mirrors.ctan.org/macros/generic/diagrams/xypic/xy/doc/xyrefer.pdf
3688 \begin_layout Bibliography
3689 \begin_inset CommandInset bibitem
3690 LatexCommand bibitem
3695 Homepage of the package
3699 \begin_layout Plain Layout
3713 \begin_inset Flex URL
3716 \begin_layout Plain Layout
3718 http://www.ctan.org/pkg/xypic
3726 \begin_layout Bibliography
3727 \begin_inset CommandInset bibitem
3728 LatexCommand bibitem
3729 key "instant-preview"
3733 Homepage of preview-latex:
3734 \begin_inset Newline newline
3738 \begin_inset Flex URL
3741 \begin_layout Plain Layout
3743 http://www.gnu.org/software/auctex/preview-latex.html
3751 \begin_layout Bibliography
3752 \begin_inset CommandInset bibitem
3753 LatexCommand bibitem
3759 \begin_inset Flex URL
3762 \begin_layout Plain Layout
3764 http://www.gnu.org/software/auctex/
3772 \begin_layout Bibliography
3773 \begin_inset CommandInset bibitem
3774 LatexCommand bibitem
3783 \begin_layout Plain Layout
3798 tutorial with an archive of examples
3801 \begin_inset Newline newline
3805 \begin_inset Flex URL
3808 \begin_layout Plain Layout
3810 http://www.math.columbia.edu/~lauda/xy/