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
483 \begin_inset Separator parbreak
490 \begin_layout Enumerate
491 Open \SpecialChar LyX
494 Tools\SpecialChar menuseparator
495 Preferences\SpecialChar menuseparator
496 Look and Feel\SpecialChar menuseparator
506 \begin_layout Enumerate
509 Document\SpecialChar menuseparator
510 Settings\SpecialChar menuseparator
519 Use AMS Math package automatically
528 \begin_layout Enumerate
533 works by opening a \SpecialChar LyX
534 -document and entering any math-formula, e.
535 \begin_inset space \thinspace{}
539 \begin_inset space \space{}
543 \begin_inset Formula $a+b=c$
550 \begin_layout Enumerate
551 Move the cursor out of the formula, and watch it change its appearance to
552 look just like in the finished DVI- or PostScript document.
557 \begin_layout Enumerate
562 \begin_layout Plain Layout
576 \begin_inset Separator parbreak
583 \begin_layout Enumerate
584 Inside your \SpecialChar LyX
585 -Document, enter the text
588 \begin_inset Newline newline
600 \begin_layout Enumerate
601 Select the whole text and choose
603 Insert\SpecialChar menuseparator
604 Math\SpecialChar menuseparator
607 , or use the corresponding keyboard shortcut
615 \begin_layout Enumerate
616 Move the mouse cursor out of the editing box and wait for a split second
617 to see an arrow appear:
618 \begin_inset Formula $\xymatrix{A\ar[r] & B}
626 \begin_layout Section
630 \begin_layout Standard
631 The following diagram, which is taken from the documentation of
635 \begin_layout Plain Layout
645 \begin_inset CommandInset citation
651 by its creator Kristoffer H.
652 Rose, will provide an example for many of the features available with that
657 \begin_layout LyX-Code
661 \begin_inset Newline newline
673 \begin_inset Newline newline
683 \begin_inset Newline newline
699 \begin_inset Newline newline
707 \begin_layout LyX-Code
711 \begin_layout Standard
712 Again, to turn this code into a graphical output, select it all at once
720 up to the closing brace \SpecialChar ldots
725 and turn it into display-math as explained above.
726 A moment after the cursor leaves the math-area, you should see the diagram
727 in its full graphical glory as shown below.
731 \begin_layout Standard
732 \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\
733 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
742 \begin_layout Subsection
743 The matrix layout of diagrams
746 \begin_layout Standard
751 uses a matrix to define the layout of the vertices of a diagram.
752 For the above example, we need a
753 \begin_inset Formula $3\times3$
756 -matrix of which 5 entries are used for the vertices
757 \begin_inset Formula $U$
761 \begin_inset Formula $X\times_{Z}Y$
765 \begin_inset Formula $X$
769 \begin_inset Formula $Y$
773 \begin_inset Formula $Z$
776 , the other positions remaining empty.
777 In this case, the following matrix determines the layout:
780 \begin_layout LyX-Code
784 \begin_inset Newline newline
792 \begin_inset Newline newline
802 \begin_inset Newline newline
808 \begin_layout Standard
809 The pattern should be familiar from \SpecialChar LaTeX
810 : We see three rows, the first two being
811 terminated by the end-of-line-marker
820 Each line consists of entries, separated by the ampersand
828 \begin_layout Subsection
832 \begin_layout Standard
833 Having entered the vertices, we add arrows between them.
838 -command to produce an arrow is
844 , it is entered into the cell of the matrix where the arrow is to start.
845 The target of the arrow is defined by direction commands
862 These can be combined to a path and enclosed in square brackets.
863 As an example, the arrows from the vertex
864 \begin_inset Formula $U$
867 in the upper left corner down and right to the vertices
868 \begin_inset Formula $X\times_{Z}Y$
872 \begin_inset Formula $Y$
876 \begin_inset Formula $X$
879 are, respectively, defined as
898 Thus the above diagram with all arrows added becomes:
901 \begin_layout LyX-Code
905 \begin_inset Newline newline
919 \begin_inset Newline newline
935 \begin_inset Newline newline
943 \begin_layout LyX-Code
944 \begin_inset Formula $\xymatrix{U\ar[ddr]\ar[drr]\ar[dr]\\
945 & X\times_{Z}Y\ar[d]\ar[r] & X\ar[d]\\
954 \begin_layout LyX-Code
958 \begin_layout LyX-Code
962 \begin_layout Subsection
966 \begin_layout Standard
967 Labels are attached to arrows by affixing them as upper or lower indices
983 defines an arrow going one cell down, two to the right and having the label
985 \begin_inset Formula $\varphi$
989 To attach a label below the arrow, make it a lower index as in
998 This explanation is correct only for arrows pointing to the right.
999 More precisely, imagine looking along the arrow in the direction it is
1001 Then an upper index places a label to the left and a lower index places
1003 Consequently, an arrow pointing from right to left, such as
1014 \begin_inset Formula $\alpha$
1018 \begin_inset Formula $\beta$
1022 \begin_inset space \thinspace{}
1026 \begin_inset space \space{}
1030 \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.}
1034 Using the character | instead of ^ or _ , it is even possible to place the
1035 label right onto the arrow, obscuring part of its shaft.
1039 \begin_layout Standard
1040 Normally, a label is placed halfway between an arrow's start and target
1042 In the first diagram, the central arrow starting in
1043 \begin_inset Formula $U$
1047 \begin_inset Formula $(x,y)$
1050 in the middle of the arrow's shaft, rather than in the middle between the
1051 two objects it connects.
1052 This is achieved by prefixing the label with a minus sign, here:
1061 \begin_layout LyX-Code
1065 \begin_inset Newline newline
1083 \begin_inset Newline newline
1099 \begin_inset Newline newline
1107 \begin_layout LyX-Code
1108 \begin_inset Formula $\xymatrix{U\ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\
1109 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
1118 \begin_layout Standard
1122 \begin_layout Plain Layout
1131 -pic normally permits labels to be shifted towards the tip or towards the
1132 start of an arrow by prefixing the label with a ratio, such as e.
1133 \begin_inset space \thinspace{}
1137 \begin_inset space \space{}
1146 this works only for labels which are placed on top of the arrow, such
1159 \begin_layout Standard
1160 For labels placed to the left or to the right of the arrow this does not
1166 \begin_layout Plain Layout
1175 -pic code such as e.
1176 \begin_inset space \thinspace{}
1180 \begin_inset space \space{}
1199 is not correctly interpreted by \SpecialChar LyX
1201 Two workarounds are suggested in the last section of this note.
1204 \begin_layout Subsection
1208 \begin_layout Standard
1209 Modification of the design, the form or the positioning of arrows are introduced
1215 This is followed by a pair of matching brackets, where the form of the
1228 indicates, whether we want to modify the design, the or the curvature of
1230 Various modifications can be applied to an arrow at the same time.
1233 \begin_layout Subsubsection
1237 \begin_layout Standard
1238 Various designs such as
1254 are possible for the shaft of an arrow.
1255 These can be combined with various ends and various tips.
1256 In general, the design of an arrow is described by following the command
1267 -sign and a pair of braces {\SpecialChar ldots
1268 } containing characters describing the end,
1269 the shaft and the tip of the arrow.
1270 These characters are chosen to give some form of ASCII-rendering of the
1278 produces an arrow with split end, a dotted shaft and double head.
1279 A number of other arrow designs is given in the table below.
1280 Note that the ends of embedding arrows
1281 \begin_inset Formula $\xymatrix{A\ar@{^{(}->}[r] & B}
1285 are described by raising or lowering opening parentheses, such as in
1292 \begin_inset Separator parbreak
1298 \begin_layout Standard
1300 \begin_inset Tabular
1301 <lyxtabular version="3" rows="11" columns="2">
1302 <features tabularvalignment="middle">
1303 <column alignment="center" valignment="top" width="0pt">
1304 <column alignment="center" valignment="top">
1306 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1309 \begin_layout Plain Layout
1315 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1318 \begin_layout Plain Layout
1319 Source code in \SpecialChar LyX
1327 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1330 \begin_layout Plain Layout
1331 \begin_inset Formula $\xymatrix{\ \ar[r] & \ }
1340 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1343 \begin_layout Plain Layout
1355 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1358 \begin_layout Plain Layout
1359 \begin_inset Formula $\xymatrix{\ \ar@{-->}[r] & \ }
1368 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1371 \begin_layout Plain Layout
1383 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1386 \begin_layout Plain Layout
1387 \begin_inset Formula $\xymatrix{\ \ar@{..>}[r] & \ }
1396 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1399 \begin_layout Plain Layout
1411 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1414 \begin_layout Plain Layout
1415 \begin_inset Formula $\xymatrix{\ \ar@{~>}[r] & \ }
1424 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1427 \begin_layout Plain Layout
1439 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1442 \begin_layout Plain Layout
1443 \begin_inset Formula $\xymatrix{\ \ar@{->>}[r] & \ }
1452 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1455 \begin_layout Plain Layout
1467 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1470 \begin_layout Plain Layout
1471 \begin_inset Formula $\xymatrix{\ \ar@{-->>}[r] & \ }
1480 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1483 \begin_layout Plain Layout
1495 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1498 \begin_layout Plain Layout
1499 \begin_inset Formula $\xymatrix{\ \ar@{>->>}[r] & \ }
1508 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1511 \begin_layout Plain Layout
1523 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1526 \begin_layout Plain Layout
1527 \begin_inset Formula $\xymatrix{\ \ar@{_{(}->}[r] & \ }
1536 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1539 \begin_layout Plain Layout
1551 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1554 \begin_layout Plain Layout
1555 \begin_inset Formula $\xymatrix{\ \ar@{^{(}->}[r] & \ }
1564 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1567 \begin_layout Plain Layout
1579 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1582 \begin_layout Plain Layout
1583 \begin_inset Formula $\xymatrix{\ \ar@{|-|}[r] & \ }
1592 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1595 \begin_layout Plain Layout
1613 \begin_layout Standard
1615 Following the @-character by either a 2, 3, _ or a ^, we can produce arrows
1616 with double, triple shaft or arrows showing only the lower or upper half
1617 of their tips and ends.
1618 Arrows need not have tips nor ends, as the last example shows:
1619 \begin_inset Separator parbreak
1625 \begin_layout Standard
1627 \begin_inset Tabular
1628 <lyxtabular version="3" rows="8" columns="2">
1629 <features tabularvalignment="middle">
1630 <column alignment="center" valignment="top">
1631 <column alignment="center" valignment="top">
1633 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1636 \begin_layout Plain Layout
1642 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1645 \begin_layout Plain Layout
1646 Source code for \SpecialChar LyX
1654 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1657 \begin_layout Plain Layout
1658 \begin_inset Formula $\xymatrix{\ \ar@2[r] & \ }
1667 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1670 \begin_layout Plain Layout
1682 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1685 \begin_layout Plain Layout
1686 \begin_inset Formula $\xymatrix{\ \ar@3[r] & \ }
1695 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1698 \begin_layout Plain Layout
1710 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1713 \begin_layout Plain Layout
1714 \begin_inset Formula $\xymatrix{\ \ar@_{->}[r] & \ }
1723 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1726 \begin_layout Plain Layout
1738 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1741 \begin_layout Plain Layout
1742 \begin_inset Formula $\xymatrix{\ \ar@^{->}[r] & \ }
1751 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1754 \begin_layout Plain Layout
1766 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1769 \begin_layout Plain Layout
1770 \begin_inset Formula $\xymatrix{\ \ar@^{>>->>}[r] & \ }
1779 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1782 \begin_layout Plain Layout
1787 ar@^{>\SpecialChar ligaturebreak
1788 >->\SpecialChar ligaturebreak
1796 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1799 \begin_layout Plain Layout
1800 \begin_inset Formula $\xymatrix{\ \ar@{^{<}-_{>}}[r] & \ }
1809 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1812 \begin_layout Plain Layout
1824 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1827 \begin_layout Plain Layout
1828 \begin_inset Formula $\xymatrix{\ \ar@2{--}[r] & \ }
1837 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1840 \begin_layout Plain Layout
1858 \begin_layout Subsubsection
1859 Designing your own arrows
1862 \begin_layout Standard
1863 Within certain limits there is even a way to design your own arrows.
1864 Using some the characters
1868 one can even design one's own arrow tips using the
1874 command in the preamble.
1875 For explanations, we refer to the
1881 \begin_layout Plain Layout
1892 -manual, from which we take the example:
1895 \begin_layout Standard
1900 newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
1905 \begin_layout Standard
1907 This defines a new arrow tip, referred to as
1917 and which displays correctly in \SpecialChar LyX
1919 \begin_inset Formula
1921 \xymatrix{A\ar@{-|>}[r] & \ \ B}
1929 \begin_layout Subsection
1933 \begin_layout Standard
1934 Arrows are shifted sideways with the modifier
1939 \begin_inset Formula $\ldots$
1946 where the ellipsis is replaced by a positive or negative measure.
1947 For instance, to design a pair of mutually opposing arrows between two
1948 nodes, we shift them to see them apart.
1949 Note that the direction of the shift (positive) is to the left if one looks
1954 \begin_layout Standard
1970 \begin_layout Standard
1973 \begin_inset Formula
1975 \xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1983 \begin_layout Subsubsection
1984 Inline or centered diagrams
1987 \begin_layout Standard
1988 Arrows and diagrams can be used inline, such as this one:
1989 \begin_inset Formula $\xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1994 When their code is written inside \SpecialChar LyX
1995 as above, select it and choose either
2000 for inline appearance or
2005 Diagrams constructed inline can later be centered, or, conversely, centered
2006 diagrams can be changed to inline formulas with
2008 Edit\SpecialChar menuseparator
2013 \SpecialChar menuseparator
2014 Change Formula Type.
2017 \begin_layout Subsection
2021 \begin_layout Standard
2022 There are two simple methods to make arrows bend.
2023 The first is giving an explicit value by which the midpoint of the arrow's
2024 shaft is raised or depressed, the other is by forcing the arrow to leave
2025 its origin in a prescribed compass direction and to make him enter the
2026 target at another direction.
2027 The necessary bending of the arrow is determined automatically.
2028 We describe both methods.
2031 \begin_layout Subsubsection
2035 \begin_layout Standard
2036 For bending arrows we use the modifier @/
2037 \begin_inset Formula $\ldots$
2041 The ellipsis stands for a \SpecialChar TeX
2042 -measure which needs to be entered as a lower
2048 , we could simply write, e.
2049 \begin_inset space \thinspace{}
2053 \begin_inset space \space{}
2062 for an arrow bending
2066 downwards, this cannot directly be done in \SpecialChar LyX
2068 It is necessary, to enclose the measure in a pair of braces, such as e.
2069 \begin_inset space \thinspace{}
2073 \begin_inset space \space{}
2083 As an example, here are two opposing arrows between
2084 \begin_inset Formula $A$
2088 \begin_inset Formula $B$
2091 , each bending by .5 pica, given by the following source code:
2094 \begin_layout Standard
2106 \begin_layout Standard
2107 \begin_inset Formula
2109 \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]}
2117 \begin_layout Subsubsection
2118 Specifying exit- and entrance directions
2121 \begin_layout Standard
2122 An alternative for making arrows bend is by specifying their compass direction
2123 as they are leaving their source and their direction from which they enter
2125 Instead of north, north-east, east, etc., the directions are named
2157 , standing for up, up-right, right, down-right, etc..
2158 A direction is specified as @(
2170 stands for the direction the first object is left and
2174 stands for the direction from which the target is entered.
2175 As an example, we show some bending arrows and a loop, which arises when
2176 we do not specify a target for an arrow, just its incoming and outgoing
2180 \begin_layout Standard
2181 \begin_inset Formula
2183 \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\
2193 \begin_layout LyX-Code
2201 \begin_inset Newline newline
2211 \begin_inset Newline newline
2219 \begin_layout Subsection
2223 \begin_layout Standard
2224 The above example is reminiscent of an automata diagram, except that in
2225 such a diagram states would be enclosed in small circles, with double circles
2226 denoting final states.
2230 \begin_layout Subsubsection
2234 \begin_layout Standard
2239 \begin_layout Plain Layout
2248 -pic, entries can obtain a single or a double frame, such as
2249 \begin_inset Formula $\xymatrix{*+[F]{A}}
2254 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2258 by prefixing an entry with
2266 and enclosing the portion of the entry to be framed in braces.
2267 Normally, the frame will be very tight so that it must be widened by prefixing
2277 Round frames, such as
2278 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2283 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2287 are obtained by specifying the shape as
2292 So the latter figure was constructed as *++[o][F=]{B}.
2293 This way, the following automaton
2296 \begin_layout Standard
2297 \begin_inset Formula
2299 \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]}
2307 \begin_layout Standard
2312 \begin_layout LyX-Code
2322 \begin_layout LyX-Code
2328 \begin_layout LyX-Code
2336 \begin_layout LyX-Code
2340 \begin_layout Standard
2341 The \SpecialChar LaTeX
2353 will make a certain entry style the default, that can, of course be overridden
2354 for individual entries.
2359 entrymodifiers={++[o][F-]}
2361 , all following entries inside
2365 \begin_layout Plain Layout
2374 -matrices would be encircled.
2377 \begin_layout Subsubsection
2381 \begin_layout Standard
2382 Framing a whole rectangle inside an xymatrix is done with the macro pair
2402 The dimension of the rectangle is given as a dotted pair
2403 \begin_inset Formula $P_{0}.P_{1}$
2406 of points denoting the top left and lower right corners of the rectangle.
2407 Each point, in turn,is given as a doubly quoted comma separated pair
2408 \begin_inset Quotes eld
2412 \begin_inset Formula $x,y$
2416 \begin_inset Quotes erd
2420 \begin_inset Formula $x$
2424 \begin_inset Formula $y$
2428 These are followed by the framing commands, to produce figures such as
2430 \begin_inset Formula
2432 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2433 C & \save"1,1"."1,2"*++[F]\frm{}\restore
2450 save"1,1"."2,1"*+[F=]
2463 produces the doubly framed rectangle, and the code for the extra wide horizonta
2475 save"1,1"."1,2"*++[F]
2489 This code can be placed in arbitrary cells of the xymatrix.
2493 \begin_layout Section
2494 Using \SpecialChar LyX
2496 \begin_inset CommandInset label
2498 name "sec:math-editor"
2505 \begin_layout Standard
2506 As an alternative to writing the
2510 code, then transforming it into a math-editing environment by marking it
2519 , one may construct and modify the whole xypic-diagram inside \SpecialChar LyX
2521 We describe the editing steps for a figure just like the one above.
2525 \begin_layout Subsection
2526 Caveat - how to enter braces
2529 \begin_layout Standard
2530 Recall that in \SpecialChar LyX
2531 's math-editor any pair of braces
2539 that are to enclose a macro-parameter must be entered by typing just
2546 The closing brace is automatically supplied and in between a box into which
2547 to the parameter is entered.
2552 \begin_layout Plain Layout
2561 -diagrams, this applies in particular to arrow modifications that are normally
2571 with the ellipsis standing for the description of end, shaft and tip of
2573 Inside the math-editor, enter just
2579 and let \SpecialChar LyX
2580 provide the closing brace and the box into which to enter the
2581 description of the arrow.
2584 \begin_layout Standard
2585 Braces that are entered without the backslash
2591 will just appear as typed, but cannot be used to receive a macro parameter.
2592 They are useful, for instance to denote sets, e.
2593 \begin_inset space \thinspace{}
2597 \begin_inset space \space{}
2611 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2617 \begin_layout Subsection
2618 Setting up the matrix
2621 \begin_layout Standard
2630 open a formula environment and enter:
2638 \begin_inset Formula $\times$
2645 \begin_layout Plain Layout
2655 Add extra rows by typing
2659 and add columns by typing
2665 \begin_layout Standard
2666 At any time, further rows or columns can be entered or deleted using commands
2669 Edit\SpecialChar menuseparator
2673 their shortcuts, beginning with
2677 for the column commands or
2681 for the row commands.
2682 A more direct way uses the icons in the math toolbar once it has been activated
2685 View\SpecialChar menuseparator
2689 \begin_layout Subsection
2690 Entering nodes, arrows and labels
2693 \begin_layout Standard
2694 Type the nodes into the correct positions of the matrix.
2695 If you move the cursor out of the matrix, you should see a first rendering
2697 Next, add the arrows at the nodes from where they should emanate by typing
2714 can be any path made up from the characters
2731 Make sure that the path indeed leads to an existing node within the matrix.
2732 Otherwise, the figure will not display when the cursor leaves the editing
2736 \begin_layout Standard
2737 Next, label the arrows by attaching a label text as upper or lower indices
2738 to the end of the arrow's path.
2739 As always in \SpecialChar LyX
2740 's math editor, an underscore
2744 opens a box for a lower index and a
2748 followed by a space opens a box for an upper index.
2749 You can enter any \SpecialChar LaTeX
2753 \begin_layout Subsection
2757 \begin_layout Standard
2758 Finally, you can modify the appearance of the arrows by entering @-modifiers
2789 The above caveat applies to the first form only.
2790 It must be entered as
2796 with the arrow description entered inside the \SpecialChar LyX
2798 If this box remains empty, you have specified an empty arrow.
2799 This is a useful construction, too, as you will see in the next section.
2803 \begin_layout Standard
2804 The other modifiers,
2832 are typed as shown with the arrow description replacing the ellipsis.
2833 The code for bending arrows, which in
2862 is any valid \SpecialChar TeX
2863 -measure that should be entered as upper or lower index to
2865 Make sure that the ending slash does not end up being part of the upper
2869 \begin_layout Subsection
2870 What if something goes wrong
2873 \begin_layout Standard
2874 When constructing a diagram, you should at times check it by just moving
2875 the cursor out of the editing area to see whether instant preview can successfu
2876 lly convert it into graphical output.
2877 If this does not happen, it may either be that instant preview for some
2878 reason is not aware that it should retranslate the graphics.
2879 Moving the cursor into the editing area and out again sometimes wakes up
2883 \begin_layout Standard
2884 A more serious reason could be a syntactical error in your input (in that
2885 case, the math edition area disappears completely).
2886 If necessary, undo the last editing steps, using
2890 , or try to translate the \SpecialChar LyX
2901 View\SpecialChar menuseparator
2905 There should be some error generated, which hopefully gives you a hint
2906 as to the source of the mistake.
2909 \begin_layout Section
2913 \begin_layout Standard
2914 Certain things do not work correctly inside \SpecialChar LyX
2916 The ones that we (used to) miss most are the horizontal and vertical scaling
2917 of diagrams, and the correct positioning of arrows.
2918 There are some workarounds that we are explaining here.
2922 \begin_layout Subsection
2923 Horizontal and vertical scaling
2926 \begin_layout Standard
2927 It is often convenient to stretch the horizontal or the vertical dimensions
2928 of an entire diagram by using spacing commands for rows and/or columns.
2933 \begin_layout Plain Layout
2943 \begin_inset CommandInset citation
2964 \begin_layout Plain Layout
2973 -matrix with row spacing of 1
2974 \begin_inset space ~
2994 allows to modify the space between columns.
2995 Unfortunately, one cannot type
2996 \begin_inset Quotes eld
3006 \begin_inset Quotes erd
3009 into a formula to get the desired matrix because the @-character is interpreted
3018 But there are two other ways of getting the desired matrix:
3021 \begin_layout Itemize
3023 \begin_inset space \space{}
3032 as normal document text, then either highlight it and press
3038 to get a formula, or copy it into an existing formula.
3039 You can now continue as normal.
3040 \begin_inset Newline newline
3044 \begin_inset Note Greyedout
3047 \begin_layout Plain Layout
3052 This method only works for single spacing settings, so using
3053 \begin_inset Newline newline
3066 xymatrix@M=1pt@C=1dd
3069 The method also don't work if you use '!' to get a fixed grid with a defined
3071 \begin_inset space \space{}
3092 \begin_inset Newline newline
3095 For the following matrix, the command
3102 \begin_inset Formula
3104 \xymatrix@C=9pc{A\ar[r]\ar[d] & B\\
3105 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3114 \begin_layout Itemize
3118 \begin_layout Plain Layout
3128 \begin_inset space ~
3131 stores the values for row-spacing and column-spacing in the variables
3132 \begin_inset Newline newline
3148 So one can add the following macro to the preamble (
3150 Layout\SpecialChar menuseparator
3151 Document\SpecialChar menuseparator
3155 \begin_inset Separator parbreak
3162 \begin_layout LyX-Code
3170 \begin_layout LyX-Code
3175 xymatrixrowsep@{#1}}
3178 \begin_layout Standard
3185 can be defined correspondingly by replacing
3198 Now, a figure can be scaled by entering
3200 xyR{ into the formula before the
3204 \begin_layout Plain Layout
3214 Place the cursor inside the matrix, just before the first entry.
3232 Don't forget the backslashes and remember, that the closing brace is automatica
3233 lly supplied by \SpecialChar LyX
3235 Inside the braces enter the dimensions.
3236 \begin_inset Newline newline
3240 \begin_inset Note Greyedout
3243 \begin_layout Plain Layout
3248 these commands affect all following
3252 \begin_layout Plain Layout
3262 Therefore don't forget to reset the values to default after the usage of
3275 \begin_inset Newline newline
3283 Here you see a diagram which is squashed vertically and stretched horizontally
3293 \begin_inset Formula
3295 \xyR{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
3296 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3303 \begin_inset Formula $\xyR{2pc}\xyC{2pc}$
3307 \begin_inset Note Note
3310 \begin_layout Plain Layout
3320 \begin_layout Subsection
3324 \begin_layout Standard
3329 \begin_layout Plain Layout
3338 -command allows the correct positioning of labels along the shaft of arrows.
3339 This feature is sometimes necessary, when the default position of a label
3340 would otherwise clutter the picture, or would even coincide with other
3341 items, such as the intersection of the arrows in the figure below.
3342 In order to shift a label position alongside the shaft of an arrow,
3346 \begin_layout Plain Layout
3356 \begin_inset space ~
3359 allows to prefix the label by a decimal number in parentheses, specifying
3360 the fraction of distance alongside the arrow where the label is to be placed.
3361 For instance, the code
3369 , will place the label on the shaft, but only about one third of the way.
3373 \begin_layout Standard
3374 Doing the same with labels above or below arrows as
3390 , does not work from inside \SpecialChar LyX
3392 Instead, one has to replace the hat-symbol ^, resp.
3393 the underscore _ , by the macros
3427 It is, in fact, possible to enter several labels this way and those labels
3428 are placed correctly, even if the arrow bends.
3429 In the following figure, the bending arrow with its four labels has been
3453 \begin_layout Standard
3454 \begin_inset Formula
3456 \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}}\\
3457 \circ\ar[ur]\sb(0.3)\phi & \bullet
3466 \begin_layout Subsection
3467 Invisible stretched arrows
3470 \begin_layout Standard
3471 A more general trick uses invisible arrows to place any object almost anywhere
3473 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3474 a decimal stretching ratio, e.
3475 \begin_inset space \thinspace{}
3479 \begin_inset space \space{}
3491 Attach a label to this invisible arrow.
3495 \begin_layout Standard
3496 Thus, the down pointing arrow with its label
3497 \begin_inset Formula $\varphi$
3500 at (0.3) of its way along the shaft might as well have been produced by
3501 adding to the regular arrow
3508 \begin_inset Formula $\varphi$
3519 , reaching only 0.6 of the way.
3520 Its label will now appear at 0.3 of the way of the original visible arrow.
3524 \begin_layout Standard
3525 This workaround has two minor drawbacks: First, it does not work with bending
3527 Secondly, prolonging an invisible arrow beyond the normal dimension of
3528 the figure will invisibly extend the figure box, and thereby cause too
3529 much vertical space between the figure and the preceding or the following
3534 \begin_layout Standard
3535 Nevertheless, invisible arrows are an important tool, since they can, in
3536 principle, be used to place information at any chosen place in a diagram.
3537 In the above figure, for instance, we have used an invisible arrow to carry
3544 as label and at the earlier figure we had used an invisible arrow to carry
3546 \begin_inset Quotes eld
3554 \begin_inset Quotes erd
3557 into the center of the figure.
3560 \begin_layout Subsection
3568 \begin_layout Standard
3569 Here we have focused only on the
3575 command, which is just one of the features available in Kris Rose's amazing
3581 \begin_layout Plain Layout
3599 \begin_layout Plain Layout
3611 \begin_inset CommandInset citation
3617 demonstrates many of the advanced possibilities of that package.
3618 Beware, that its style is rather terse and you will likely need a lot of
3619 experimenting and modifying the many worked examples.
3621 \begin_inset CommandInset citation
3631 \begin_layout Plain Layout
3640 -pic to make braids, cobordism, string diagrams, and much more.
3641 You might want to look on
3645 example shipped with \SpecialChar LyX
3646 , which demonstrates how to use more advanced
3650 \begin_layout Plain Layout
3663 \begin_inset space ~
3675 \begin_layout Standard
3676 \begin_inset Newpage newpage
3682 \begin_layout Bibliography
3683 \begin_inset CommandInset bibitem
3684 LatexCommand bibitem
3694 \begin_layout Plain Layout
3708 \begin_inset Newline newline
3712 \begin_inset Flex URL
3715 \begin_layout Plain Layout
3717 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyguide.pdf
3725 \begin_layout Bibliography
3726 \begin_inset CommandInset bibitem
3727 LatexCommand bibitem
3728 key "xypic reference"
3733 Rose and Ross Moore:
3737 \begin_layout Plain Layout
3748 -pic Reference Manual
3751 \begin_inset Newline newline
3755 \begin_inset Flex URL
3758 \begin_layout Plain Layout
3760 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyrefer.pdf
3768 \begin_layout Bibliography
3769 \begin_inset CommandInset bibitem
3770 LatexCommand bibitem
3775 Homepage of the package
3779 \begin_layout Plain Layout
3793 \begin_inset Flex URL
3796 \begin_layout Plain Layout
3798 http://www.ctan.org/pkg/xypic
3806 \begin_layout Bibliography
3807 \begin_inset CommandInset bibitem
3808 LatexCommand bibitem
3809 key "instant-preview"
3813 Homepage of preview-latex:
3814 \begin_inset Newline newline
3818 \begin_inset Flex URL
3821 \begin_layout Plain Layout
3823 http://www.gnu.org/software/auctex/preview-latex.html
3831 \begin_layout Bibliography
3832 \begin_inset CommandInset bibitem
3833 LatexCommand bibitem
3838 Homepage of AUC\SpecialChar TeX
3840 \begin_inset Flex URL
3843 \begin_layout Plain Layout
3845 http://www.gnu.org/software/auctex/
3853 \begin_layout Bibliography
3854 \begin_inset CommandInset bibitem
3855 LatexCommand bibitem
3864 \begin_layout Plain Layout
3879 tutorial with an archive of examples
3882 \begin_inset Newline newline
3886 \begin_inset Flex URL
3889 \begin_layout Plain Layout
3891 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyguide.pdf