1 #LyX 2.3 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 \use_dash_ligatures false
69 \default_output_format default
71 \bibtex_command default
72 \index_command default
76 \pdf_title "Using XY-pc in LyX"
77 \pdf_author "H. Peter Gumm"
78 \pdf_subject "LyX's XY-pic manual"
79 \pdf_keywords "LyX, documentation"
81 \pdf_bookmarksnumbered true
82 \pdf_bookmarksopen true
83 \pdf_bookmarksopenlevel 2
88 \pdf_pdfusetitle false
89 \pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue,pdfpagelayout=OneColumn, pdfnewwindow=true,pdfstartview=XYZ, plainpages=false"
92 \use_package amsmath 1
93 \use_package amssymb 1
96 \use_package mathdots 1
97 \use_package mathtools 1
99 \use_package stackrel 1
100 \use_package stmaryrd 1
101 \use_package undertilde 1
103 \cite_engine_type default
107 \paperorientation portrait
111 \notefontcolor #0000ff
118 \paragraph_separation indent
119 \paragraph_indentation default
121 \math_numbering_side default
122 \quotes_style english
125 \paperpagestyle default
126 \tracking_changes false
127 \output_changes false
141 \begin_layout Plain Layout
150 -pic in \SpecialChar LyX
159 \begin_layout Abstract
160 With the recent versions of \SpecialChar LyX
165 -style installed in the \SpecialChar LaTeX
166 -System, the graph drawing package
172 \begin_layout Plain Layout
183 -pic can be conveniently used inside \SpecialChar LyX
185 Diagrams can be edited and displayed inside the main \SpecialChar LyX
187 Here, we shall describe how to use the
197 inside \SpecialChar LyX
198 in order to draw, to edit and to preview diagrams as typically
199 used in category theory, algebra, and related fields.
203 \begin_layout Abstract
204 \begin_inset CommandInset toc
205 LatexCommand tableofcontents
212 \begin_layout Section
216 \begin_layout Standard
221 -package has long served as a convenient tool for easily constructing graphs
222 and diagrams in \SpecialChar LaTeX
224 Unfortunately, its use in \SpecialChar LyX
225 had long been restricted to the infamous \SpecialChar TeX
227 boxes, meaning that the \SpecialChar LyX
228 editor could only display the \SpecialChar LaTeX
230 the finished diagram.
235 -style of \SpecialChar LaTeX
236 which is part of the AUC\SpecialChar TeX
238 \begin_inset CommandInset citation
245 , finally enables the editing and displaying of
249 -diagrams, constructed, displayed and interactively edited inside \SpecialChar LyX
253 \begin_layout Standard
254 \begin_inset VSpace defskip
260 \begin_layout Standard
262 \begin_inset Graphics
263 filename xyfigure.png
271 \begin_layout Standard
272 \begin_inset VSpace defskip
278 \begin_layout Standard
279 In this note, we describe how
283 \begin_layout Plain Layout
292 -pic can be used from inside \SpecialChar LyX
293 , how diagrams can be created and edited.
294 We have tested the following using \SpecialChar LyX
295 versions 1.3.7 up to 1.6, running under
297 \begin_inset space \thinspace{}
300 XP and under Windows Vista.
304 \begin_layout Standard
305 There are two modes of operations: For a start, and for some first tests,
306 it may be easiest to first enter the
310 \begin_layout Plain Layout
319 -pic code inside the \SpecialChar LyX
320 -window, select it all and convert it to a graphical
321 representation by pressing
334 \begin_layout Plain Layout
343 -pic more frequently, or if you want to modify your initial figure, you
344 will want to assemble and modify your figures using \SpecialChar LyX
349 \begin_layout Standard
350 Once the cursor is moved over a diagram, this is displayed as an array of
351 nodes and arrow-commands.
352 These can be changed interactively.
353 When the cursor leaves the editing area, the diagram reappears.
357 \begin_layout Standard
358 In the first two sections of this documentation, we explain how to use \SpecialChar LyX
360 in the first mentioned mode and we introduce all
364 \begin_layout Plain Layout
373 -pic features that might be of use for drawing commutative diagrams, graphs
376 \begin_inset CommandInset ref
378 reference "sec:math-editor"
382 explains how to use the
386 \begin_layout Plain Layout
395 -pic commands inside a math-editing area.
399 \begin_layout Standard
400 It is not our intention to write another introduction to
404 \begin_layout Plain Layout
413 -pic, rather our motivation is to give an introduction how the most important
414 commands work inside \SpecialChar LyX
415 , since the keystrokes as explained in the
419 \begin_layout Plain Layout
429 \begin_inset CommandInset citation
436 will not always function correctly inside \SpecialChar LyX
441 \begin_layout Section
445 \begin_layout Standard
446 The following requires that the \SpecialChar LaTeX
455 are installed in the \SpecialChar LaTeX
457 They are available from CTAN, see at
458 \begin_inset CommandInset citation
460 key "instant-preview"
467 \begin_inset CommandInset citation
475 After freshly installing them, it may be necessary, to run
477 Tools\SpecialChar menuseparator
480 from the main \SpecialChar LyX
482 The steps to a first diagram output in \SpecialChar LyX
486 \begin_layout Enumerate
493 \begin_layout Enumerate
494 Open \SpecialChar LyX
497 Tools\SpecialChar menuseparator
498 Preferences\SpecialChar menuseparator
499 Look and Feel\SpecialChar menuseparator
509 \begin_layout Enumerate
512 Document\SpecialChar menuseparator
513 Settings\SpecialChar menuseparator
522 Use AMS Math package automatically
531 \begin_layout Enumerate
536 works by opening a \SpecialChar LyX
537 -document and entering any math-formula, e.
538 \begin_inset space \thinspace{}
542 \begin_inset space \space{}
546 \begin_inset Formula $a+b=c$
553 \begin_layout Enumerate
554 Move the cursor out of the formula, and watch it change its appearance to
555 look just like in the finished DVI- or PostScript document.
560 \begin_layout Enumerate
565 \begin_layout Plain Layout
580 \begin_layout Enumerate
581 Inside your \SpecialChar LyX
582 -Document, enter the text
585 \begin_inset Newline newline
597 \begin_layout Enumerate
598 Select the whole text and choose
600 Insert\SpecialChar menuseparator
601 Math\SpecialChar menuseparator
604 , or use the corresponding keyboard shortcut
612 \begin_layout Enumerate
613 Move the mouse cursor out of the editing box and wait for a split second
614 to see an arrow appear:
615 \begin_inset Formula $\xymatrix{A\ar[r] & B}
623 \begin_layout Section
627 \begin_layout Standard
628 The following diagram, which is taken from the documentation of
632 \begin_layout Plain Layout
642 \begin_inset CommandInset citation
649 by its creator Kristoffer H.
650 Rose, will provide an example for many of the features available with that
655 \begin_layout LyX-Code
659 \begin_inset Newline newline
671 \begin_inset Newline newline
681 \begin_inset Newline newline
697 \begin_inset Newline newline
705 \begin_layout LyX-Code
709 \begin_layout Standard
710 Again, to turn this code into a graphical output, select it all at once
718 up to the closing brace \SpecialChar ldots
723 and turn it into display-math as explained above.
724 A moment after the cursor leaves the math-area, you should see the diagram
725 in its full graphical glory as shown below.
729 \begin_layout Standard
730 \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\
731 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
740 \begin_layout Subsection
741 The matrix layout of diagrams
744 \begin_layout Standard
749 uses a matrix to define the layout of the vertices of a diagram.
750 For the above example, we need a
751 \begin_inset Formula $3\times3$
754 -matrix of which 5 entries are used for the vertices
755 \begin_inset Formula $U$
759 \begin_inset Formula $X\times_{Z}Y$
763 \begin_inset Formula $X$
767 \begin_inset Formula $Y$
771 \begin_inset Formula $Z$
774 , the other positions remaining empty.
775 In this case, the following matrix determines the layout:
778 \begin_layout LyX-Code
782 \begin_inset Newline newline
790 \begin_inset Newline newline
800 \begin_inset Newline newline
806 \begin_layout Standard
807 The pattern should be familiar from \SpecialChar LaTeX
808 : We see three rows, the first two being
809 terminated by the end-of-line-marker
818 Each line consists of entries, separated by the ampersand
826 \begin_layout Subsection
830 \begin_layout Standard
831 Having entered the vertices, we add arrows between them.
836 -command to produce an arrow is
842 , it is entered into the cell of the matrix where the arrow is to start.
843 The target of the arrow is defined by direction commands
860 These can be combined to a path and enclosed in square brackets.
861 As an example, the arrows from the vertex
862 \begin_inset Formula $U$
865 in the upper left corner down and right to the vertices
866 \begin_inset Formula $X\times_{Z}Y$
870 \begin_inset Formula $Y$
874 \begin_inset Formula $X$
877 are, respectively, defined as
896 Thus the above diagram with all arrows added becomes:
899 \begin_layout LyX-Code
903 \begin_inset Newline newline
917 \begin_inset Newline newline
933 \begin_inset Newline newline
941 \begin_layout LyX-Code
942 \begin_inset Formula $\xymatrix{U\ar[ddr]\ar[drr]\ar[dr]\\
943 & X\times_{Z}Y\ar[d]\ar[r] & X\ar[d]\\
952 \begin_layout LyX-Code
956 \begin_layout LyX-Code
960 \begin_layout Subsection
964 \begin_layout Standard
965 Labels are attached to arrows by affixing them as upper or lower indices
981 defines an arrow going one cell down, two to the right and having the label
983 \begin_inset Formula $\varphi$
987 To attach a label below the arrow, make it a lower index as in
996 This explanation is correct only for arrows pointing to the right.
997 More precisely, imagine looking along the arrow in the direction it is
999 Then an upper index places a label to the left and a lower index places
1001 Consequently, an arrow pointing from right to left, such as
1012 \begin_inset Formula $\alpha$
1016 \begin_inset Formula $\beta$
1020 \begin_inset space \thinspace{}
1024 \begin_inset space \space{}
1028 \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.}
1032 Using the character | instead of ^ or _ , it is even possible to place the
1033 label right onto the arrow, obscuring part of its shaft.
1037 \begin_layout Standard
1038 Normally, a label is placed halfway between an arrow's start and target
1040 In the first diagram, the central arrow starting in
1041 \begin_inset Formula $U$
1045 \begin_inset Formula $(x,y)$
1048 in the middle of the arrow's shaft, rather than in the middle between the
1049 two objects it connects.
1050 This is achieved by prefixing the label with a minus sign, here:
1059 \begin_layout LyX-Code
1063 \begin_inset Newline newline
1081 \begin_inset Newline newline
1097 \begin_inset Newline newline
1105 \begin_layout LyX-Code
1106 \begin_inset Formula $\xymatrix{U\ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\
1107 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
1116 \begin_layout Standard
1120 \begin_layout Plain Layout
1129 -pic normally permits labels to be shifted towards the tip or towards the
1130 start of an arrow by prefixing the label with a ratio, such as e.
1131 \begin_inset space \thinspace{}
1135 \begin_inset space \space{}
1144 this works only for labels which are placed on top of the arrow, such
1157 \begin_layout Standard
1158 For labels placed to the left or to the right of the arrow this does not
1164 \begin_layout Plain Layout
1173 -pic code such as e.
1174 \begin_inset space \thinspace{}
1178 \begin_inset space \space{}
1197 is not correctly interpreted by \SpecialChar LyX
1199 Two workarounds are suggested in the last section of this note.
1202 \begin_layout Subsection
1206 \begin_layout Standard
1207 Modification of the design, the form or the positioning of arrows are introduced
1213 This is followed by a pair of matching brackets, where the form of the
1226 indicates, whether we want to modify the design, the or the curvature of
1228 Various modifications can be applied to an arrow at the same time.
1231 \begin_layout Subsubsection
1235 \begin_layout Standard
1236 Various designs such as
1252 are possible for the shaft of an arrow.
1253 These can be combined with various ends and various tips.
1254 In general, the design of an arrow is described by following the command
1265 -sign and a pair of braces {\SpecialChar ldots
1266 } containing characters describing the end,
1267 the shaft and the tip of the arrow.
1268 These characters are chosen to give some form of ASCII-rendering of the
1276 produces an arrow with split end, a dotted shaft and double head.
1277 A number of other arrow designs is given in the table below.
1278 Note that the ends of embedding arrows
1279 \begin_inset Formula $\xymatrix{A\ar@{^{(}->}[r] & B}
1283 are described by raising or lowering opening parentheses, such as in
1290 \begin_layout Standard
1292 \begin_inset Tabular
1293 <lyxtabular version="3" rows="11" columns="2">
1294 <features tabularvalignment="middle">
1295 <column alignment="center" valignment="top" width="0pt">
1296 <column alignment="center" valignment="top">
1298 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1301 \begin_layout Plain Layout
1307 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1310 \begin_layout Plain Layout
1311 Source code in \SpecialChar LyX
1319 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1322 \begin_layout Plain Layout
1323 \begin_inset Formula $\xymatrix{\ \ar[r] & \ }
1332 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1335 \begin_layout Plain Layout
1347 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1350 \begin_layout Plain Layout
1351 \begin_inset Formula $\xymatrix{\ \ar@{-->}[r] & \ }
1360 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1363 \begin_layout Plain Layout
1375 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1378 \begin_layout Plain Layout
1379 \begin_inset Formula $\xymatrix{\ \ar@{..>}[r] & \ }
1388 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1391 \begin_layout Plain Layout
1403 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1406 \begin_layout Plain Layout
1407 \begin_inset Formula $\xymatrix{\ \ar@{~>}[r] & \ }
1416 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1419 \begin_layout Plain Layout
1431 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1434 \begin_layout Plain Layout
1435 \begin_inset Formula $\xymatrix{\ \ar@{->>}[r] & \ }
1444 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1447 \begin_layout Plain Layout
1459 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1462 \begin_layout Plain Layout
1463 \begin_inset Formula $\xymatrix{\ \ar@{-->>}[r] & \ }
1472 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1475 \begin_layout Plain Layout
1487 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1490 \begin_layout Plain Layout
1491 \begin_inset Formula $\xymatrix{\ \ar@{>->>}[r] & \ }
1500 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1503 \begin_layout Plain Layout
1515 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1518 \begin_layout Plain Layout
1519 \begin_inset Formula $\xymatrix{\ \ar@{_{(}->}[r] & \ }
1528 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1531 \begin_layout Plain Layout
1543 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1546 \begin_layout Plain Layout
1547 \begin_inset Formula $\xymatrix{\ \ar@{^{(}->}[r] & \ }
1556 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1559 \begin_layout Plain Layout
1571 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1574 \begin_layout Plain Layout
1575 \begin_inset Formula $\xymatrix{\ \ar@{|-|}[r] & \ }
1584 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1587 \begin_layout Plain Layout
1605 \begin_layout Standard
1607 Following the @-character by either a 2, 3, _ or a ^, we can produce arrows
1608 with double, triple shaft or arrows showing only the lower or upper half
1609 of their tips and ends.
1610 Arrows need not have tips nor ends, as the last example shows:
1613 \begin_layout Standard
1615 \begin_inset Tabular
1616 <lyxtabular version="3" rows="8" columns="2">
1617 <features tabularvalignment="middle">
1618 <column alignment="center" valignment="top">
1619 <column alignment="center" valignment="top">
1621 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1624 \begin_layout Plain Layout
1630 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1633 \begin_layout Plain Layout
1634 Source code for \SpecialChar LyX
1642 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1645 \begin_layout Plain Layout
1646 \begin_inset Formula $\xymatrix{\ \ar@2[r] & \ }
1655 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1658 \begin_layout Plain Layout
1670 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1673 \begin_layout Plain Layout
1674 \begin_inset Formula $\xymatrix{\ \ar@3[r] & \ }
1683 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1686 \begin_layout Plain Layout
1698 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1701 \begin_layout Plain Layout
1702 \begin_inset Formula $\xymatrix{\ \ar@_{->}[r] & \ }
1711 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1714 \begin_layout Plain Layout
1726 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1729 \begin_layout Plain Layout
1730 \begin_inset Formula $\xymatrix{\ \ar@^{->}[r] & \ }
1739 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1742 \begin_layout Plain Layout
1754 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1757 \begin_layout Plain Layout
1758 \begin_inset Formula $\xymatrix{\ \ar@^{>>->>}[r] & \ }
1767 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1770 \begin_layout Plain Layout
1775 ar@^{>\SpecialChar ligaturebreak
1776 >->\SpecialChar ligaturebreak
1784 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1787 \begin_layout Plain Layout
1788 \begin_inset Formula $\xymatrix{\ \ar@{^{<}-_{>}}[r] & \ }
1797 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1800 \begin_layout Plain Layout
1812 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1815 \begin_layout Plain Layout
1816 \begin_inset Formula $\xymatrix{\ \ar@2{--}[r] & \ }
1825 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1828 \begin_layout Plain Layout
1846 \begin_layout Subsubsection
1847 Designing your own arrows
1850 \begin_layout Standard
1851 Within certain limits there is even a way to design your own arrows.
1852 Using some the characters
1856 one can even design one's own arrow tips using the
1862 command in the preamble.
1863 For explanations, we refer to the
1869 \begin_layout Plain Layout
1880 -manual, from which we take the example:
1883 \begin_layout Standard
1888 newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
1893 \begin_layout Standard
1895 This defines a new arrow tip, referred to as
1905 and which displays correctly in \SpecialChar LyX
1907 \begin_inset Formula
1909 \xymatrix{A\ar@{-|>}[r] & \ \ B}
1917 \begin_layout Subsection
1921 \begin_layout Standard
1922 Arrows are shifted sideways with the modifier
1927 \begin_inset Formula $\ldots$
1934 where the ellipsis is replaced by a positive or negative measure.
1935 For instance, to design a pair of mutually opposing arrows between two
1936 nodes, we shift them to see them apart.
1937 Note that the direction of the shift (positive) is to the left if one looks
1942 \begin_layout Standard
1958 \begin_layout Standard
1961 \begin_inset Formula
1963 \xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1971 \begin_layout Subsubsection
1972 Inline or centered diagrams
1975 \begin_layout Standard
1976 Arrows and diagrams can be used inline, such as this one:
1977 \begin_inset Formula $\xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1982 When their code is written inside \SpecialChar LyX
1983 as above, select it and choose either
1988 for inline appearance or
1993 Diagrams constructed inline can later be centered, or, conversely, centered
1994 diagrams can be changed to inline formulas with
1996 Edit\SpecialChar menuseparator
2001 \SpecialChar menuseparator
2002 Change Formula Type.
2005 \begin_layout Subsection
2009 \begin_layout Standard
2010 There are two simple methods to make arrows bend.
2011 The first is giving an explicit value by which the midpoint of the arrow's
2012 shaft is raised or depressed, the other is by forcing the arrow to leave
2013 its origin in a prescribed compass direction and to make him enter the
2014 target at another direction.
2015 The necessary bending of the arrow is determined automatically.
2016 We describe both methods.
2019 \begin_layout Subsubsection
2023 \begin_layout Standard
2024 For bending arrows we use the modifier @/
2025 \begin_inset Formula $\ldots$
2029 The ellipsis stands for a \SpecialChar TeX
2030 -measure which needs to be entered as a lower
2036 , we could simply write, e.
2037 \begin_inset space \thinspace{}
2041 \begin_inset space \space{}
2050 for an arrow bending
2054 downwards, this cannot directly be done in \SpecialChar LyX
2056 It is necessary, to enclose the measure in a pair of braces, such as e.
2057 \begin_inset space \thinspace{}
2061 \begin_inset space \space{}
2071 As an example, here are two opposing arrows between
2072 \begin_inset Formula $A$
2076 \begin_inset Formula $B$
2079 , each bending by .5 pica, given by the following source code:
2082 \begin_layout Standard
2094 \begin_layout Standard
2095 \begin_inset Formula
2097 \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]}
2105 \begin_layout Subsubsection
2106 Specifying exit- and entrance directions
2109 \begin_layout Standard
2110 An alternative for making arrows bend is by specifying their compass direction
2111 as they are leaving their source and their direction from which they enter
2113 Instead of north, north-east, east, etc., the directions are named
2145 , standing for up, up-right, right, down-right, etc..
2146 A direction is specified as @(
2158 stands for the direction the first object is left and
2162 stands for the direction from which the target is entered.
2163 As an example, we show some bending arrows and a loop, which arises when
2164 we do not specify a target for an arrow, just its incoming and outgoing
2168 \begin_layout Standard
2169 \begin_inset Formula
2171 \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\
2181 \begin_layout LyX-Code
2189 \begin_inset Newline newline
2199 \begin_inset Newline newline
2207 \begin_layout Subsection
2211 \begin_layout Standard
2212 The above example is reminiscent of an automata diagram, except that in
2213 such a diagram states would be enclosed in small circles, with double circles
2214 denoting final states.
2218 \begin_layout Subsubsection
2222 \begin_layout Standard
2227 \begin_layout Plain Layout
2236 -pic, entries can obtain a single or a double frame, such as
2237 \begin_inset Formula $\xymatrix{*+[F]{A}}
2242 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2246 by prefixing an entry with
2254 and enclosing the portion of the entry to be framed in braces.
2255 Normally, the frame will be very tight so that it must be widened by prefixing
2265 Round frames, such as
2266 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2271 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2275 are obtained by specifying the shape as
2280 So the latter figure was constructed as *++[o][F=]{B}.
2281 This way, the following automaton
2284 \begin_layout Standard
2285 \begin_inset Formula
2287 \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]}
2295 \begin_layout Standard
2300 \begin_layout LyX-Code
2310 \begin_layout LyX-Code
2316 \begin_layout LyX-Code
2324 \begin_layout LyX-Code
2328 \begin_layout Standard
2329 The \SpecialChar LaTeX
2341 will make a certain entry style the default, that can, of course be overridden
2342 for individual entries.
2347 entrymodifiers={++[o][F-]}
2349 , all following entries inside
2353 \begin_layout Plain Layout
2362 -matrices would be encircled.
2365 \begin_layout Subsubsection
2369 \begin_layout Standard
2370 Framing a whole rectangle inside an xymatrix is done with the macro pair
2390 The dimension of the rectangle is given as a dotted pair
2391 \begin_inset Formula $P_{0}.P_{1}$
2394 of points denoting the top left and lower right corners of the rectangle.
2395 Each point, in turn,is given as a doubly quoted comma separated pair
2396 \begin_inset Quotes eld
2400 \begin_inset Formula $x,y$
2404 \begin_inset Quotes erd
2408 \begin_inset Formula $x$
2412 \begin_inset Formula $y$
2416 These are followed by the framing commands, to produce figures such as
2418 \begin_inset Formula
2420 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2421 C & \save"1,1"."1,2"*++[F]\frm{}\restore
2438 save"1,1"."2,1"*+[F=]
2451 produces the doubly framed rectangle, and the code for the extra wide horizonta
2463 save"1,1"."1,2"*++[F]
2477 This code can be placed in arbitrary cells of the xymatrix.
2481 \begin_layout Section
2482 Using \SpecialChar LyX
2484 \begin_inset CommandInset label
2486 name "sec:math-editor"
2493 \begin_layout Standard
2494 As an alternative to writing the
2498 code, then transforming it into a math-editing environment by marking it
2507 , one may construct and modify the whole xypic-diagram inside \SpecialChar LyX
2509 We describe the editing steps for a figure just like the one above.
2513 \begin_layout Subsection
2514 Caveat - how to enter braces
2517 \begin_layout Standard
2518 Recall that in \SpecialChar LyX
2519 's math-editor any pair of braces
2527 that are to enclose a macro-parameter must be entered by typing just
2534 The closing brace is automatically supplied and in between a box into which
2535 to the parameter is entered.
2540 \begin_layout Plain Layout
2549 -diagrams, this applies in particular to arrow modifications that are normally
2559 with the ellipsis standing for the description of end, shaft and tip of
2561 Inside the math-editor, enter just
2567 and let \SpecialChar LyX
2568 provide the closing brace and the box into which to enter the
2569 description of the arrow.
2572 \begin_layout Standard
2573 Braces that are entered without the backslash
2579 will just appear as typed, but cannot be used to receive a macro parameter.
2580 They are useful, for instance to denote sets, e.
2581 \begin_inset space \thinspace{}
2585 \begin_inset space \space{}
2599 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2605 \begin_layout Subsection
2606 Setting up the matrix
2609 \begin_layout Standard
2618 open a formula environment and enter:
2626 \begin_inset Formula $\times$
2633 \begin_layout Plain Layout
2643 Add extra rows by typing
2647 and add columns by typing
2653 \begin_layout Standard
2654 At any time, further rows or columns can be entered or deleted using commands
2657 Edit\SpecialChar menuseparator
2661 their shortcuts, beginning with
2665 for the column commands or
2669 for the row commands.
2670 A more direct way uses the icons in the math toolbar once it has been activated
2673 View\SpecialChar menuseparator
2677 \begin_layout Subsection
2678 Entering nodes, arrows and labels
2681 \begin_layout Standard
2682 Type the nodes into the correct positions of the matrix.
2683 If you move the cursor out of the matrix, you should see a first rendering
2685 Next, add the arrows at the nodes from where they should emanate by typing
2702 can be any path made up from the characters
2719 Make sure that the path indeed leads to an existing node within the matrix.
2720 Otherwise, the figure will not display when the cursor leaves the editing
2724 \begin_layout Standard
2725 Next, label the arrows by attaching a label text as upper or lower indices
2726 to the end of the arrow's path.
2727 As always in \SpecialChar LyX
2728 's math editor, an underscore
2732 opens a box for a lower index and a
2736 followed by a space opens a box for an upper index.
2737 You can enter any \SpecialChar LaTeX
2741 \begin_layout Subsection
2745 \begin_layout Standard
2746 Finally, you can modify the appearance of the arrows by entering @-modifiers
2777 The above caveat applies to the first form only.
2778 It must be entered as
2784 with the arrow description entered inside the \SpecialChar LyX
2786 If this box remains empty, you have specified an empty arrow.
2787 This is a useful construction, too, as you will see in the next section.
2791 \begin_layout Standard
2792 The other modifiers,
2820 are typed as shown with the arrow description replacing the ellipsis.
2821 The code for bending arrows, which in
2850 is any valid \SpecialChar TeX
2851 -measure that should be entered as upper or lower index to
2853 Make sure that the ending slash does not end up being part of the upper
2857 \begin_layout Subsection
2858 What if something goes wrong
2861 \begin_layout Standard
2862 When constructing a diagram, you should at times check it by just moving
2863 the cursor out of the editing area to see whether instant preview can successfu
2864 lly convert it into graphical output.
2865 If this does not happen, it may either be that instant preview for some
2866 reason is not aware that it should retranslate the graphics.
2867 Moving the cursor into the editing area and out again sometimes wakes up
2871 \begin_layout Standard
2872 A more serious reason could be a syntactical error in your input (in that
2873 case, the math edition area disappears completely).
2874 If necessary, undo the last editing steps, using
2878 , or try to translate the \SpecialChar LyX
2889 View\SpecialChar menuseparator
2893 There should be some error generated, which hopefully gives you a hint
2894 as to the source of the mistake.
2897 \begin_layout Section
2901 \begin_layout Standard
2902 Certain things do not work correctly inside \SpecialChar LyX
2904 The ones that we (used to) miss most are the horizontal and vertical scaling
2905 of diagrams, and the correct positioning of arrows.
2906 There are some workarounds that we are explaining here.
2910 \begin_layout Subsection
2911 Horizontal and vertical scaling
2914 \begin_layout Standard
2915 It is often convenient to stretch the horizontal or the vertical dimensions
2916 of an entire diagram by using spacing commands for rows and/or columns.
2921 \begin_layout Plain Layout
2931 \begin_inset CommandInset citation
2953 \begin_layout Plain Layout
2962 -matrix with row spacing of 1
2963 \begin_inset space ~
2983 allows to modify the space between columns.
2984 Unfortunately, one cannot type
2985 \begin_inset Quotes eld
2995 \begin_inset Quotes erd
2998 into a formula to get the desired matrix because the @-character is interpreted
3007 But there are two other ways of getting the desired matrix:
3010 \begin_layout Itemize
3012 \begin_inset space \space{}
3021 as normal document text, then either highlight it and press
3027 to get a formula, or copy it into an existing formula.
3028 You can now continue as normal.
3029 \begin_inset Newline newline
3033 \begin_inset Note Greyedout
3036 \begin_layout Plain Layout
3041 This method only works for single spacing settings, so using
3042 \begin_inset Newline newline
3055 xymatrix@M=1pt@C=1dd
3058 The method also don't work if you use '!' to get a fixed grid with a defined
3060 \begin_inset space \space{}
3081 \begin_inset Newline newline
3084 For the following matrix, the command
3091 \begin_inset Formula
3093 \xymatrix@C=9pc{A\ar[r]\ar[d] & B\\
3094 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3103 \begin_layout Itemize
3107 \begin_layout Plain Layout
3117 \begin_inset space ~
3120 stores the values for row-spacing and column-spacing in the variables
3121 \begin_inset Newline newline
3137 So one can add the following macro to the preamble (
3139 Layout\SpecialChar menuseparator
3140 Document\SpecialChar menuseparator
3147 \begin_layout LyX-Code
3155 \begin_layout LyX-Code
3160 xymatrixrowsep@{#1}}
3163 \begin_layout Standard
3170 can be defined correspondingly by replacing
3183 Now, a figure can be scaled by entering
3185 xyR{ into the formula before the
3189 \begin_layout Plain Layout
3199 Place the cursor inside the matrix, just before the first entry.
3217 Don't forget the backslashes and remember, that the closing brace is automatica
3218 lly supplied by \SpecialChar LyX
3220 Inside the braces enter the dimensions.
3221 \begin_inset Newline newline
3225 \begin_inset Note Greyedout
3228 \begin_layout Plain Layout
3233 these commands affect all following
3237 \begin_layout Plain Layout
3247 Therefore don't forget to reset the values to default after the usage of
3260 \begin_inset Newline newline
3268 Here you see a diagram which is squashed vertically and stretched horizontally
3278 \begin_inset Formula
3280 \xyR{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
3281 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3288 \begin_inset Formula $\xyR{2pc}\xyC{2pc}$
3292 \begin_inset Note Note
3295 \begin_layout Plain Layout
3305 \begin_layout Subsection
3309 \begin_layout Standard
3314 \begin_layout Plain Layout
3323 -command allows the correct positioning of labels along the shaft of arrows.
3324 This feature is sometimes necessary, when the default position of a label
3325 would otherwise clutter the picture, or would even coincide with other
3326 items, such as the intersection of the arrows in the figure below.
3327 In order to shift a label position alongside the shaft of an arrow,
3331 \begin_layout Plain Layout
3341 \begin_inset space ~
3344 allows to prefix the label by a decimal number in parentheses, specifying
3345 the fraction of distance alongside the arrow where the label is to be placed.
3346 For instance, the code
3354 , will place the label on the shaft, but only about one third of the way.
3358 \begin_layout Standard
3359 Doing the same with labels above or below arrows as
3375 , does not work from inside \SpecialChar LyX
3377 Instead, one has to replace the hat-symbol ^, resp.
3378 the underscore _ , by the macros
3412 It is, in fact, possible to enter several labels this way and those labels
3413 are placed correctly, even if the arrow bends.
3414 In the following figure, the bending arrow with its four labels has been
3438 \begin_layout Standard
3439 \begin_inset Formula
3441 \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}}\\
3442 \circ\ar[ur]\sb(0.3)\phi & \bullet
3451 \begin_layout Subsection
3452 Invisible stretched arrows
3455 \begin_layout Standard
3456 A more general trick uses invisible arrows to place any object almost anywhere
3458 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3459 a decimal stretching ratio, e.
3460 \begin_inset space \thinspace{}
3464 \begin_inset space \space{}
3476 Attach a label to this invisible arrow.
3480 \begin_layout Standard
3481 Thus, the down pointing arrow with its label
3482 \begin_inset Formula $\varphi$
3485 at (0.3) of its way along the shaft might as well have been produced by
3486 adding to the regular arrow
3493 \begin_inset Formula $\varphi$
3504 , reaching only 0.6 of the way.
3505 Its label will now appear at 0.3 of the way of the original visible arrow.
3509 \begin_layout Standard
3510 This workaround has two minor drawbacks: First, it does not work with bending
3512 Secondly, prolonging an invisible arrow beyond the normal dimension of
3513 the figure will invisibly extend the figure box, and thereby cause too
3514 much vertical space between the figure and the preceding or the following
3519 \begin_layout Standard
3520 Nevertheless, invisible arrows are an important tool, since they can, in
3521 principle, be used to place information at any chosen place in a diagram.
3522 In the above figure, for instance, we have used an invisible arrow to carry
3529 as label and at the earlier figure we had used an invisible arrow to carry
3531 \begin_inset Quotes eld
3539 \begin_inset Quotes erd
3542 into the center of the figure.
3545 \begin_layout Subsection
3553 \begin_layout Standard
3554 Here we have focused only on the
3560 command, which is just one of the features available in Kris Rose's amazing
3566 \begin_layout Plain Layout
3584 \begin_layout Plain Layout
3596 \begin_inset CommandInset citation
3603 demonstrates many of the advanced possibilities of that package.
3604 Beware, that its style is rather terse and you will likely need a lot of
3605 experimenting and modifying the many worked examples.
3607 \begin_inset CommandInset citation
3618 \begin_layout Plain Layout
3627 -pic to make braids, cobordism, string diagrams, and much more.
3628 You might want to look on
3632 example shipped with \SpecialChar LyX
3633 , which demonstrates how to use more advanced
3637 \begin_layout Plain Layout
3650 \begin_inset space ~
3662 \begin_layout Standard
3663 \begin_inset Newpage newpage
3669 \begin_layout Bibliography
3670 \begin_inset CommandInset bibitem
3671 LatexCommand bibitem
3682 \begin_layout Plain Layout
3696 \begin_inset Newline newline
3700 \begin_inset Flex URL
3703 \begin_layout Plain Layout
3705 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyguide.pdf
3713 \begin_layout Bibliography
3714 \begin_inset CommandInset bibitem
3715 LatexCommand bibitem
3716 key "xypic reference"
3722 Rose and Ross Moore:
3726 \begin_layout Plain Layout
3737 -pic Reference Manual
3740 \begin_inset Newline newline
3744 \begin_inset Flex URL
3747 \begin_layout Plain Layout
3749 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyrefer.pdf
3757 \begin_layout Bibliography
3758 \begin_inset CommandInset bibitem
3759 LatexCommand bibitem
3765 Homepage of the package
3769 \begin_layout Plain Layout
3783 \begin_inset Flex URL
3786 \begin_layout Plain Layout
3788 http://www.ctan.org/pkg/xypic
3796 \begin_layout Bibliography
3797 \begin_inset CommandInset bibitem
3798 LatexCommand bibitem
3799 key "instant-preview"
3804 Homepage of preview-latex:
3805 \begin_inset Newline newline
3809 \begin_inset Flex URL
3812 \begin_layout Plain Layout
3814 http://www.gnu.org/software/auctex/preview-latex.html
3822 \begin_layout Bibliography
3823 \begin_inset CommandInset bibitem
3824 LatexCommand bibitem
3830 Homepage of AUC\SpecialChar TeX
3832 \begin_inset Flex URL
3835 \begin_layout Plain Layout
3837 http://www.gnu.org/software/auctex/
3845 \begin_layout Bibliography
3846 \begin_inset CommandInset bibitem
3847 LatexCommand bibitem
3857 \begin_layout Plain Layout
3872 tutorial with an archive of examples
3875 \begin_inset Newline newline
3879 \begin_inset Flex URL
3882 \begin_layout Plain Layout
3884 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyguide.pdf