1 #LyX 2.0.0svn created this file. For more info see http://www.lyx.org/
9 % define new commands used in sec. 5.1
11 \xydef@\xymatrixrowsep@{#1}}
13 \xydef@\xymatrixcolsep@{#1}}
15 \newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
17 % a pdf-bookmark for the TOC is added
18 \let\myTOC\tableofcontents
19 \renewcommand\tableofcontents{%
20 \pdfbookmark[1]{\contentsname}{}
23 % redefine the \LyX macro for PDF bookmarks
24 \def\LyX{\texorpdfstring{%
25 L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}
29 \use_default_options false
30 \maintain_unincluded_children false
36 \font_typewriter default
37 \font_default_family default
45 \default_output_format default
46 \bibtex_command default
47 \index_command default
51 \pdf_title "Using XY-pc in LyX"
52 \pdf_author "H. Peter Gumm"
53 \pdf_subject "LyX's XY-pic manual"
54 \pdf_keywords "LyX, documentation"
56 \pdf_bookmarksnumbered true
57 \pdf_bookmarksopen true
58 \pdf_bookmarksopenlevel 2
63 \pdf_pdfusetitle false
64 \pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue,pdfpagelayout=OneColumn, pdfnewwindow=true,pdfstartview=XYZ, plainpages=false, pdfpagelabels"
73 \paperorientation portrait
81 \paragraph_separation indent
82 \paragraph_indentation default
83 \quotes_language english
86 \paperpagestyle default
87 \tracking_changes false
100 \begin_layout Plain Layout
117 \begin_layout Abstract
118 With the recent versions of LyX and with the
122 -style installed in the LaTeX-System, the graph drawing package
128 \begin_layout Plain Layout
139 -pic can be conveniently used inside LyX.
140 Diagrams can be edited and displayed inside the main LyX editing window.
141 Here, we shall describe how to use the
151 inside LyX in order to draw, to edit and to preview diagrams as typically
152 used in category theory, algebra, and related fields.
156 \begin_layout Abstract
157 \begin_inset CommandInset toc
158 LatexCommand tableofcontents
165 \begin_layout Section
169 \begin_layout Standard
174 -package has long served as a convenient tool for easily constructing graphs
175 and diagrams in LaTeX.
176 Unfortunately, its use in LyX had long been restricted to the infamous
177 TeX code boxes, meaning that the LyX editor could only display the LaTeX-source
178 and not the finished diagram.
183 -style of LaTeX which is part of the AUCTeX project
184 \begin_inset CommandInset citation
190 , finally enables the editing and displaying of
194 -diagrams, constructed, displayed and interactively edited inside LyX.
197 \begin_layout Standard
198 \begin_inset VSpace defskip
204 \begin_layout Standard
206 \begin_inset Graphics
207 filename xyfigure.png
209 BoundingBox 0bp 0bp 580bp 440bp
217 \begin_layout Standard
218 \begin_inset VSpace defskip
224 \begin_layout Standard
225 In this note, we describe how
229 \begin_layout Plain Layout
238 -pic can be used from inside LyX, how diagrams can be created and edited.
239 We have tested the following using LyX versions 1.3.7 up to 1.6, running under
241 \begin_inset space \thinspace{}
244 XP and under Windows Vista.
248 \begin_layout Standard
249 There are two modes of operations: For a start, and for some first tests,
250 it may be easiest to first enter the
254 \begin_layout Plain Layout
263 -pic code inside the LyX-window, select it all and convert it to a graphical
264 representation by pressing
277 \begin_layout Plain Layout
286 -pic more frequently, or if you want to modify your initial figure, you
287 will want to assemble and modify your figures using LyX's math editor.
291 \begin_layout Standard
292 Once the cursor is moved over a diagram, this is displayed as an array of
293 nodes and arrow-commands.
294 These can be changed interactively.
295 When the cursor leaves the editing area, the diagram reappears.
299 \begin_layout Standard
300 In the first two sections of this documentation, we explain how to use LyX
301 in the first mentioned mode and we introduce all
305 \begin_layout Plain Layout
314 -pic features that might be of use for drawing commutative diagrams, graphs
317 \begin_inset CommandInset ref
319 reference "sec:math-editor"
323 explains how to use the
327 \begin_layout Plain Layout
336 -pic commands inside a math-editing area.
340 \begin_layout Standard
341 It is not our intention to write another introduction to
345 \begin_layout Plain Layout
354 -pic, rather our motivation is to give an introduction how the most important
355 commands work inside LyX, since the keystrokes as explained in the
359 \begin_layout Plain Layout
369 \begin_inset CommandInset citation
375 will not always function correctly inside LyX.
379 \begin_layout Section
383 \begin_layout Standard
384 The following requires that the LaTeX-packages
392 are installed in the LaTeX system.
393 They are available from CTAN, see at
394 \begin_inset CommandInset citation
396 key "instant-preview"
402 \begin_inset CommandInset citation
409 After freshly installing them, it may be necessary, to run
411 Tools\SpecialChar \menuseparator
414 from the main LyX menu.
415 The steps to a first diagram output in LyX are then:
418 \begin_layout Enumerate
425 \begin_layout Enumerate
428 Tools\SpecialChar \menuseparator
429 Preferences\SpecialChar \menuseparator
430 Look and Feel\SpecialChar \menuseparator
440 \begin_layout Enumerate
443 Document\SpecialChar \menuseparator
444 Settings\SpecialChar \menuseparator
453 Use AMS Math package automatically
462 \begin_layout Enumerate
467 works by opening a LyX-document and entering any math-formula, e.
468 \begin_inset space \thinspace{}
473 \begin_inset Formula $a+b=c$
480 \begin_layout Enumerate
481 Move the cursor out of the formula, and watch it change its appearance to
482 look just like in the finished DVI- or PostScript document.
487 \begin_layout Enumerate
492 \begin_layout Plain Layout
507 \begin_layout Enumerate
508 Inside your LyX-Document, enter the text
511 \begin_inset Newline newline
523 \begin_layout Enumerate
524 Select the whole text and choose
526 Insert\SpecialChar \menuseparator
527 Math\SpecialChar \menuseparator
530 , or use the corresponding keyboard shortcut
538 \begin_layout Enumerate
539 Move the mouse cursor out of the editing box and wait for a split second
540 to see an arrow appear:
541 \begin_inset Formula $\xymatrix{A\ar[r] & B}
549 \begin_layout Section
553 \begin_layout Standard
554 The following diagram, which is taken from the documentation of
558 \begin_layout Plain Layout
568 \begin_inset CommandInset citation
574 by its creator Kristoffer H.
575 Rose, will provide an example for many of the features available with that
580 \begin_layout LyX-Code
584 \begin_inset Newline newline
596 \begin_inset Newline newline
606 \begin_inset Newline newline
622 \begin_inset Newline newline
630 \begin_layout LyX-Code
634 \begin_layout Standard
635 Again, to turn this code into a graphical output, select it all at once
642 \SpecialChar \ldots{}
643 up to the closing brace \SpecialChar \ldots{}
648 and turn it into display-math as explained above.
649 A moment after the cursor leaves the math-area, you should see the diagram
650 in its full graphical glory as shown below.
654 \begin_layout Standard
655 \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\
656 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
665 \begin_layout Subsection
666 The matrix layout of diagrams
669 \begin_layout Standard
674 uses a matrix to define the layout of the vertices of a diagram.
675 For the above example, we need a
676 \begin_inset Formula $3\times3$
679 -matrix of which 5 entries are used for the vertices
680 \begin_inset Formula $U$
684 \begin_inset Formula $X\times_{Z}Y$
688 \begin_inset Formula $X$
692 \begin_inset Formula $Y$
696 \begin_inset Formula $Z$
699 , the other positions remaining empty.
700 In this case, the following matrix determines the layout:
703 \begin_layout LyX-Code
707 \begin_inset Newline newline
715 \begin_inset Newline newline
725 \begin_inset Newline newline
731 \begin_layout Standard
732 The pattern should be familiar from LaTeX: We see three rows, the first
733 two being terminated by the end-of-line-marker
742 Each line consists of entries, separated by the ampersand
750 \begin_layout Subsection
754 \begin_layout Standard
755 Having entered the vertices, we add arrows between them.
760 -command to produce an arrow is
766 , it is entered into the cell of the matrix where the arrow is to start.
767 The target of the arrow is defined by direction commands
784 These can be combined to a path and enclosed in square brackets.
785 As an example, the arrows from the vertex
786 \begin_inset Formula $U$
789 in the upper left corner down and right to the vertices
790 \begin_inset Formula $X\times_{Z}Y$
794 \begin_inset Formula $Y$
798 \begin_inset Formula $X$
801 are, respectively, defined as
820 Thus the above diagram with all arrows added becomes:
823 \begin_layout LyX-Code
827 \begin_inset Newline newline
841 \begin_inset Newline newline
857 \begin_inset Newline newline
865 \begin_layout Standard
866 \begin_inset Formula \xymatrix{ U \ar[ddr] \ar[drr] \ar[dr]\\
867 & X \times_{Z} Y \ar[d] \ar[r] & X \ar[d]\\
877 \begin_layout LyX-Code
881 \begin_layout LyX-Code
885 \begin_layout Subsection
889 \begin_layout Standard
890 Labels are attached to arrows by affixing them as upper or lower indices
906 defines an arrow going one cell down, two to the right and having the label
908 \begin_inset Formula $\varphi$
912 To attach a label below the arrow, make it a lower index as in
921 This explanation is correct only for arrows pointing to the right.
922 More precisely, imagine looking along the arrow in the direction it is
924 Then an upper index places a label to the left and a lower index places
926 Consequently, an arrow pointing from right to left, such as
937 \begin_inset Formula $\alpha$
941 \begin_inset Formula $\beta$
945 \begin_inset space \thinspace{}
949 \begin_inset space \space{}
953 \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.}
957 Using the character | instead of ^ or _ , it is even possible to place the
958 label right onto the arrow, obscuring part of its shaft.
962 \begin_layout Standard
963 Normally, a label is placed halfway between an arrow's start and target
965 In the first diagram, the central arrow starting in
966 \begin_inset Formula $U$
970 \begin_inset Formula $(x,y)$
973 in the middle of the arrow's shaft, rather than in the middle between the
974 two objects it connects.
975 This is achieved by prefixing the label with a minus sign, here:
984 \begin_layout LyX-Code
988 \begin_inset Newline newline
1006 \begin_inset Newline newline
1022 \begin_inset Newline newline
1030 \begin_layout LyX-Code
1031 \begin_inset Formula \xymatrix{ U \ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\
1032 & X \times_{Z} Y \ar[d]^{q} \ar[r]_{p} & X \ar[d]_{f}\\
1042 \begin_layout Standard
1046 \begin_layout Plain Layout
1055 -pic normally permits labels to be shifted towards the tip or towards the
1056 start of an arrow by prefixing the label with a ratio, such as e.
1057 \begin_inset space \thinspace{}
1066 In LyX this works only for labels which are placed on top of the arrow,
1079 \begin_layout Standard
1080 For labels placed to the left or to the right of the arrow this does not
1086 \begin_layout Plain Layout
1095 -pic code such as e.
1096 \begin_inset space \thinspace{}
1116 is not correctly interpreted by LyX's math editor.
1117 Two workarounds are suggested in the last section of this note.
1120 \begin_layout Subsection
1124 \begin_layout Standard
1125 Modification of the design, the form or the positioning of arrows are introduced
1131 This is followed by a pair of matching brackets, where the form of the
1144 indicates, whether we want to modify the design, the or the curvature of
1146 Various modifications can be applied to an arrow at the same time.
1149 \begin_layout Subsubsection
1153 \begin_layout Standard
1154 Various designs such as
1170 are possible for the shaft of an arrow.
1171 These can be combined with various ends and various tips.
1172 In general, the design of an arrow is described by following the command
1183 -sign and a pair of braces {\SpecialChar \ldots{}
1184 } containing characters describing the end,
1185 the shaft and the tip of the arrow.
1186 These characters are chosen to give some form of ASCII-rendering of the
1194 produces an arrow with split end, a dotted shaft and double head.
1195 A number of other arrow designs is given in the table below.
1196 Note that the ends of embedding arrows
1197 \begin_inset Formula $\xymatrix{A\ar@{^{(}->}[r] & B}
1201 are described by raising or lowering opening parentheses, such as in
1206 \begin_inset Newline newline
1212 \begin_layout Standard
1213 \begin_inset Tabular
1214 <lyxtabular version="3" rows="11" columns="2">
1215 <features islongtable="true" longtabularalignment="center">
1216 <column alignment="center" valignment="top" width="0">
1217 <column alignment="center" valignment="top" width="0">
1219 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1222 \begin_layout Plain Layout
1228 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1231 \begin_layout Plain Layout
1239 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1242 \begin_layout Plain Layout
1243 \begin_inset Formula \xymatrix{\ \ar[r] & \ }
1253 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1256 \begin_layout Plain Layout
1268 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1271 \begin_layout Plain Layout
1272 \begin_inset Formula \xymatrix{\ \ar@{-->}[r] & \ }
1282 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1285 \begin_layout Plain Layout
1297 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1300 \begin_layout Plain Layout
1301 \begin_inset Formula \xymatrix{\ \ar@{..>}[r] & \ }
1311 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1314 \begin_layout Plain Layout
1326 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1329 \begin_layout Plain Layout
1330 \begin_inset Formula \xymatrix{\ \ar@{~>}[r] & \ }
1340 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1343 \begin_layout Plain Layout
1355 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1358 \begin_layout Plain Layout
1359 \begin_inset Formula \xymatrix{\ \ar@{->>}[r] & \ }
1369 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1372 \begin_layout Plain Layout
1384 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1387 \begin_layout Plain Layout
1388 \begin_inset Formula \xymatrix{\ \ar@{-->>}[r] & \ }
1398 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1401 \begin_layout Plain Layout
1413 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1416 \begin_layout Plain Layout
1417 \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] & \ }
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] & \ }
1485 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1488 \begin_layout Plain Layout
1500 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1503 \begin_layout Plain Layout
1504 \begin_inset Formula \xymatrix{\ \ar@{|-|}[r] & \ }
1514 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1517 \begin_layout Plain Layout
1535 \begin_layout Standard
1537 Following the @-character by either a 2, 3, _,or a ^, we can produce arrows
1538 with double, triple shaft or arrows showing only the lower or upper half
1539 of their tips and ends.
1540 Arrows need not have tips nor ends, as the last example shows :
1541 \begin_inset Newline newline
1547 \begin_layout Standard
1548 \begin_inset Tabular
1549 <lyxtabular version="3" rows="8" columns="2">
1550 <features islongtable="true" longtabularalignment="center">
1551 <column alignment="center" valignment="top" width="0">
1552 <column alignment="center" valignment="top" width="0">
1554 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1557 \begin_layout Plain Layout
1563 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1566 \begin_layout Plain Layout
1574 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1577 \begin_layout Plain Layout
1578 \begin_inset Formula \xymatrix{\ \ar@2[r] & \ }
1588 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1591 \begin_layout Plain Layout
1603 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1606 \begin_layout Plain Layout
1607 \begin_inset Formula \xymatrix{\ \ar@3[r] & \ }
1617 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1620 \begin_layout Plain Layout
1632 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1635 \begin_layout Plain Layout
1636 \begin_inset Formula \xymatrix{\ \ar@_{->}[r] & \ }
1646 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1649 \begin_layout Plain Layout
1661 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1664 \begin_layout Plain Layout
1665 \begin_inset Formula \xymatrix{\ \ar@^{->}[r] & \ }
1675 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1678 \begin_layout Plain Layout
1690 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1693 \begin_layout Plain Layout
1694 \begin_inset Formula \xymatrix{\ \ar@^{>>->>}[r] & \ }
1704 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1707 \begin_layout Plain Layout
1719 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1722 \begin_layout Plain Layout
1723 \begin_inset Formula \xymatrix{\ \ar@{^{<}-_{>}}[r] & \ }
1733 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1736 \begin_layout Plain Layout
1748 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1751 \begin_layout Plain Layout
1752 \begin_inset Formula \xymatrix{\ \ar@2{--}[r] & \ }
1762 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1765 \begin_layout Plain Layout
1783 \begin_layout Subsubsection
1784 Designing your own arrows
1787 \begin_layout Standard
1788 Within certain limits there is even a way to design your own arrows.
1789 Using some the characters
1793 one can even design one's own arrow tips using the
1799 command in the preamble.
1800 For explanations, we refer to the
1806 \begin_layout Plain Layout
1817 -manual, from which we take the example:
1820 \begin_layout Standard
1825 newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
1830 \begin_layout Standard
1832 This defines a new arrow tip, referred to as
1842 and which displays correctly in LyX as:
1843 \begin_inset Formula \[
1844 \xymatrix{A\ar@{-|>}[r] & \ \ B}
1852 \begin_layout Subsection
1856 \begin_layout Standard
1857 Arrows are shifted sideways with the modifier
1862 \begin_inset Formula $\ldots$
1869 where the ellipsis is replaced by a positive or negative measure.
1870 For instance, to design a pair of mutually opposing arrows between two
1871 nodes, we shift them to see them apart.
1872 Note that the direction of the shift (positive) is to the left if one looks
1877 \begin_layout Standard
1893 \begin_layout Standard
1896 \begin_inset space ~
1900 \begin_inset space ~
1904 \begin_inset Formula \[
1905 \xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1914 \begin_layout Subsubsection
1915 Inline or centered diagrams
1918 \begin_layout Standard
1919 Arrows and diagrams can be used inline, such as this one:
1920 \begin_inset Formula $\xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1925 When their code is written inside LyX as above, select it and choose either
1930 for inline appearance or
1935 Diagrams constructed inline can later be centered, or, conversely, centered
1936 diagrams can be changed to inline formulas with
1938 Edit\SpecialChar \menuseparator
1943 \SpecialChar \menuseparator
1944 Change Formula Type.
1947 \begin_layout Subsection
1951 \begin_layout Standard
1952 There are two simple methods to make arrows bend.
1953 The first is giving an explicit value by which the midpoint of the arrow's
1954 shaft is raised or depressed, the other is by forcing the arrow to leave
1955 its origin in a prescribed compass direction and to make him enter the
1956 target at another direction.
1957 The necessary bending of the arrow is determined automatically.
1958 We describe both methods.
1961 \begin_layout Subsubsection
1965 \begin_layout Standard
1966 For bending arrows we use the modifier @/
1967 \begin_inset Formula $\ldots$
1971 The ellipsis stands for a TeX-measure which needs to be entered as a lower
1977 , we could simply write, e.
1978 \begin_inset space \thinspace{}
1988 for an arrow bending
1992 downwards, this cannot directly be done in LyX.
1993 It is necessary, to enclose the measure in a pair of braces, such as e.
1994 \begin_inset space \thinspace{}
2005 As an example, here are two opposing arrows between
2006 \begin_inset Formula $A$
2010 \begin_inset Formula $B$
2013 , each bending by .5 pica, given by the following source code:
2016 \begin_layout Standard
2028 \begin_layout Standard
2029 \begin_inset Formula \[
2030 \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]}
2038 \begin_layout Subsubsection
2039 Specifying exit- and entrance directions
2042 \begin_layout Standard
2043 An alternative for making arrows bend is by specifying their compass direction
2044 as they are leaving their source and their direction from which they enter
2046 Instead of north, north-east, east, etc., the directions are named
2078 , standing for up, up-right, right, down-right, etc..
2079 A direction is specified as @(
2091 stands for the direction the first object is left and
2095 stands for the direction from which the target is entered.
2096 As an example, we show some bending arrows and a loop, which arises when
2097 we do not specify a target for an arrow, just its incoming and outgoing
2101 \begin_layout Standard
2102 \begin_inset Formula \[
2103 \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\
2113 \begin_layout LyX-Code
2121 \begin_inset Newline newline
2131 \begin_inset Newline newline
2139 \begin_layout Subsection
2143 \begin_layout Standard
2144 The above example is reminiscent of an automata diagram, except that in
2145 such a diagram states would be enclosed in small circles, with double circles
2146 denoting final states.
2150 \begin_layout Subsubsection
2154 \begin_layout Standard
2159 \begin_layout Plain Layout
2168 -pic, entries can obtain a single or a double frame, such as
2169 \begin_inset Formula $\xymatrix{*+[F]{A}}
2174 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2178 by prefixing an entry with
2186 and enclosing the portion of the entry to be framed in braces.
2187 Normally, the frame will be very tight so that it must be widened by prefixing
2197 Round frames, such as
2198 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2203 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2207 are obtained by specifying the shape as
2212 So the latter figure was constructed as *++[o][F=]{B}.
2213 This way, the following automaton
2216 \begin_layout Standard
2217 \begin_inset Formula \[
2218 \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]}
2226 \begin_layout Standard
2231 \begin_layout LyX-Code
2241 \begin_layout LyX-Code
2247 \begin_layout LyX-Code
2255 \begin_layout LyX-Code
2259 \begin_layout Standard
2266 \SpecialChar \ldots{}
2271 will make a certain entry style the default, that can, of course be overridden
2272 for individual entries.
2277 entrymodifiers={++[o][F-]}
2279 , all following entries inside
2283 \begin_layout Plain Layout
2292 -matrices would be encircled.
2295 \begin_layout Subsubsection
2299 \begin_layout Standard
2300 Framing a whole rectangle inside an xymatrix is done with the macro pair
2320 The dimension of the rectangle is given as a dotted pair
2321 \begin_inset Formula $P_{0}.P_{1}$
2324 of points denoting the top left and lower right corners of the rectangle.
2325 Each point, in turn,is given as a doubly quoted comma separated pair
2326 \begin_inset Quotes eld
2330 \begin_inset Formula $x,y$
2334 \begin_inset Quotes erd
2338 \begin_inset Formula $x$
2342 \begin_inset Formula $y$
2346 These are followed by the framing commands, to produce figures such as
2348 \begin_inset Formula \[
2349 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2350 C & \save"1,1"."1,2"*++[F]\frm{}\restore
2367 save"1,1"."2,1"*+[F=]
2380 produces the doubly framed rectangle, and the code for the extra wide horizonta
2392 save"1,1"."1,2"*++[F]
2406 This code can be placed in arbitrary cells of the xymatrix.
2410 \begin_layout Section
2411 Using LyX's math editor
2412 \begin_inset CommandInset label
2414 name "sec:math-editor"
2421 \begin_layout Standard
2422 As an alternative to writing the
2426 code, then transforming it into a math-editing environment by marking it
2435 , one may construct and modify the whole xypic-diagram inside LyX's math
2437 We describe the editing steps for a figure just like the one above.
2441 \begin_layout Subsection
2442 Caveat - how to enter braces
2445 \begin_layout Standard
2446 Recall that in LyX's math-editor any pair of braces
2454 that are to enclose a macro-parameter must be entered by typing just
2461 The closing brace is automatically supplied and in between a box into which
2462 to the parameter is entered.
2467 \begin_layout Plain Layout
2476 -diagrams, this applies in particular to arrow modifications that are normally
2481 \SpecialChar \ldots{}
2486 with the ellipsis standing for the description of end, shaft and tip of
2488 Inside the math-editor, enter just
2494 and let LyX provide the closing brace and the box into which to enter the
2495 description of the arrow.
2498 \begin_layout Standard
2499 Braces that are entered without the backslash
2505 will just appear as typed, but cannot be used to receive a macro parameter.
2506 They are useful, for instance to denote sets, e.
2507 \begin_inset space \thinspace{}
2522 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2528 \begin_layout Subsection
2529 Setting up the matrix
2532 \begin_layout Standard
2541 open a formula environment and enter:
2549 \begin_inset Formula $\times$
2556 \begin_layout Plain Layout
2566 Add extra rows by typing
2570 and add columns by typing
2576 \begin_layout Standard
2577 At any time, further rows or columns can be entered or deleted using commands
2580 Edit\SpecialChar \menuseparator
2584 their shortcuts, beginning with
2588 for the column commands or
2592 for the row commands.
2593 A more direct way uses the icons in the math toolbar once it has been activated
2596 View\SpecialChar \menuseparator
2600 \begin_layout Subsection
2601 Entering nodes, arrows and labels
2604 \begin_layout Standard
2605 Type the nodes into the correct positions of the matrix.
2606 If you move the cursor out of the matrix, you should see a first rendering
2608 Next, add the arrows at the nodes from where they should emanate by typing
2625 can be any path made up from the characters
2642 Make sure that the path indeed leads to an existing node within the matrix.
2643 Otherwise, the figure will not display when the cursor leaves the editing
2647 \begin_layout Standard
2648 Next, label the arrows by attaching a label text as upper or lower indices
2649 to the end of the arrow's path.
2650 As always in LyX's math editor, an underscore
2654 opens a box for a lower index and a
2658 followed by a space opens a box for an upper index.
2659 You can enter any LaTeX-code as a label.
2662 \begin_layout Subsection
2666 \begin_layout Standard
2667 Finally, you can modify the appearance of the arrows by entering @-modifiers
2672 \SpecialChar \ldots{}
2681 \SpecialChar \ldots{}
2686 \SpecialChar \ldots{}
2687 ,\SpecialChar \ldots{}
2692 \SpecialChar \ldots{}
2698 The above caveat applies to the first form only.
2699 It must be entered as
2705 with the arrow description entered inside the LyX-supplied box.
2706 If this box remains empty, you have specified an empty arrow.
2707 This is a useful construction, too, as you will see in the next section.
2711 \begin_layout Standard
2712 The other modifiers,
2716 \SpecialChar \ldots{}
2725 \SpecialChar \ldots{}
2726 ,\SpecialChar \ldots{}
2735 \SpecialChar \ldots{}
2740 are typed as shown with the arrow description replacing the ellipsis.
2741 The code for bending arrows, which in
2770 is any valid TeX-measure that should be entered as upper or lower index
2771 to the first slash /.
2772 Make sure that the ending slash does not end up being part of the upper
2776 \begin_layout Subsection
2777 What if something goes wrong
2780 \begin_layout Standard
2781 When constructing a diagram, you should at times check it by just moving
2782 the cursor out of the editing area to see whether instant preview can successfu
2783 lly convert it into graphical output.
2784 If this does not happen, it may either be that instant preview for some
2785 reason is not aware that it should retranslate the graphics.
2786 Moving the cursor into the editing area and out again sometimes wakes up
2790 \begin_layout Standard
2791 A more serious reason could be a syntactical error in your input (in that
2792 case, the math edition area disappears completely).
2793 If necessary, undo the last editing steps, using
2797 , or try to translate the LyX-file into
2807 View\SpecialChar \menuseparator
2811 There should be some error generated, which hopefully gives you a hint
2812 as to the source of the mistake.
2815 \begin_layout Section
2819 \begin_layout Standard
2820 Certain things do not work correctly inside LyX.
2821 The ones that we (used to) miss most are the horizontal and vertical scaling
2822 of diagrams, and the correct positioning of arrows.
2823 There are some workarounds that we are explaining here.
2827 \begin_layout Subsection
2828 Horizontal and vertical scaling
2831 \begin_layout Standard
2832 It is often convenient to stretch the horizontal or the vertical dimensions
2833 of an entire diagram by using spacing commands for rows and/or columns.
2838 \begin_layout Plain Layout
2847 -manual, for instance,
2853 \SpecialChar \ldots{}
2862 \begin_layout Plain Layout
2871 -matrix with row spacing of 1 pica.
2878 \SpecialChar \ldots{}
2883 \SpecialChar \ldots{}
2888 allows to modify the space between columns.
2889 Unfortunately, these commands do currently not work inside LyX, as the
2890 @-character is interpreted by LyX as ending the
2894 \begin_layout Plain Layout
2907 \begin_layout Standard
2912 \begin_layout Plain Layout
2922 \begin_inset space ~
2925 stores the values for row-spacing and column-spacing in the variables
2937 , add the following macro to the preamble (
2939 Layout\SpecialChar \menuseparator
2940 Document\SpecialChar \menuseparator
2944 \begin_inset Newpage pagebreak
2950 \begin_layout LyX-Code
2958 \begin_layout LyX-Code
2963 xymatrixrowsep@{#1}}
2966 \begin_layout LyX-Code
2970 \begin_layout Standard
2977 can be defined correspondingly by replacing
2990 Now, a figure can be scaled by entering
2996 \begin_layout Plain Layout
3006 Place the cursor inside the matrix, just before the first entry.
3024 Don't forget the backslashes and remember, that the closing brace is automatica
3025 lly supplied by LyX.
3026 Inside the braces enter the dimensions.
3032 Here you see a diagram which is squashed vertically and stretched horizontally
3044 \begin_layout Standard
3045 \begin_inset Formula \[
3046 \xyC{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
3047 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3056 \begin_layout Subsection
3060 \begin_layout Standard
3065 \begin_layout Plain Layout
3074 -command allows the correct positioning of labels along the shaft of arrows.
3075 This feature is sometimes necessary, when the default position of a label
3076 would otherwise clutter the picture, or would even coincide with other
3077 items, such as the intersection of the arrows in the figure below.
3078 In order to shift a label position alongside the shaft of an arrow,
3082 \begin_layout Plain Layout
3092 \begin_inset space ~
3095 allows to prefix the label by a decimal number in parentheses, specifying
3096 the fraction of distance alongside the arrow where the label is to be placed.
3097 For instance, the code
3105 , will place the label on the shaft, but only about one third of the way.
3109 \begin_layout Standard
3110 Doing the same with labels above or below arrows as
3126 , does not work from inside LyX.
3127 Instead, one has to replace the hat-symbol ^, resp.
3128 the underscore _ , by the macros
3162 It is, in fact, possible to enter several labels this way and those labels
3163 are placed correctly, even if the arrow bends.
3164 In the following figure, the bending arrow with its four labels has been
3188 \begin_layout Standard
3189 \begin_inset Formula \[
3190 \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}}\\
3191 \circ\ar[ur]\sb(0.3)\phi & \bullet
3200 \begin_layout Subsection
3201 Invisible stretched arrows
3204 \begin_layout Standard
3205 A more general trick uses invisible arrows to place any object almost anywhere
3207 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3208 a decimal stretching ratio, e.
3209 \begin_inset space \thinspace{}
3222 Attach a label to this invisible arrow.
3226 \begin_layout Standard
3227 Thus, the down pointing arrow with its label
3228 \begin_inset Formula $\varphi$
3231 at (0.3) of its way along the shaft might as well have been produced by
3232 adding to the regular arrow
3239 \begin_inset Formula $\varphi$
3250 , reaching only 0.6 of the way.
3251 Its label will now appear at 0.3 of the way of the original visible arrow.
3255 \begin_layout Standard
3256 This workaround has two minor drawbacks: First, it does not work with bending
3258 Secondly, prolonging an invisible arrow beyond the normal dimension of
3259 the figure will invisibly extend the figure box, and thereby cause too
3260 much vertical space between the figure and the preceding or the following
3265 \begin_layout Standard
3266 Nevertheless, invisible arrows are an important tool, since they can, in
3267 principle, be used to place information at any chosen place in a diagram.
3268 In the above figure, for instance, we have used an invisible arrow to carry
3275 as label and at the earlier figure we had used an invisible arrow to carry
3277 \begin_inset Quotes eld
3285 \begin_inset Quotes erd
3288 into the center of the figure.
3291 \begin_layout Subsection
3298 \begin_layout Plain Layout
3312 \begin_layout Standard
3313 Here we have focused only on the
3319 command, which is just one of the features available in Kris Rose's amazing
3325 \begin_layout Plain Layout
3343 \begin_layout Plain Layout
3355 \begin_inset CommandInset citation
3361 demonstrates many of the advanced possibilities of that package.
3362 Beware, that its style is rather terse and you will likely need a lot of
3363 experimenting and modifying the many worked examples.
3365 \begin_inset CommandInset citation
3375 \begin_layout Plain Layout
3384 -pic to make braids, cobordism, string diagrams, and much more.
3385 You might want to look on
3389 example shipped with LyX, which demonstrates how to use more advanced
3393 \begin_layout Plain Layout
3411 A good and rather systematic introduction to
3417 \begin_layout Plain Layout
3429 \begin_inset CommandInset citation
3436 Even if you share with me the disadvantage of not being fluent in Esperanto,
3437 you will be able to understand most of it.
3441 \begin_layout Bibliography
3442 \labelwidthstring References
3443 \begin_inset CommandInset bibitem
3444 LatexCommand bibitem
3455 \begin_layout Plain Layout
3471 Available as part of the
3479 \begin_layout Bibliography
3480 \labelwidthstring References
3481 \begin_inset CommandInset bibitem
3482 LatexCommand bibitem
3484 key "instant-preview"
3489 \begin_inset Flex URL
3492 \begin_layout Plain Layout
3494 http://www.tug.org/tex-archive/help/Catalogue/entries/preview-latex.html
3502 \begin_layout Bibliography
3503 \labelwidthstring References
3504 \begin_inset CommandInset bibitem
3505 LatexCommand bibitem
3512 \begin_inset Flex URL
3515 \begin_layout Plain Layout
3517 http://www.tug.org/tex-archive/help/Catalogue/entries/xypic.html
3525 \begin_layout Bibliography
3526 \labelwidthstring References
3527 \begin_inset CommandInset bibitem
3528 LatexCommand bibitem
3535 \begin_inset Flex URL
3538 \begin_layout Plain Layout
3540 http://www.gnu.org/software/auctex/
3548 \begin_layout Bibliography
3549 \labelwidthstring References
3550 \begin_inset CommandInset bibitem
3551 LatexCommand bibitem
3561 \begin_layout Plain Layout
3576 tutorial with an archive of examples
3579 \begin_inset Flex URL
3582 \begin_layout Plain Layout
3584 http://www.math.columbia.edu/~lauda/xy/
3592 \begin_layout Bibliography
3593 \labelwidthstring References
3594 \begin_inset CommandInset bibitem
3595 LatexCommand bibitem
3605 \begin_layout Plain Layout
3620 Enkonduko pri Xymatrix
3624 \begin_inset Flex URL
3627 \begin_layout Plain Layout
3629 http://filip.ouvaton.org/xypic/xymatrix/index.html