1 #LyX 2.2 created this file. For more info see http://www.lyx.org/
5 \save_transient_properties true
6 \origin /systemlyxdir/examples/
9 % DO NOT ALTER THIS PREAMBLE!!!
11 % This preamble is designed to ensure that the file prints
12 % out as advertised. If you mess with this preamble,
13 % parts of this document may not print out as expected. If you
14 % have problems LaTeXing this file, please contact
15 % the documentation team
16 % email: lyx-docs@lists.lyx.org
20 % define new commands used in sec. 5.1
22 \xydef@\xymatrixrowsep@{#1}}
24 \xydef@\xymatrixcolsep@{#1}}
26 \newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
28 % a pdf-bookmark for the TOC is added
29 \let\myTOC\tableofcontents
30 \renewcommand\tableofcontents{%
31 \pdfbookmark[1]{\contentsname}{}
34 % redefine the \LyX macro for PDF bookmarks
35 \def\LyX{\texorpdfstring{%
36 L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}
43 % set fonts for nicer pdf view
44 \IfFileExists{lmodern.sty}
45 {\usepackage{lmodern}}{}
47 \fi % end if pdflatex is used
50 \use_default_options false
51 \maintain_unincluded_children false
53 \language_package default
56 \font_roman "default" "default"
57 \font_sans "default" "default"
58 \font_typewriter "default" "default"
59 \font_math "auto" "auto"
60 \font_default_family default
61 \use_non_tex_fonts false
64 \font_sf_scale 100 100
65 \font_tt_scale 100 100
67 \default_output_format default
69 \bibtex_command default
70 \index_command default
74 \pdf_title "Using XY-pc in LyX"
75 \pdf_author "H. Peter Gumm"
76 \pdf_subject "LyX's XY-pic manual"
77 \pdf_keywords "LyX, documentation"
79 \pdf_bookmarksnumbered true
80 \pdf_bookmarksopen true
81 \pdf_bookmarksopenlevel 2
86 \pdf_pdfusetitle false
87 \pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue,pdfpagelayout=OneColumn, pdfnewwindow=true,pdfstartview=XYZ, plainpages=false"
90 \use_package amsmath 1
91 \use_package amssymb 1
94 \use_package mathdots 1
95 \use_package mathtools 0
97 \use_package stackrel 0
98 \use_package stmaryrd 0
99 \use_package undertilde 0
101 \cite_engine_type default
105 \paperorientation portrait
109 \notefontcolor #0000ff
116 \paragraph_separation indent
117 \paragraph_indentation default
118 \quotes_language english
121 \paperpagestyle default
122 \tracking_changes false
123 \output_changes false
136 \begin_layout Plain Layout
145 -pic in \SpecialChar LyX
154 \begin_layout Abstract
155 With the recent versions of \SpecialChar LyX
160 -style installed in the \SpecialChar LaTeX
161 -System, the graph drawing package
167 \begin_layout Plain Layout
178 -pic can be conveniently used inside \SpecialChar LyX
180 Diagrams can be edited and displayed inside the main \SpecialChar LyX
182 Here, we shall describe how to use the
192 inside \SpecialChar LyX
193 in order to draw, to edit and to preview diagrams as typically
194 used in category theory, algebra, and related fields.
198 \begin_layout Abstract
199 \begin_inset CommandInset toc
200 LatexCommand tableofcontents
207 \begin_layout Section
211 \begin_layout Standard
216 -package has long served as a convenient tool for easily constructing graphs
217 and diagrams in \SpecialChar LaTeX
219 Unfortunately, its use in \SpecialChar LyX
220 had long been restricted to the infamous \SpecialChar TeX
222 boxes, meaning that the \SpecialChar LyX
223 editor could only display the \SpecialChar LaTeX
225 the finished diagram.
230 -style of \SpecialChar LaTeX
231 which is part of the AUC\SpecialChar TeX
233 \begin_inset CommandInset citation
239 , finally enables the editing and displaying of
243 -diagrams, constructed, displayed and interactively edited inside \SpecialChar LyX
247 \begin_layout Standard
248 \begin_inset VSpace defskip
254 \begin_layout Standard
256 \begin_inset Graphics
257 filename xyfigure.png
265 \begin_layout Standard
266 \begin_inset VSpace defskip
272 \begin_layout Standard
273 In this note, we describe how
277 \begin_layout Plain Layout
286 -pic can be used from inside \SpecialChar LyX
287 , how diagrams can be created and edited.
288 We have tested the following using \SpecialChar LyX
289 versions 1.3.7 up to 1.6, running under
291 \begin_inset space \thinspace{}
294 XP and under Windows Vista.
298 \begin_layout Standard
299 There are two modes of operations: For a start, and for some first tests,
300 it may be easiest to first enter the
304 \begin_layout Plain Layout
313 -pic code inside the \SpecialChar LyX
314 -window, select it all and convert it to a graphical
315 representation by pressing
328 \begin_layout Plain Layout
337 -pic more frequently, or if you want to modify your initial figure, you
338 will want to assemble and modify your figures using \SpecialChar LyX
343 \begin_layout Standard
344 Once the cursor is moved over a diagram, this is displayed as an array of
345 nodes and arrow-commands.
346 These can be changed interactively.
347 When the cursor leaves the editing area, the diagram reappears.
351 \begin_layout Standard
352 In the first two sections of this documentation, we explain how to use \SpecialChar LyX
354 in the first mentioned mode and we introduce all
358 \begin_layout Plain Layout
367 -pic features that might be of use for drawing commutative diagrams, graphs
370 \begin_inset CommandInset ref
372 reference "sec:math-editor"
376 explains how to use the
380 \begin_layout Plain Layout
389 -pic commands inside a math-editing area.
393 \begin_layout Standard
394 It is not our intention to write another introduction to
398 \begin_layout Plain Layout
407 -pic, rather our motivation is to give an introduction how the most important
408 commands work inside \SpecialChar LyX
409 , since the keystrokes as explained in the
413 \begin_layout Plain Layout
423 \begin_inset CommandInset citation
429 will not always function correctly inside \SpecialChar LyX
434 \begin_layout Section
438 \begin_layout Standard
439 The following requires that the \SpecialChar LaTeX
448 are installed in the \SpecialChar LaTeX
450 They are available from CTAN, see at
451 \begin_inset CommandInset citation
453 key "instant-preview"
459 \begin_inset CommandInset citation
466 After freshly installing them, it may be necessary, to run
468 Tools\SpecialChar menuseparator
471 from the main \SpecialChar LyX
473 The steps to a first diagram output in \SpecialChar LyX
477 \begin_layout Enumerate
484 \begin_layout Enumerate
485 Open \SpecialChar LyX
488 Tools\SpecialChar menuseparator
489 Preferences\SpecialChar menuseparator
490 Look and Feel\SpecialChar menuseparator
500 \begin_layout Enumerate
503 Document\SpecialChar menuseparator
504 Settings\SpecialChar menuseparator
513 Use AMS Math package automatically
522 \begin_layout Enumerate
527 works by opening a \SpecialChar LyX
528 -document and entering any math-formula, e.
529 \begin_inset space \thinspace{}
533 \begin_inset space \space{}
537 \begin_inset Formula $a+b=c$
544 \begin_layout Enumerate
545 Move the cursor out of the formula, and watch it change its appearance to
546 look just like in the finished DVI- or PostScript document.
551 \begin_layout Enumerate
556 \begin_layout Plain Layout
571 \begin_layout Enumerate
572 Inside your \SpecialChar LyX
573 -Document, enter the text
576 \begin_inset Newline newline
588 \begin_layout Enumerate
589 Select the whole text and choose
591 Insert\SpecialChar menuseparator
592 Math\SpecialChar menuseparator
595 , or use the corresponding keyboard shortcut
603 \begin_layout Enumerate
604 Move the mouse cursor out of the editing box and wait for a split second
605 to see an arrow appear:
606 \begin_inset Formula $\xymatrix{A\ar[r] & B}
614 \begin_layout Section
618 \begin_layout Standard
619 The following diagram, which is taken from the documentation of
623 \begin_layout Plain Layout
633 \begin_inset CommandInset citation
639 by its creator Kristoffer H.
640 Rose, will provide an example for many of the features available with that
645 \begin_layout LyX-Code
649 \begin_inset Newline newline
661 \begin_inset Newline newline
671 \begin_inset Newline newline
687 \begin_inset Newline newline
695 \begin_layout LyX-Code
699 \begin_layout Standard
700 Again, to turn this code into a graphical output, select it all at once
708 up to the closing brace \SpecialChar ldots
713 and turn it into display-math as explained above.
714 A moment after the cursor leaves the math-area, you should see the diagram
715 in its full graphical glory as shown below.
719 \begin_layout Standard
720 \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\
721 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
730 \begin_layout Subsection
731 The matrix layout of diagrams
734 \begin_layout Standard
739 uses a matrix to define the layout of the vertices of a diagram.
740 For the above example, we need a
741 \begin_inset Formula $3\times3$
744 -matrix of which 5 entries are used for the vertices
745 \begin_inset Formula $U$
749 \begin_inset Formula $X\times_{Z}Y$
753 \begin_inset Formula $X$
757 \begin_inset Formula $Y$
761 \begin_inset Formula $Z$
764 , the other positions remaining empty.
765 In this case, the following matrix determines the layout:
768 \begin_layout LyX-Code
772 \begin_inset Newline newline
780 \begin_inset Newline newline
790 \begin_inset Newline newline
796 \begin_layout Standard
797 The pattern should be familiar from \SpecialChar LaTeX
798 : We see three rows, the first two being
799 terminated by the end-of-line-marker
808 Each line consists of entries, separated by the ampersand
816 \begin_layout Subsection
820 \begin_layout Standard
821 Having entered the vertices, we add arrows between them.
826 -command to produce an arrow is
832 , it is entered into the cell of the matrix where the arrow is to start.
833 The target of the arrow is defined by direction commands
850 These can be combined to a path and enclosed in square brackets.
851 As an example, the arrows from the vertex
852 \begin_inset Formula $U$
855 in the upper left corner down and right to the vertices
856 \begin_inset Formula $X\times_{Z}Y$
860 \begin_inset Formula $Y$
864 \begin_inset Formula $X$
867 are, respectively, defined as
886 Thus the above diagram with all arrows added becomes:
889 \begin_layout LyX-Code
893 \begin_inset Newline newline
907 \begin_inset Newline newline
923 \begin_inset Newline newline
931 \begin_layout LyX-Code
932 \begin_inset Formula $\xymatrix{U\ar[ddr]\ar[drr]\ar[dr]\\
933 & X\times_{Z}Y\ar[d]\ar[r] & X\ar[d]\\
942 \begin_layout LyX-Code
946 \begin_layout LyX-Code
950 \begin_layout Subsection
954 \begin_layout Standard
955 Labels are attached to arrows by affixing them as upper or lower indices
971 defines an arrow going one cell down, two to the right and having the label
973 \begin_inset Formula $\varphi$
977 To attach a label below the arrow, make it a lower index as in
986 This explanation is correct only for arrows pointing to the right.
987 More precisely, imagine looking along the arrow in the direction it is
989 Then an upper index places a label to the left and a lower index places
991 Consequently, an arrow pointing from right to left, such as
1002 \begin_inset Formula $\alpha$
1006 \begin_inset Formula $\beta$
1010 \begin_inset space \thinspace{}
1014 \begin_inset space \space{}
1018 \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.}
1022 Using the character | instead of ^ or _ , it is even possible to place the
1023 label right onto the arrow, obscuring part of its shaft.
1027 \begin_layout Standard
1028 Normally, a label is placed halfway between an arrow's start and target
1030 In the first diagram, the central arrow starting in
1031 \begin_inset Formula $U$
1035 \begin_inset Formula $(x,y)$
1038 in the middle of the arrow's shaft, rather than in the middle between the
1039 two objects it connects.
1040 This is achieved by prefixing the label with a minus sign, here:
1049 \begin_layout LyX-Code
1053 \begin_inset Newline newline
1071 \begin_inset Newline newline
1087 \begin_inset Newline newline
1095 \begin_layout LyX-Code
1096 \begin_inset Formula $\xymatrix{U\ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\
1097 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
1106 \begin_layout Standard
1110 \begin_layout Plain Layout
1119 -pic normally permits labels to be shifted towards the tip or towards the
1120 start of an arrow by prefixing the label with a ratio, such as e.
1121 \begin_inset space \thinspace{}
1125 \begin_inset space \space{}
1134 this works only for labels which are placed on top of the arrow, such
1147 \begin_layout Standard
1148 For labels placed to the left or to the right of the arrow this does not
1154 \begin_layout Plain Layout
1163 -pic code such as e.
1164 \begin_inset space \thinspace{}
1168 \begin_inset space \space{}
1187 is not correctly interpreted by \SpecialChar LyX
1189 Two workarounds are suggested in the last section of this note.
1192 \begin_layout Subsection
1196 \begin_layout Standard
1197 Modification of the design, the form or the positioning of arrows are introduced
1203 This is followed by a pair of matching brackets, where the form of the
1216 indicates, whether we want to modify the design, the or the curvature of
1218 Various modifications can be applied to an arrow at the same time.
1221 \begin_layout Subsubsection
1225 \begin_layout Standard
1226 Various designs such as
1242 are possible for the shaft of an arrow.
1243 These can be combined with various ends and various tips.
1244 In general, the design of an arrow is described by following the command
1255 -sign and a pair of braces {\SpecialChar ldots
1256 } containing characters describing the end,
1257 the shaft and the tip of the arrow.
1258 These characters are chosen to give some form of ASCII-rendering of the
1266 produces an arrow with split end, a dotted shaft and double head.
1267 A number of other arrow designs is given in the table below.
1268 Note that the ends of embedding arrows
1269 \begin_inset Formula $\xymatrix{A\ar@{^{(}->}[r] & B}
1273 are described by raising or lowering opening parentheses, such as in
1280 \begin_layout Standard
1282 \begin_inset Tabular
1283 <lyxtabular version="3" rows="11" columns="2">
1284 <features tabularvalignment="middle">
1285 <column alignment="center" valignment="top" width="0pt">
1286 <column alignment="center" valignment="top">
1288 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1291 \begin_layout Plain Layout
1297 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1300 \begin_layout Plain Layout
1301 Source code in \SpecialChar LyX
1309 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1312 \begin_layout Plain Layout
1313 \begin_inset Formula $\xymatrix{\ \ar[r] & \ }
1322 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1325 \begin_layout Plain Layout
1337 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1340 \begin_layout Plain Layout
1341 \begin_inset Formula $\xymatrix{\ \ar@{-->}[r] & \ }
1350 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1353 \begin_layout Plain Layout
1365 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1368 \begin_layout Plain Layout
1369 \begin_inset Formula $\xymatrix{\ \ar@{..>}[r] & \ }
1378 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1381 \begin_layout Plain Layout
1393 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1396 \begin_layout Plain Layout
1397 \begin_inset Formula $\xymatrix{\ \ar@{~>}[r] & \ }
1406 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1409 \begin_layout Plain Layout
1421 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1424 \begin_layout Plain Layout
1425 \begin_inset Formula $\xymatrix{\ \ar@{->>}[r] & \ }
1434 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1437 \begin_layout Plain Layout
1449 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1452 \begin_layout Plain Layout
1453 \begin_inset Formula $\xymatrix{\ \ar@{-->>}[r] & \ }
1462 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1465 \begin_layout Plain Layout
1477 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1480 \begin_layout Plain Layout
1481 \begin_inset Formula $\xymatrix{\ \ar@{>->>}[r] & \ }
1490 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1493 \begin_layout Plain Layout
1505 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1508 \begin_layout Plain Layout
1509 \begin_inset Formula $\xymatrix{\ \ar@{_{(}->}[r] & \ }
1518 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1521 \begin_layout Plain Layout
1533 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1536 \begin_layout Plain Layout
1537 \begin_inset Formula $\xymatrix{\ \ar@{^{(}->}[r] & \ }
1546 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1549 \begin_layout Plain Layout
1561 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1564 \begin_layout Plain Layout
1565 \begin_inset Formula $\xymatrix{\ \ar@{|-|}[r] & \ }
1574 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1577 \begin_layout Plain Layout
1595 \begin_layout Standard
1597 Following the @-character by either a 2, 3, _ or a ^, we can produce arrows
1598 with double, triple shaft or arrows showing only the lower or upper half
1599 of their tips and ends.
1600 Arrows need not have tips nor ends, as the last example shows:
1603 \begin_layout Standard
1605 \begin_inset Tabular
1606 <lyxtabular version="3" rows="8" columns="2">
1607 <features tabularvalignment="middle">
1608 <column alignment="center" valignment="top">
1609 <column alignment="center" valignment="top">
1611 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1614 \begin_layout Plain Layout
1620 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1623 \begin_layout Plain Layout
1624 Source code for \SpecialChar LyX
1632 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1635 \begin_layout Plain Layout
1636 \begin_inset Formula $\xymatrix{\ \ar@2[r] & \ }
1645 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1648 \begin_layout Plain Layout
1660 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1663 \begin_layout Plain Layout
1664 \begin_inset Formula $\xymatrix{\ \ar@3[r] & \ }
1673 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1676 \begin_layout Plain Layout
1688 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1691 \begin_layout Plain Layout
1692 \begin_inset Formula $\xymatrix{\ \ar@_{->}[r] & \ }
1701 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1704 \begin_layout Plain Layout
1716 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1719 \begin_layout Plain Layout
1720 \begin_inset Formula $\xymatrix{\ \ar@^{->}[r] & \ }
1729 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1732 \begin_layout Plain Layout
1744 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1747 \begin_layout Plain Layout
1748 \begin_inset Formula $\xymatrix{\ \ar@^{>>->>}[r] & \ }
1757 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1760 \begin_layout Plain Layout
1765 ar@^{>\SpecialChar ligaturebreak
1766 >->\SpecialChar ligaturebreak
1774 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1777 \begin_layout Plain Layout
1778 \begin_inset Formula $\xymatrix{\ \ar@{^{<}-_{>}}[r] & \ }
1787 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1790 \begin_layout Plain Layout
1802 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1805 \begin_layout Plain Layout
1806 \begin_inset Formula $\xymatrix{\ \ar@2{--}[r] & \ }
1815 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1818 \begin_layout Plain Layout
1836 \begin_layout Subsubsection
1837 Designing your own arrows
1840 \begin_layout Standard
1841 Within certain limits there is even a way to design your own arrows.
1842 Using some the characters
1846 one can even design one's own arrow tips using the
1852 command in the preamble.
1853 For explanations, we refer to the
1859 \begin_layout Plain Layout
1870 -manual, from which we take the example:
1873 \begin_layout Standard
1878 newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
1883 \begin_layout Standard
1885 This defines a new arrow tip, referred to as
1895 and which displays correctly in \SpecialChar LyX
1897 \begin_inset Formula
1899 \xymatrix{A\ar@{-|>}[r] & \ \ B}
1907 \begin_layout Subsection
1911 \begin_layout Standard
1912 Arrows are shifted sideways with the modifier
1917 \begin_inset Formula $\ldots$
1924 where the ellipsis is replaced by a positive or negative measure.
1925 For instance, to design a pair of mutually opposing arrows between two
1926 nodes, we shift them to see them apart.
1927 Note that the direction of the shift (positive) is to the left if one looks
1932 \begin_layout Standard
1948 \begin_layout Standard
1951 \begin_inset Formula
1953 \xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1961 \begin_layout Subsubsection
1962 Inline or centered diagrams
1965 \begin_layout Standard
1966 Arrows and diagrams can be used inline, such as this one:
1967 \begin_inset Formula $\xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1972 When their code is written inside \SpecialChar LyX
1973 as above, select it and choose either
1978 for inline appearance or
1983 Diagrams constructed inline can later be centered, or, conversely, centered
1984 diagrams can be changed to inline formulas with
1986 Edit\SpecialChar menuseparator
1991 \SpecialChar menuseparator
1992 Change Formula Type.
1995 \begin_layout Subsection
1999 \begin_layout Standard
2000 There are two simple methods to make arrows bend.
2001 The first is giving an explicit value by which the midpoint of the arrow's
2002 shaft is raised or depressed, the other is by forcing the arrow to leave
2003 its origin in a prescribed compass direction and to make him enter the
2004 target at another direction.
2005 The necessary bending of the arrow is determined automatically.
2006 We describe both methods.
2009 \begin_layout Subsubsection
2013 \begin_layout Standard
2014 For bending arrows we use the modifier @/
2015 \begin_inset Formula $\ldots$
2019 The ellipsis stands for a \SpecialChar TeX
2020 -measure which needs to be entered as a lower
2026 , we could simply write, e.
2027 \begin_inset space \thinspace{}
2031 \begin_inset space \space{}
2040 for an arrow bending
2044 downwards, this cannot directly be done in \SpecialChar LyX
2046 It is necessary, to enclose the measure in a pair of braces, such as e.
2047 \begin_inset space \thinspace{}
2051 \begin_inset space \space{}
2061 As an example, here are two opposing arrows between
2062 \begin_inset Formula $A$
2066 \begin_inset Formula $B$
2069 , each bending by .5 pica, given by the following source code:
2072 \begin_layout Standard
2084 \begin_layout Standard
2085 \begin_inset Formula
2087 \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]}
2095 \begin_layout Subsubsection
2096 Specifying exit- and entrance directions
2099 \begin_layout Standard
2100 An alternative for making arrows bend is by specifying their compass direction
2101 as they are leaving their source and their direction from which they enter
2103 Instead of north, north-east, east, etc., the directions are named
2135 , standing for up, up-right, right, down-right, etc..
2136 A direction is specified as @(
2148 stands for the direction the first object is left and
2152 stands for the direction from which the target is entered.
2153 As an example, we show some bending arrows and a loop, which arises when
2154 we do not specify a target for an arrow, just its incoming and outgoing
2158 \begin_layout Standard
2159 \begin_inset Formula
2161 \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\
2171 \begin_layout LyX-Code
2179 \begin_inset Newline newline
2189 \begin_inset Newline newline
2197 \begin_layout Subsection
2201 \begin_layout Standard
2202 The above example is reminiscent of an automata diagram, except that in
2203 such a diagram states would be enclosed in small circles, with double circles
2204 denoting final states.
2208 \begin_layout Subsubsection
2212 \begin_layout Standard
2217 \begin_layout Plain Layout
2226 -pic, entries can obtain a single or a double frame, such as
2227 \begin_inset Formula $\xymatrix{*+[F]{A}}
2232 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2236 by prefixing an entry with
2244 and enclosing the portion of the entry to be framed in braces.
2245 Normally, the frame will be very tight so that it must be widened by prefixing
2255 Round frames, such as
2256 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2261 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2265 are obtained by specifying the shape as
2270 So the latter figure was constructed as *++[o][F=]{B}.
2271 This way, the following automaton
2274 \begin_layout Standard
2275 \begin_inset Formula
2277 \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]}
2285 \begin_layout Standard
2290 \begin_layout LyX-Code
2300 \begin_layout LyX-Code
2306 \begin_layout LyX-Code
2314 \begin_layout LyX-Code
2318 \begin_layout Standard
2319 The \SpecialChar LaTeX
2331 will make a certain entry style the default, that can, of course be overridden
2332 for individual entries.
2337 entrymodifiers={++[o][F-]}
2339 , all following entries inside
2343 \begin_layout Plain Layout
2352 -matrices would be encircled.
2355 \begin_layout Subsubsection
2359 \begin_layout Standard
2360 Framing a whole rectangle inside an xymatrix is done with the macro pair
2380 The dimension of the rectangle is given as a dotted pair
2381 \begin_inset Formula $P_{0}.P_{1}$
2384 of points denoting the top left and lower right corners of the rectangle.
2385 Each point, in turn,is given as a doubly quoted comma separated pair
2386 \begin_inset Quotes eld
2390 \begin_inset Formula $x,y$
2394 \begin_inset Quotes erd
2398 \begin_inset Formula $x$
2402 \begin_inset Formula $y$
2406 These are followed by the framing commands, to produce figures such as
2408 \begin_inset Formula
2410 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2411 C & \save"1,1"."1,2"*++[F]\frm{}\restore
2428 save"1,1"."2,1"*+[F=]
2441 produces the doubly framed rectangle, and the code for the extra wide horizonta
2453 save"1,1"."1,2"*++[F]
2467 This code can be placed in arbitrary cells of the xymatrix.
2471 \begin_layout Section
2472 Using \SpecialChar LyX
2474 \begin_inset CommandInset label
2476 name "sec:math-editor"
2483 \begin_layout Standard
2484 As an alternative to writing the
2488 code, then transforming it into a math-editing environment by marking it
2497 , one may construct and modify the whole xypic-diagram inside \SpecialChar LyX
2499 We describe the editing steps for a figure just like the one above.
2503 \begin_layout Subsection
2504 Caveat - how to enter braces
2507 \begin_layout Standard
2508 Recall that in \SpecialChar LyX
2509 's math-editor any pair of braces
2517 that are to enclose a macro-parameter must be entered by typing just
2524 The closing brace is automatically supplied and in between a box into which
2525 to the parameter is entered.
2530 \begin_layout Plain Layout
2539 -diagrams, this applies in particular to arrow modifications that are normally
2549 with the ellipsis standing for the description of end, shaft and tip of
2551 Inside the math-editor, enter just
2557 and let \SpecialChar LyX
2558 provide the closing brace and the box into which to enter the
2559 description of the arrow.
2562 \begin_layout Standard
2563 Braces that are entered without the backslash
2569 will just appear as typed, but cannot be used to receive a macro parameter.
2570 They are useful, for instance to denote sets, e.
2571 \begin_inset space \thinspace{}
2575 \begin_inset space \space{}
2589 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2595 \begin_layout Subsection
2596 Setting up the matrix
2599 \begin_layout Standard
2608 open a formula environment and enter:
2616 \begin_inset Formula $\times$
2623 \begin_layout Plain Layout
2633 Add extra rows by typing
2637 and add columns by typing
2643 \begin_layout Standard
2644 At any time, further rows or columns can be entered or deleted using commands
2647 Edit\SpecialChar menuseparator
2651 their shortcuts, beginning with
2655 for the column commands or
2659 for the row commands.
2660 A more direct way uses the icons in the math toolbar once it has been activated
2663 View\SpecialChar menuseparator
2667 \begin_layout Subsection
2668 Entering nodes, arrows and labels
2671 \begin_layout Standard
2672 Type the nodes into the correct positions of the matrix.
2673 If you move the cursor out of the matrix, you should see a first rendering
2675 Next, add the arrows at the nodes from where they should emanate by typing
2692 can be any path made up from the characters
2709 Make sure that the path indeed leads to an existing node within the matrix.
2710 Otherwise, the figure will not display when the cursor leaves the editing
2714 \begin_layout Standard
2715 Next, label the arrows by attaching a label text as upper or lower indices
2716 to the end of the arrow's path.
2717 As always in \SpecialChar LyX
2718 's math editor, an underscore
2722 opens a box for a lower index and a
2726 followed by a space opens a box for an upper index.
2727 You can enter any \SpecialChar LaTeX
2731 \begin_layout Subsection
2735 \begin_layout Standard
2736 Finally, you can modify the appearance of the arrows by entering @-modifiers
2767 The above caveat applies to the first form only.
2768 It must be entered as
2774 with the arrow description entered inside the \SpecialChar LyX
2776 If this box remains empty, you have specified an empty arrow.
2777 This is a useful construction, too, as you will see in the next section.
2781 \begin_layout Standard
2782 The other modifiers,
2810 are typed as shown with the arrow description replacing the ellipsis.
2811 The code for bending arrows, which in
2840 is any valid \SpecialChar TeX
2841 -measure that should be entered as upper or lower index to
2843 Make sure that the ending slash does not end up being part of the upper
2847 \begin_layout Subsection
2848 What if something goes wrong
2851 \begin_layout Standard
2852 When constructing a diagram, you should at times check it by just moving
2853 the cursor out of the editing area to see whether instant preview can successfu
2854 lly convert it into graphical output.
2855 If this does not happen, it may either be that instant preview for some
2856 reason is not aware that it should retranslate the graphics.
2857 Moving the cursor into the editing area and out again sometimes wakes up
2861 \begin_layout Standard
2862 A more serious reason could be a syntactical error in your input (in that
2863 case, the math edition area disappears completely).
2864 If necessary, undo the last editing steps, using
2868 , or try to translate the \SpecialChar LyX
2879 View\SpecialChar menuseparator
2883 There should be some error generated, which hopefully gives you a hint
2884 as to the source of the mistake.
2887 \begin_layout Section
2891 \begin_layout Standard
2892 Certain things do not work correctly inside \SpecialChar LyX
2894 The ones that we (used to) miss most are the horizontal and vertical scaling
2895 of diagrams, and the correct positioning of arrows.
2896 There are some workarounds that we are explaining here.
2900 \begin_layout Subsection
2901 Horizontal and vertical scaling
2904 \begin_layout Standard
2905 It is often convenient to stretch the horizontal or the vertical dimensions
2906 of an entire diagram by using spacing commands for rows and/or columns.
2911 \begin_layout Plain Layout
2921 \begin_inset CommandInset citation
2942 \begin_layout Plain Layout
2951 -matrix with row spacing of 1
2952 \begin_inset space ~
2972 allows to modify the space between columns.
2973 Unfortunately, one cannot type
2974 \begin_inset Quotes eld
2984 \begin_inset Quotes erd
2987 into a formula to get the desired matrix because the @-character is interpreted
2996 But there are two other ways of getting the desired matrix:
2999 \begin_layout Itemize
3001 \begin_inset space \space{}
3010 as normal document text, then either highlight it and press
3016 to get a formula, or copy it into an existing formula.
3017 You can now continue as normal.
3018 \begin_inset Newline newline
3022 \begin_inset Note Greyedout
3025 \begin_layout Plain Layout
3030 This method only works for single spacing settings, so using
3031 \begin_inset Newline newline
3044 xymatrix@M=1pt@C=1dd
3047 The method also don't work if you use '!' to get a fixed grid with a defined
3049 \begin_inset space \space{}
3070 \begin_inset Newline newline
3073 For the following matrix, the command
3080 \begin_inset Formula
3082 \xymatrix@C=9pc{A\ar[r]\ar[d] & B\\
3083 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3092 \begin_layout Itemize
3096 \begin_layout Plain Layout
3106 \begin_inset space ~
3109 stores the values for row-spacing and column-spacing in the variables
3110 \begin_inset Newline newline
3126 So one can add the following macro to the preamble (
3128 Layout\SpecialChar menuseparator
3129 Document\SpecialChar menuseparator
3136 \begin_layout LyX-Code
3144 \begin_layout LyX-Code
3149 xymatrixrowsep@{#1}}
3152 \begin_layout Standard
3159 can be defined correspondingly by replacing
3172 Now, a figure can be scaled by entering
3174 xyR{ into the formula before the
3178 \begin_layout Plain Layout
3188 Place the cursor inside the matrix, just before the first entry.
3206 Don't forget the backslashes and remember, that the closing brace is automatica
3207 lly supplied by \SpecialChar LyX
3209 Inside the braces enter the dimensions.
3210 \begin_inset Newline newline
3214 \begin_inset Note Greyedout
3217 \begin_layout Plain Layout
3222 these commands affect all following
3226 \begin_layout Plain Layout
3236 Therefore don't forget to reset the values to default after the usage of
3249 \begin_inset Newline newline
3257 Here you see a diagram which is squashed vertically and stretched horizontally
3267 \begin_inset Formula
3269 \xyR{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
3270 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3277 \begin_inset Formula $\xyR{2pc}\xyC{2pc}$
3281 \begin_inset Note Note
3284 \begin_layout Plain Layout
3294 \begin_layout Subsection
3298 \begin_layout Standard
3303 \begin_layout Plain Layout
3312 -command allows the correct positioning of labels along the shaft of arrows.
3313 This feature is sometimes necessary, when the default position of a label
3314 would otherwise clutter the picture, or would even coincide with other
3315 items, such as the intersection of the arrows in the figure below.
3316 In order to shift a label position alongside the shaft of an arrow,
3320 \begin_layout Plain Layout
3330 \begin_inset space ~
3333 allows to prefix the label by a decimal number in parentheses, specifying
3334 the fraction of distance alongside the arrow where the label is to be placed.
3335 For instance, the code
3343 , will place the label on the shaft, but only about one third of the way.
3347 \begin_layout Standard
3348 Doing the same with labels above or below arrows as
3364 , does not work from inside \SpecialChar LyX
3366 Instead, one has to replace the hat-symbol ^, resp.
3367 the underscore _ , by the macros
3401 It is, in fact, possible to enter several labels this way and those labels
3402 are placed correctly, even if the arrow bends.
3403 In the following figure, the bending arrow with its four labels has been
3427 \begin_layout Standard
3428 \begin_inset Formula
3430 \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}}\\
3431 \circ\ar[ur]\sb(0.3)\phi & \bullet
3440 \begin_layout Subsection
3441 Invisible stretched arrows
3444 \begin_layout Standard
3445 A more general trick uses invisible arrows to place any object almost anywhere
3447 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3448 a decimal stretching ratio, e.
3449 \begin_inset space \thinspace{}
3453 \begin_inset space \space{}
3465 Attach a label to this invisible arrow.
3469 \begin_layout Standard
3470 Thus, the down pointing arrow with its label
3471 \begin_inset Formula $\varphi$
3474 at (0.3) of its way along the shaft might as well have been produced by
3475 adding to the regular arrow
3482 \begin_inset Formula $\varphi$
3493 , reaching only 0.6 of the way.
3494 Its label will now appear at 0.3 of the way of the original visible arrow.
3498 \begin_layout Standard
3499 This workaround has two minor drawbacks: First, it does not work with bending
3501 Secondly, prolonging an invisible arrow beyond the normal dimension of
3502 the figure will invisibly extend the figure box, and thereby cause too
3503 much vertical space between the figure and the preceding or the following
3508 \begin_layout Standard
3509 Nevertheless, invisible arrows are an important tool, since they can, in
3510 principle, be used to place information at any chosen place in a diagram.
3511 In the above figure, for instance, we have used an invisible arrow to carry
3518 as label and at the earlier figure we had used an invisible arrow to carry
3520 \begin_inset Quotes eld
3528 \begin_inset Quotes erd
3531 into the center of the figure.
3534 \begin_layout Subsection
3542 \begin_layout Standard
3543 Here we have focused only on the
3549 command, which is just one of the features available in Kris Rose's amazing
3555 \begin_layout Plain Layout
3573 \begin_layout Plain Layout
3585 \begin_inset CommandInset citation
3591 demonstrates many of the advanced possibilities of that package.
3592 Beware, that its style is rather terse and you will likely need a lot of
3593 experimenting and modifying the many worked examples.
3595 \begin_inset CommandInset citation
3605 \begin_layout Plain Layout
3614 -pic to make braids, cobordism, string diagrams, and much more.
3615 You might want to look on
3619 example shipped with \SpecialChar LyX
3620 , which demonstrates how to use more advanced
3624 \begin_layout Plain Layout
3637 \begin_inset space ~
3649 \begin_layout Standard
3650 \begin_inset Newpage newpage
3656 \begin_layout Bibliography
3657 \begin_inset CommandInset bibitem
3658 LatexCommand bibitem
3668 \begin_layout Plain Layout
3682 \begin_inset Newline newline
3686 \begin_inset Flex URL
3689 \begin_layout Plain Layout
3691 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyguide.pdf
3699 \begin_layout Bibliography
3700 \begin_inset CommandInset bibitem
3701 LatexCommand bibitem
3702 key "xypic reference"
3707 Rose and Ross Moore:
3711 \begin_layout Plain Layout
3722 -pic Reference Manual
3725 \begin_inset Newline newline
3729 \begin_inset Flex URL
3732 \begin_layout Plain Layout
3734 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyrefer.pdf
3742 \begin_layout Bibliography
3743 \begin_inset CommandInset bibitem
3744 LatexCommand bibitem
3749 Homepage of the package
3753 \begin_layout Plain Layout
3767 \begin_inset Flex URL
3770 \begin_layout Plain Layout
3772 http://www.ctan.org/pkg/xypic
3780 \begin_layout Bibliography
3781 \begin_inset CommandInset bibitem
3782 LatexCommand bibitem
3783 key "instant-preview"
3787 Homepage of preview-latex:
3788 \begin_inset Newline newline
3792 \begin_inset Flex URL
3795 \begin_layout Plain Layout
3797 http://www.gnu.org/software/auctex/preview-latex.html
3805 \begin_layout Bibliography
3806 \begin_inset CommandInset bibitem
3807 LatexCommand bibitem
3812 Homepage of AUC\SpecialChar TeX
3814 \begin_inset Flex URL
3817 \begin_layout Plain Layout
3819 http://www.gnu.org/software/auctex/
3827 \begin_layout Bibliography
3828 \begin_inset CommandInset bibitem
3829 LatexCommand bibitem
3838 \begin_layout Plain Layout
3853 tutorial with an archive of examples
3856 \begin_inset Newline newline
3860 \begin_inset Flex URL
3863 \begin_layout Plain Layout
3865 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyguide.pdf