1 #LyX 1.6.5svn created this file. For more info see http://www.lyx.org/
10 % define new commands used in sec. 5.1
12 \xydef@\xymatrixrowsep@{#1}}
14 \xydef@\xymatrixcolsep@{#1}}
16 \newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
18 % a pdf-bookmark for the TOC is added
19 \let\myTOC\tableofcontents
20 \renewcommand\tableofcontents{%
21 \pdfbookmark[1]{\contentsname}{}
24 % redefine the \LyX macro for PDF bookmarks
25 \def\LyX{\texorpdfstring{%
26 L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}
30 \use_default_options false
35 \font_typewriter default
36 \font_default_family default
46 \pdf_title "Using XY-pc in LyX"
47 \pdf_author "H. Peter Gumm"
48 \pdf_subject "LyX's XY-pic manual"
49 \pdf_keywords "LyX, documentation"
51 \pdf_bookmarksnumbered true
52 \pdf_bookmarksopen true
53 \pdf_bookmarksopenlevel 2
58 \pdf_pdfusetitle false
59 \pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue,pdfpagelayout=OneColumn, pdfnewwindow=true,pdfstartview=XYZ, plainpages=false, pdfpagelabels"
66 \paperorientation portrait
69 \paragraph_separation indent
71 \quotes_language english
74 \paperpagestyle default
75 \tracking_changes false
88 \begin_layout Plain Layout
105 \begin_layout Abstract
106 With the recent versions of LyX and with the
110 -style installed in the LaTeX-System, the graph drawing package
116 \begin_layout Plain Layout
127 -Pic can be conveniently used inside LyX.
128 Diagrams can be edited and displayed inside the main LyX editing window.
129 Here, we shall describe how to use the
139 inside LyX in order to draw, to edit and to preview diagrams as typically
140 used in category theory, algebra, and related fields.
144 \begin_layout Abstract
145 \begin_inset CommandInset toc
146 LatexCommand tableofcontents
153 \begin_layout Section
157 \begin_layout Standard
162 -package has long served as a convenient tool for easily constructing graphs
163 and diagrams in LaTeX.
164 Unfortunately, its use in LyX had long been restricted to the infamous
165 TeX code boxes, meaning that the LyX editor could only display the LaTeX-source
166 and not the finished diagram.
171 -style of LaTeX which is part of the AUCTeX project
172 \begin_inset CommandInset citation
178 , finally enables the editing and displaying of
182 -diagrams, constructed, displayed and interactively edited inside LyX.
185 \begin_layout Standard
186 \begin_inset VSpace defskip
192 \begin_layout Standard
194 \begin_inset Graphics
195 filename xyfigure.png
197 BoundingBox 0bp 0bp 580bp 440bp
205 \begin_layout Standard
206 \begin_inset VSpace defskip
212 \begin_layout Standard
213 In this note, we describe how
217 \begin_layout Plain Layout
226 -pic can be used from inside LyX, how diagrams can be created and edited.
227 We have tested the following using LyX versions 1.3.7 up to 1.6, running under
229 \begin_inset space \thinspace{}
232 XP and under Windows Vista.
236 \begin_layout Standard
237 There are two modes of operations: For a start, and for some first tests,
238 it may be easiest to first enter the
242 \begin_layout Plain Layout
251 -Pic code inside the LyX-window, select it all and convert it to a graphical
252 representation by pressing
265 \begin_layout Plain Layout
274 -Pic more frequently, or if you want to modify your initial figure, you
275 will want to assemble and modify your figures using LyX's math editor.
279 \begin_layout Standard
280 Once the cursor is moved over a diagram, this is displayed as an array of
281 nodes and arrow-commands.
282 These can be changed interactively.
283 When the cursor leaves the editing area, the diagram reappears.
287 \begin_layout Standard
288 In the first two sections of this documentation, we explain how to use LyX
289 in the first mentioned mode and we introduce all
293 \begin_layout Plain Layout
302 -Pic features that might be of use for drawing commutative diagrams, graphs
305 \begin_inset CommandInset ref
307 reference "sec:math-editor"
311 explains how to use the
315 \begin_layout Plain Layout
324 -Pic commands inside a math-editing area.
328 \begin_layout Standard
329 It is not our intention to write another introduction to
333 \begin_layout Plain Layout
342 -Pic, rather our motivation is to give an introduction how the most important
343 commands work inside LyX, since the keystrokes as explained in the
347 \begin_layout Plain Layout
357 \begin_inset CommandInset citation
363 will not always function correctly inside LyX.
367 \begin_layout Section
371 \begin_layout Standard
372 The following requires that the LaTeX-packages
380 are installed in the LaTeX system.
381 They are available from CTAN, see at
382 \begin_inset CommandInset citation
384 key "instant-preview"
390 \begin_inset CommandInset citation
397 After freshly installing them, it may be necessary, to run
399 Edit\SpecialChar \menuseparator
402 from the main LyX menu.
403 The steps to a first diagram output in LyX are then:
406 \begin_layout Enumerate
413 \begin_layout Enumerate
416 Edit\SpecialChar \menuseparator
417 Preferences\SpecialChar \menuseparator
418 Look and Feel\SpecialChar \menuseparator
421 and place a check-mark at
429 \begin_layout Enumerate
434 works by opening a LyX-document and entering any math-formula, e.
435 \begin_inset space \thinspace{}
440 \begin_inset Formula $a+b=c$
447 \begin_layout Enumerate
448 Move the cursor out of the formula, and watch it change its appearance to
449 look just like in the finished DVI- or PostScript document.
454 \begin_layout Enumerate
459 \begin_layout Plain Layout
474 \begin_layout Enumerate
475 Inside your LyX-Document, enter the text
478 \begin_inset Newline newline
490 \begin_layout Enumerate
491 Select the whole text and choose
493 Insert\SpecialChar \menuseparator
494 Math\SpecialChar \menuseparator
497 , or use the corresponding keyboard shortcut
505 \begin_layout Enumerate
506 Move the mouse cursor out of the editing box and wait for a split second
507 to see an arrow appear:
508 \begin_inset Formula $\xymatrix{A\ar[r] & B}
516 \begin_layout Section
520 \begin_layout Standard
521 The following diagram, which is taken from the documentation of
525 \begin_layout Plain Layout
535 \begin_inset CommandInset citation
541 by its creator Kristoffer H.
542 Rose, will provide an example for many of the features available with that
547 \begin_layout LyX-Code
551 \begin_inset Newline newline
563 \begin_inset Newline newline
573 \begin_inset Newline newline
589 \begin_inset Newline newline
597 \begin_layout LyX-Code
601 \begin_layout Standard
602 Again, to turn this code into a graphical output, select it all at once
609 \SpecialChar \ldots{}
610 up to the closing brace \SpecialChar \ldots{}
615 and turn it into display-math as explained above.
616 A moment after the cursor leaves the math-area, you should see the diagram
617 in its full graphical glory as shown below.
621 \begin_layout Standard
622 \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\
623 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
631 \begin_layout Subsection
632 The matrix layout of diagrams
635 \begin_layout Standard
640 uses a matrix to define the layout of the vertices of a diagram.
641 For the above example, we need a
642 \begin_inset Formula $3\times3$
645 -matrix of which 5 entries are used for the vertices
646 \begin_inset Formula $U$
650 \begin_inset Formula $X\times_{Z}Y$
654 \begin_inset Formula $X$
658 \begin_inset Formula $Y$
662 \begin_inset Formula $Z$
665 , the other positions remaining empty.
666 In this case, the following matrix determines the layout:
669 \begin_layout LyX-Code
673 \begin_inset Newline newline
681 \begin_inset Newline newline
691 \begin_inset Newline newline
697 \begin_layout Standard
698 The pattern should be familiar from LaTeX: We see three rows, the first
699 two being terminated by the end-of-line-marker
708 Each line consists of entries, separated by the ampersand
716 \begin_layout Subsection
720 \begin_layout Standard
721 Having entered the vertices, we add arrows between them.
726 -command to produce an arrow is
732 , it is entered into the cell of the matrix where the arrow is to start.
733 The target of the arrow is defined by direction commands
750 These can be combined to a path and enclosed in square brackets.
751 As an example, the arrows from the vertex
752 \begin_inset Formula $U$
755 in the upper left corner down and right to the vertices
756 \begin_inset Formula $X\times_{Z}Y$
760 \begin_inset Formula $Y$
764 \begin_inset Formula $X$
767 are, respectively, defined as
786 Thus the above diagram with all arrows added becomes:
789 \begin_layout LyX-Code
793 \begin_inset Newline newline
807 \begin_inset Newline newline
823 \begin_inset Newline newline
831 \begin_layout Standard
832 \begin_inset Formula \xymatrix{ U \ar[ddr] \ar[drr] \ar[dr]\\
833 & X \times_{Z} Y \ar[d] \ar[r] & X \ar[d]\\
842 \begin_layout LyX-Code
846 \begin_layout LyX-Code
850 \begin_layout Subsection
854 \begin_layout Standard
855 Labels are attached to arrows by affixing them as upper or lower indices
871 defines an arrow going one cell down, two to the right and having the label
873 \begin_inset Formula $\varphi$
877 To attach a label below the arrow, make it a lower index as in
886 This explanation is correct only for arrows pointing to the right.
887 More precisely, imagine looking along the arrow in the direction it is
889 Then an upper index places a label to the left and a lower index places
891 Consequently, an arrow pointing from right to left, such as
902 \begin_inset Formula $\alpha$
906 \begin_inset Formula $\beta$
910 \begin_inset space \thinspace{}
914 \begin_inset space \space{}
918 \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.}
922 Using the character | instead of ^ or _ , it is even possible to place the
923 label right onto the arrow, obscuring part of its shaft.
927 \begin_layout Standard
928 Normally, a label is placed halfway between an arrow's start and target
930 In the first diagram, the central arrow starting in
931 \begin_inset Formula $U$
935 \begin_inset Formula $(x,y)$
938 in the middle of the arrow's shaft, rather than in the middle between the
939 two objects it connects.
940 This is achieved by prefixing the label with a minus sign, here:
949 \begin_layout LyX-Code
953 \begin_inset Newline newline
971 \begin_inset Newline newline
987 \begin_inset Newline newline
995 \begin_layout LyX-Code
996 \begin_inset Formula \xymatrix{ U \ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\
997 & X \times_{Z} Y \ar[d]^{q} \ar[r]_{p} & X \ar[d]_{f}\\
1006 \begin_layout Standard
1010 \begin_layout Plain Layout
1019 -pic normally permits labels to be shifted towards the tip or towards the
1020 start of an arrow by prefixing the label with a ratio, such as e.
1021 \begin_inset space \thinspace{}
1030 In LyX this works only for labels which are placed on top of the arrow,
1043 \begin_layout Standard
1044 For labels placed to the left or to the right of the arrow this does not
1050 \begin_layout Plain Layout
1059 -pic code such as e.
1060 \begin_inset space \thinspace{}
1080 is not correctly interpreted by LyX's math editor.
1081 Two workarounds are suggested in the last section of this note.
1084 \begin_layout Subsection
1088 \begin_layout Standard
1089 Modification of the design, the form or the positioning of arrows are introduced
1095 This is followed by a pair of matching brackets, where the form of the
1108 indicates, whether we want to modify the design, the or the curvature of
1110 Various modifications can be applied to an arrow at the same time.
1113 \begin_layout Subsubsection
1117 \begin_layout Standard
1118 Various designs such as
1134 are possible for the shaft of an arrow.
1135 These can be combined with various ends and various tips.
1136 In general, the design of an arrow is described by following the command
1147 -sign and a pair of braces {\SpecialChar \ldots{}
1148 } containing characters describing the end,
1149 the shaft and the tip of the arrow.
1150 These characters are chosen to give some form of ASCII-rendering of the
1158 produces an arrow with split end, a dotted shaft and double head.
1159 A number of other arrow designs is given in the table below.
1160 Note that the ends of embedding arrows
1161 \begin_inset Formula $\xymatrix{A\ar@{^{(}->}[r] & B}
1165 are described by raising or lowering opening parentheses, such as in
1170 \begin_inset Newline newline
1176 \begin_layout Standard
1177 \begin_inset Tabular
1178 <lyxtabular version="3" rows="11" columns="2">
1179 <features islongtable="true">
1180 <column alignment="center" valignment="top" width="0">
1181 <column alignment="center" valignment="top" width="0">
1183 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1186 \begin_layout Plain Layout
1192 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1195 \begin_layout Plain Layout
1203 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1206 \begin_layout Plain Layout
1207 \begin_inset Formula \xymatrix{\ \ar[r] & \ }
1217 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1220 \begin_layout Plain Layout
1232 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1235 \begin_layout Plain Layout
1236 \begin_inset Formula \xymatrix{\ \ar@{-->}[r] & \ }
1246 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1249 \begin_layout Plain Layout
1261 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1264 \begin_layout Plain Layout
1265 \begin_inset Formula \xymatrix{\ \ar@{..>}[r] & \ }
1275 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1278 \begin_layout Plain Layout
1290 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1293 \begin_layout Plain Layout
1294 \begin_inset Formula \xymatrix{\ \ar@{~>}[r] & \ }
1304 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1307 \begin_layout Plain Layout
1319 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1322 \begin_layout Plain Layout
1323 \begin_inset Formula \xymatrix{\ \ar@{->>}[r] & \ }
1333 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1336 \begin_layout Plain Layout
1348 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1351 \begin_layout Plain Layout
1352 \begin_inset Formula \xymatrix{\ \ar@{-->>}[r] & \ }
1362 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1365 \begin_layout Plain Layout
1377 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1380 \begin_layout Plain Layout
1381 \begin_inset Formula \xymatrix{\ \ar@{>->>}[r] & \ }
1391 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1394 \begin_layout Plain Layout
1406 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1409 \begin_layout Plain Layout
1410 \begin_inset Formula \xymatrix{\ \ar@{_{(}->}[r] & \ }
1420 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1423 \begin_layout Plain Layout
1435 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1438 \begin_layout Plain Layout
1439 \begin_inset Formula \xymatrix{\ \ar@{^{(}->}[r] & \ }
1449 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1452 \begin_layout Plain Layout
1464 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1467 \begin_layout Plain Layout
1468 \begin_inset Formula \xymatrix{\ \ar@{|-|}[r] & \ }
1478 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1481 \begin_layout Plain Layout
1499 \begin_layout Standard
1501 Following the @-character by either a 2, 3, _,or a ^, we can produce arrows
1502 with double, triple shaft or arrows showing only the lower or upper half
1503 of their tips and ends.
1504 Arrows need not have tips nor ends, as the last example shows :
1505 \begin_inset Newline newline
1511 \begin_layout Standard
1512 \begin_inset Tabular
1513 <lyxtabular version="3" rows="8" columns="2">
1514 <features islongtable="true">
1515 <column alignment="center" valignment="top" width="0">
1516 <column alignment="center" valignment="top" width="0">
1518 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1521 \begin_layout Plain Layout
1527 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1530 \begin_layout Plain Layout
1538 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1541 \begin_layout Plain Layout
1542 \begin_inset Formula \xymatrix{\ \ar@2[r] & \ }
1552 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1555 \begin_layout Plain Layout
1567 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1570 \begin_layout Plain Layout
1571 \begin_inset Formula \xymatrix{\ \ar@3[r] & \ }
1581 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1584 \begin_layout Plain Layout
1596 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1599 \begin_layout Plain Layout
1600 \begin_inset Formula \xymatrix{\ \ar@_{->}[r] & \ }
1610 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1613 \begin_layout Plain Layout
1625 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1628 \begin_layout Plain Layout
1629 \begin_inset Formula \xymatrix{\ \ar@^{->}[r] & \ }
1639 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1642 \begin_layout Plain Layout
1654 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1657 \begin_layout Plain Layout
1658 \begin_inset Formula \xymatrix{\ \ar@^{>>->>}[r] & \ }
1668 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1671 \begin_layout Plain Layout
1683 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1686 \begin_layout Plain Layout
1687 \begin_inset Formula \xymatrix{\ \ar@{^{<}-_{>}}[r] & \ }
1697 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1700 \begin_layout Plain Layout
1712 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1715 \begin_layout Plain Layout
1716 \begin_inset Formula \xymatrix{\ \ar@2{--}[r] & \ }
1726 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1729 \begin_layout Plain Layout
1747 \begin_layout Subsubsection
1748 Designing your own arrows
1751 \begin_layout Standard
1752 Within certain limits there is even a way to design your own arrows.
1753 Using some the characters
1757 one can even design one's own arrow tips using the
1763 command in the preamble.
1764 For explanations, we refer to the
1770 \begin_layout Plain Layout
1781 -manual, from which we take the example:
1784 \begin_layout Standard
1789 newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
1794 \begin_layout Standard
1796 This defines a new arrow tip, referred to as
1806 and which displays correctly in LyX as:
1807 \begin_inset Formula \[
1808 \xymatrix{A\ar@{-|>}[r] & \ \ B}
1816 \begin_layout Subsection
1820 \begin_layout Standard
1821 Arrows are shifted sideways with the modifier
1826 \begin_inset Formula $\ldots$
1833 where the ellipsis is replaced by a positive or negative measure.
1834 For instance, to design a pair of mutually opposing arrows between two
1835 nodes, we shift them to see them apart.
1836 Note that the direction of the shift (positive) is to the left if one looks
1841 \begin_layout Standard
1857 \begin_layout Standard
1860 \begin_inset space ~
1864 \begin_inset space ~
1868 \begin_inset Formula \[
1869 \xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1878 \begin_layout Subsubsection
1879 Inline or centered diagrams
1882 \begin_layout Standard
1883 Arrows and diagrams can be used inline, such as this one:
1884 \begin_inset Formula $\xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1889 When their code is written inside LyX as above, select it and choose either
1894 for inline appearance or
1899 Diagrams constructed inline can later be centered, or, conversely, centered
1900 diagrams can be changed to inline formulas with
1902 Edit\SpecialChar \menuseparator
1907 \SpecialChar \menuseparator
1911 \begin_layout Subsection
1915 \begin_layout Standard
1916 There are two simple methods to make arrows bend.
1917 The first is giving an explicit value by which the midpoint of the arrow's
1918 shaft is raised or depressed, the other is by forcing the arrow to leave
1919 its origin in a prescribed compass direction and to make him enter the
1920 target at another direction.
1921 The necessary bending of the arrow is determined automatically.
1922 We describe both methods.
1925 \begin_layout Subsubsection
1929 \begin_layout Standard
1930 For bending arrows we use the modifier @/
1931 \begin_inset Formula $\ldots$
1935 The ellipsis stands for a TeX-measure which needs to be entered as a lower
1941 , we could simply write, e.
1942 \begin_inset space \thinspace{}
1952 for an arrow bending
1956 downwards, this cannot directly be done in LyX.
1957 It is necessary, to enclose the measure in a pair of braces, such as e.
1958 \begin_inset space \thinspace{}
1969 As an example, here are two opposing arrows between
1970 \begin_inset Formula $A$
1974 \begin_inset Formula $B$
1977 , each bending by .5 pica, given by the following source code:
1980 \begin_layout Standard
1992 \begin_layout Standard
1993 \begin_inset Formula \[
1994 \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]}
2002 \begin_layout Subsubsection
2003 Specifying exit- and entrance directions
2006 \begin_layout Standard
2007 An alternative for making arrows bend is by specifying their compass direction
2008 as they are leaving their source and their direction from which they enter
2010 Instead of north, north-east, east, etc., the directions are named
2042 , standing for up, up-right, right, down-right, etc..
2043 A direction is specified as @(
2055 stands for the direction the first object is left and
2059 stands for the direction from which the target is entered.
2060 As an example, we show some bending arrows and a loop, which arises when
2061 we do not specify a target for an arrow, just its incoming and outgoing
2065 \begin_layout Standard
2066 \begin_inset Formula \[
2067 \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\
2076 \begin_layout LyX-Code
2084 \begin_inset Newline newline
2094 \begin_inset Newline newline
2102 \begin_layout Subsection
2106 \begin_layout Standard
2107 The above example is reminiscent of an automata diagram, except that in
2108 such a diagram states would be enclosed in small circles, with double circles
2109 denoting final states.
2113 \begin_layout Subsubsection
2117 \begin_layout Standard
2122 \begin_layout Plain Layout
2131 -Pic, entries can obtain a single or a double frame, such as
2132 \begin_inset Formula $\xymatrix{*+[F]{A}}
2137 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2141 by prefixing an entry with
2149 and enclosing the portion of the entry to be framed in braces.
2150 Normally, the frame will be very tight so that it must be widened by prefixing
2160 Round frames, such as
2161 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2166 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2170 are obtained by specifying the shape as
2175 So the latter figure was constructed as *++[o][F=]{B}.
2176 This way, the following automaton
2179 \begin_layout Standard
2180 \begin_inset Formula \[
2181 \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]}
2189 \begin_layout Standard
2194 \begin_layout LyX-Code
2204 \begin_layout LyX-Code
2210 \begin_layout LyX-Code
2218 \begin_layout LyX-Code
2222 \begin_layout Standard
2229 \SpecialChar \ldots{}
2234 will make a certain entry style the default, that can, of course be overridden
2235 for individual entries.
2240 entrymodifiers={++[o][F-]}
2242 , all following entries inside
2246 \begin_layout Plain Layout
2255 -matrices would be encircled.
2258 \begin_layout Subsubsection
2262 \begin_layout Standard
2263 Framing a whole rectangle inside an xymatrix is done with the macro pair
2283 The dimension of the rectangle is given as a dotted pair
2284 \begin_inset Formula $P_{0}.P_{1}$
2287 of points denoting the top left and lower right corners of the rectangle.
2288 Each point, in turn,is given as a doubly quoted comma separated pair
2289 \begin_inset Quotes eld
2293 \begin_inset Formula $x,y$
2297 \begin_inset Quotes erd
2301 \begin_inset Formula $x$
2305 \begin_inset Formula $y$
2309 These are followed by the framing commands, to produce figures such as
2311 \begin_inset Formula \[
2312 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2313 C & \save"1,1"."1,2"*++[F]\frm{}\restore}
2329 save"1,1"."2,1"*+[F=]
2342 produces the doubly framed rectangle, and the code for the extra wide horizonta
2354 save"1,1"."1,2"*++[F]
2368 This code can be placed in arbitrary cells of the xymatrix.
2372 \begin_layout Section
2373 Using LyX's math editor
2374 \begin_inset CommandInset label
2376 name "sec:math-editor"
2383 \begin_layout Standard
2384 As an alternative to writing the
2388 code, then transforming it into a math-editing environment by marking it
2397 , one may construct and modify the whole xypic-diagram inside LyX's math
2399 We describe the editing steps for a figure just like the one above.
2403 \begin_layout Subsection
2404 Caveat - how to enter braces
2407 \begin_layout Standard
2408 Recall that in LyX's math-editor any pair of braces
2416 that are to enclose a macro-parameter must be entered by typing just
2423 The closing brace is automatically supplied and in between a box into which
2424 to the parameter is entered.
2429 \begin_layout Plain Layout
2438 -diagrams, this applies in particular to arrow modifications that are normally
2443 \SpecialChar \ldots{}
2448 with the ellipsis standing for the description of end, shaft and tip of
2450 Inside the math-editor, enter just
2456 and let LyX provide the closing brace and the box into which to enter the
2457 description of the arrow.
2460 \begin_layout Standard
2461 Braces that are entered without the backslash
2467 will just appear as typed, but cannot be used to receive a macro parameter.
2468 They are useful, for instance to denote sets, e.
2469 \begin_inset space \thinspace{}
2484 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2490 \begin_layout Subsection
2491 Setting up the matrix
2494 \begin_layout Standard
2503 open a formula environment and enter:
2511 \begin_inset Formula $\times$
2518 \begin_layout Plain Layout
2528 Add extra rows by typing
2532 and add columns by typing
2538 \begin_layout Standard
2539 At any time, further rows or columns can be entered or deleted using commands
2542 Edit\SpecialChar \menuseparator
2546 their shortcuts, beginning with
2550 for the column commands or
2554 for the row commands.
2558 \begin_layout Subsection
2559 Entering nodes, arrows and labels
2562 \begin_layout Standard
2563 Type the nodes into the correct positions of the matrix.
2564 If you move the cursor out of the matrix, you should see a first rendering
2566 Next, add the arrows at the nodes from where they should emanate by typing
2583 can be any path made up from the characters
2600 Make sure that the path indeed leads to an existing node within the matrix.
2601 Otherwise, the figure will not display when the cursor leaves the editing
2605 \begin_layout Standard
2606 Next, label the arrows by attaching a label text as upper or lower indices
2607 to the end of the arrow's path.
2608 As always in LyX's math editor, an underscore
2612 opens a box for a lower index and a
2616 followed by a space opens a box for an upper index.
2617 You can enter any LaTeX-code as a label.
2620 \begin_layout Subsection
2624 \begin_layout Standard
2625 Finally, you can modify the appearance of the arrows by entering @-modifiers
2630 \SpecialChar \ldots{}
2639 \SpecialChar \ldots{}
2644 \SpecialChar \ldots{}
2645 ,\SpecialChar \ldots{}
2650 \SpecialChar \ldots{}
2656 The above caveat applies to the first form only.
2657 It must be entered as
2663 with the arrow description entered inside the LyX-supplied box.
2664 If this box remains empty, you have specified an empty arrow.
2665 This is a useful construction, too, as you will see in the next section.
2669 \begin_layout Standard
2670 The other modifiers,
2674 \SpecialChar \ldots{}
2683 \SpecialChar \ldots{}
2684 ,\SpecialChar \ldots{}
2693 \SpecialChar \ldots{}
2698 are typed as shown with the arrow description replacing the ellipsis.
2699 The code for bending arrows, which in
2728 is any valid TeX-measure that should be entered as upper or lower index
2729 to the first slash /.
2730 Make sure that the ending slash does not end up being part of the upper
2734 \begin_layout Subsection
2735 What if something goes wrong
2738 \begin_layout Standard
2739 When constructing a diagram, you should at times check it by just moving
2740 the cursor out of the editing area to see whether instant preview can successfu
2741 lly convert it into graphical output.
2742 If this does not happen, it may either be that instant preview for some
2743 reason is not aware that it should retranslate the graphics.
2744 Moving the cursor into the editing area and out again sometimes wakes up
2748 \begin_layout Standard
2749 A more serious reason could be a syntactical error in your input.
2750 If necessary, redo the last editing steps, using
2754 , or try to translate the LyX-file into
2764 View\SpecialChar \menuseparator
2768 There should be some error generated, which hopefully gives you a hint
2769 as to the source of the mistake.
2772 \begin_layout Section
2776 \begin_layout Standard
2777 Certain things do not work correctly inside LyX.
2778 The ones that we (used to) miss most are the horizontal and vertical scaling
2779 of diagrams, and the correct positioning of arrows.
2780 There are some workarounds that we are explaining here.
2784 \begin_layout Subsection
2785 Horizontal and vertical scaling
2788 \begin_layout Standard
2789 It is often convenient to stretch the horizontal or the vertical dimensions
2790 of an entire diagram by using spacing commands for rows and/or columns.
2795 \begin_layout Plain Layout
2804 -manual, for instance,
2810 \SpecialChar \ldots{}
2819 \begin_layout Plain Layout
2828 -matrix with row spacing of 1 pica.
2835 \SpecialChar \ldots{}
2840 \SpecialChar \ldots{}
2845 allows to modify the space between columns.
2846 Unfortunately, these commands do currently not work inside LyX, as the
2847 @-character is interpreted by LyX as ending the
2851 \begin_layout Plain Layout
2864 \begin_layout Standard
2869 \begin_layout Plain Layout
2879 \begin_inset space ~
2882 stores the values for row-spacing and column-spacing in the variables
2894 , add the following macro to the preamble (
2896 Layout\SpecialChar \menuseparator
2897 Document\SpecialChar \menuseparator
2901 \begin_inset Newpage pagebreak
2907 \begin_layout LyX-Code
2915 \begin_layout LyX-Code
2920 xymatrixrowsep@{#1}}
2923 \begin_layout LyX-Code
2927 \begin_layout Standard
2934 can be defined correspondingly by replacing
2947 Now, a figure can be scaled by entering
2953 \begin_layout Plain Layout
2963 Place the cursor inside the matrix, just before the first entry.
2981 Don't forget the backslashes and remember, that the closing brace is automatica
2982 lly supplied by LyX.
2983 Inside the braces enter the dimensions.
2989 Here you see a diagram which is squashed vertically and stretched horizontally
3001 \begin_layout Standard
3002 \begin_inset Formula \[
3003 \xyC{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
3004 C\ar@{}[ur]|{\text{{horizontal stretch}}}}
3012 \begin_layout Subsection
3016 \begin_layout Standard
3021 \begin_layout Plain Layout
3030 -command allows the correct positioning of labels along the shaft of arrows.
3031 This feature is sometimes necessary, when the default position of a label
3032 would otherwise clutter the picture, or would even coincide with other
3033 items, such as the intersection of the arrows in the figure below.
3034 In order to shift a label position alongside the shaft of an arrow,
3038 \begin_layout Plain Layout
3048 \begin_inset space ~
3051 allows to prefix the label by a decimal number in parentheses, specifying
3052 the fraction of distance alongside the arrow where the label is to be placed.
3053 For instance, the code
3061 , will place the label on the shaft, but only about one third of the way.
3065 \begin_layout Standard
3066 Doing the same with labels above or below arrows as
3082 , does not work from inside LyX.
3083 Instead, one has to replace the hat-symbol ^, resp.
3084 the underscore _ , by the macros
3118 It is, in fact, possible to enter several labels this way and those labels
3119 are placed correctly, even if the arrow bends.
3120 In the following figure, the bending arrow with its four labels has been
3144 \begin_layout Standard
3145 \begin_inset Formula \[
3146 \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}}\\
3147 \circ\ar[ur]\sb(0.3)\phi & \bullet}
3155 \begin_layout Subsection
3156 Invisible stretched arrows
3159 \begin_layout Standard
3160 A more general trick uses invisible arrows to place any object almost anywhere
3162 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3163 a decimal stretching ratio, e.
3164 \begin_inset space \thinspace{}
3177 Attach a label to this invisible arrow.
3181 \begin_layout Standard
3182 Thus, the down pointing arrow with its label
3183 \begin_inset Formula $\varphi$
3186 at (0.3) of its way along the shaft might as well have been produced by
3187 adding to the regular arrow
3194 \begin_inset Formula $\varphi$
3205 , reaching only 0.6 of the way.
3206 Its label will now appear at 0.3 of the way of the original visible arrow.
3210 \begin_layout Standard
3211 This workaround has two minor drawbacks: First, it does not work with bending
3213 Secondly, prolonging an invisible arrow beyond the normal dimension of
3214 the figure will invisibly extend the figure box, and thereby cause too
3215 much vertical space between the figure and the preceding or the following
3220 \begin_layout Standard
3221 Nevertheless, invisible arrows are an important tool, since they can, in
3222 principle, be used to place information at any chosen place in a diagram.
3223 In the above figure, for instance, we have used an invisible arrow to carry
3230 as label and at the earlier figure we had used an invisible arrow to carry
3232 \begin_inset Quotes eld
3240 \begin_inset Quotes erd
3243 into the center of the figure.
3246 \begin_layout Subsection
3253 \begin_layout Plain Layout
3267 \begin_layout Standard
3268 Here we have focused only on the
3274 command, which is just one of the features available in Kris Rose's amazing
3280 \begin_layout Plain Layout
3298 \begin_layout Plain Layout
3310 \begin_inset CommandInset citation
3316 demonstrates many of the advanced possibilities of that package.
3317 Beware, that its style is rather terse and you will likely need a lot of
3318 experimenting and modifying the many worked examples.
3320 \begin_inset CommandInset citation
3330 \begin_layout Plain Layout
3339 -pic to make braids, cobordism, string diagrams, and much more.
3340 A good and rather systematic introduction to
3346 \begin_layout Plain Layout
3358 \begin_inset CommandInset citation
3365 Even if you share with me the disadvantage of not being fluent in Esperanto,
3366 you will be able to understand most of it.
3370 \begin_layout Bibliography
3371 \begin_inset CommandInset bibitem
3372 LatexCommand bibitem
3383 \begin_layout Plain Layout
3399 Available as part of the
3407 \begin_layout Bibliography
3408 \begin_inset CommandInset bibitem
3409 LatexCommand bibitem
3411 key "instant-preview"
3416 \begin_inset Flex URL
3419 \begin_layout Plain Layout
3421 http://www.tug.org/tex-archive/help/Catalogue/entries/preview-latex.html
3429 \begin_layout Bibliography
3430 \begin_inset CommandInset bibitem
3431 LatexCommand bibitem
3438 \begin_inset Flex URL
3441 \begin_layout Plain Layout
3443 http://www.tug.org/tex-archive/help/Catalogue/entries/xypic.html
3451 \begin_layout Bibliography
3452 \begin_inset CommandInset bibitem
3453 LatexCommand bibitem
3460 \begin_inset Flex URL
3463 \begin_layout Plain Layout
3465 http://www.gnu.org/software/auctex/
3473 \begin_layout Bibliography
3474 \begin_inset CommandInset bibitem
3475 LatexCommand bibitem
3485 \begin_layout Plain Layout
3500 tutorial with an archive of examples
3503 \begin_inset Flex URL
3506 \begin_layout Plain Layout
3508 http://www.dpmms.cam.ac.uk/~al366/xytutorial.html
3516 \begin_layout Bibliography
3517 \begin_inset CommandInset bibitem
3518 LatexCommand bibitem
3528 \begin_layout Plain Layout
3543 Enkonduko pri Xymatrix
3547 \begin_inset Flex URL
3550 \begin_layout Plain Layout
3552 http://filip.ouvaton.org/xypic/xymatrix/index.html