1 #LyX 2.3 created this file. For more info see http://www.lyx.org/
5 \save_transient_properties true
6 \origin /systemlyxdir/examples/Graphics_and_Insets/
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
112 \notefontcolor #0000ff
119 \paragraph_separation indent
120 \paragraph_indentation default
122 \math_numbering_side default
123 \quotes_style english
127 \paperpagestyle default
128 \tracking_changes false
129 \output_changes false
142 \begin_layout Plain Layout
151 -pic in \SpecialChar LyX
160 \begin_layout Abstract
161 With the recent versions of \SpecialChar LyX
166 -style installed in the \SpecialChar LaTeX
167 -System, the graph drawing package
171 \begin_layout Plain Layout
180 -pic can be conveniently used inside \SpecialChar LyX
182 Diagrams can be edited and displayed inside the main \SpecialChar LyX
184 Here, we shall describe how to use the
194 inside \SpecialChar LyX
195 in order to draw, to edit and to preview diagrams as typically
196 used in category theory, algebra, and related fields.
200 \begin_layout Abstract
201 \begin_inset CommandInset toc
202 LatexCommand tableofcontents
209 \begin_layout Section
213 \begin_layout Standard
218 -package has long served as a convenient tool for easily constructing graphs
219 and diagrams in \SpecialChar LaTeX
221 Unfortunately, its use in \SpecialChar LyX
222 had long been restricted to the infamous \SpecialChar TeX
224 boxes, meaning that the \SpecialChar LyX
225 editor could only display the \SpecialChar LaTeX
227 the finished diagram.
232 -style of \SpecialChar LaTeX
233 which is part of the AUC\SpecialChar TeX
235 \begin_inset CommandInset citation
242 , finally enables the editing and displaying of
246 -diagrams, constructed, displayed and interactively edited inside \SpecialChar LyX
250 \begin_layout Standard
251 \begin_inset VSpace defskip
257 \begin_layout Standard
259 \begin_inset Graphics
260 filename xyfigure.png
268 \begin_layout Standard
269 \begin_inset VSpace defskip
275 \begin_layout Standard
276 In this note, we describe how
280 \begin_layout Plain Layout
289 -pic can be used from inside \SpecialChar LyX
290 , how diagrams can be created and edited.
291 We have tested the following using \SpecialChar LyX
292 versions 1.3.7 up to 1.6, running under
294 \begin_inset space \thinspace{}
297 XP and under Windows Vista.
301 \begin_layout Standard
302 There are two modes of operations: For a start, and for some first tests,
303 it may be easiest to first enter the
307 \begin_layout Plain Layout
316 -pic code inside the \SpecialChar LyX
317 -window, select it all and convert it to a graphical
318 representation by pressing
331 \begin_layout Plain Layout
340 -pic more frequently, or if you want to modify your initial figure, you
341 will want to assemble and modify your figures using \SpecialChar LyX
346 \begin_layout Standard
347 Once the cursor is moved over a diagram, this is displayed as an array of
348 nodes and arrow-commands.
349 These can be changed interactively.
350 When the cursor leaves the editing area, the diagram reappears.
354 \begin_layout Standard
355 In the first two sections of this documentation, we explain how to use \SpecialChar LyX
357 in the first mentioned mode and we introduce all
361 \begin_layout Plain Layout
370 -pic features that might be of use for drawing commutative diagrams, graphs
373 \begin_inset CommandInset ref
375 reference "sec:math-editor"
379 explains how to use the
383 \begin_layout Plain Layout
392 -pic commands inside a math-editing area.
396 \begin_layout Standard
397 It is not our intention to write another introduction to
401 \begin_layout Plain Layout
410 -pic, rather our motivation is to give an introduction how the most important
411 commands work inside \SpecialChar LyX
412 , since the keystrokes as explained in the
416 \begin_layout Plain Layout
426 \begin_inset CommandInset citation
433 will not always function correctly inside \SpecialChar LyX
438 \begin_layout Section
442 \begin_layout Standard
443 The following requires that the \SpecialChar LaTeX
452 are installed in the \SpecialChar LaTeX
454 They are available from CTAN, see at
455 \begin_inset CommandInset citation
457 key "instant-preview"
464 \begin_inset CommandInset citation
472 After freshly installing them, it may be necessary, to run
474 Tools\SpecialChar menuseparator
477 from the main \SpecialChar LyX
479 The steps to a first diagram output in \SpecialChar LyX
483 \begin_layout Enumerate
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
577 \begin_layout Enumerate
578 Inside your \SpecialChar LyX
579 -Document, enter the text
582 \begin_inset Newline newline
594 \begin_layout Enumerate
595 Select the whole text and choose
597 Insert\SpecialChar menuseparator
598 Math\SpecialChar menuseparator
601 , or use the corresponding keyboard shortcut
609 \begin_layout Enumerate
610 Move the mouse cursor out of the editing box and wait for a split second
611 to see an arrow appear:
612 \begin_inset Formula $\xymatrix{A\ar[r] & B}
620 \begin_layout Section
624 \begin_layout Standard
625 The following diagram, which is taken from the documentation of
629 \begin_layout Plain Layout
639 \begin_inset CommandInset citation
646 by its creator Kristoffer H.
647 Rose, will provide an example for many of the features available with that
652 \begin_layout LyX-Code
656 \begin_inset Newline newline
668 \begin_inset Newline newline
678 \begin_inset Newline newline
694 \begin_inset Newline newline
702 \begin_layout LyX-Code
706 \begin_layout Standard
707 Again, to turn this code into a graphical output, select it all at once
715 up to the closing brace \SpecialChar ldots
720 and turn it into display-math as explained above.
721 A moment after the cursor leaves the math-area, you should see the diagram
722 in its full graphical glory as shown below.
726 \begin_layout Standard
727 \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\
728 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
737 \begin_layout Subsection
738 The matrix layout of diagrams
741 \begin_layout Standard
746 uses a matrix to define the layout of the vertices of a diagram.
747 For the above example, we need a
748 \begin_inset Formula $3\times3$
751 -matrix of which 5 entries are used for the vertices
752 \begin_inset Formula $U$
756 \begin_inset Formula $X\times_{Z}Y$
760 \begin_inset Formula $X$
764 \begin_inset Formula $Y$
768 \begin_inset Formula $Z$
771 , the other positions remaining empty.
772 In this case, the following matrix determines the layout:
775 \begin_layout LyX-Code
779 \begin_inset Newline newline
787 \begin_inset Newline newline
797 \begin_inset Newline newline
803 \begin_layout Standard
804 The pattern should be familiar from \SpecialChar LaTeX
805 : We see three rows, the first two being
806 terminated by the end-of-line-marker
815 Each line consists of entries, separated by the ampersand
823 \begin_layout Subsection
827 \begin_layout Standard
828 Having entered the vertices, we add arrows between them.
833 -command to produce an arrow is
839 , it is entered into the cell of the matrix where the arrow is to start.
840 The target of the arrow is defined by direction commands
857 These can be combined to a path and enclosed in square brackets.
858 As an example, the arrows from the vertex
859 \begin_inset Formula $U$
862 in the upper left corner down and right to the vertices
863 \begin_inset Formula $X\times_{Z}Y$
867 \begin_inset Formula $Y$
871 \begin_inset Formula $X$
874 are, respectively, defined as
893 Thus the above diagram with all arrows added becomes:
896 \begin_layout LyX-Code
900 \begin_inset Newline newline
914 \begin_inset Newline newline
930 \begin_inset Newline newline
938 \begin_layout LyX-Code
939 \begin_inset Formula $\xymatrix{U\ar[ddr]\ar[drr]\ar[dr]\\
940 & X\times_{Z}Y\ar[d]\ar[r] & X\ar[d]\\
949 \begin_layout LyX-Code
953 \begin_layout LyX-Code
957 \begin_layout Subsection
961 \begin_layout Standard
962 Labels are attached to arrows by affixing them as upper or lower indices
978 defines an arrow going one cell down, two to the right and having the label
980 \begin_inset Formula $\varphi$
984 To attach a label below the arrow, make it a lower index as in
993 This explanation is correct only for arrows pointing to the right.
994 More precisely, imagine looking along the arrow in the direction it is
996 Then an upper index places a label to the left and a lower index places
998 Consequently, an arrow pointing from right to left, such as
1009 \begin_inset Formula $\alpha$
1013 \begin_inset Formula $\beta$
1017 \begin_inset space \thinspace{}
1021 \begin_inset space \space{}
1025 \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.}
1029 Using the character | instead of ^ or _ , it is even possible to place the
1030 label right onto the arrow, obscuring part of its shaft.
1034 \begin_layout Standard
1035 Normally, a label is placed halfway between an arrow's start and target
1037 In the first diagram, the central arrow starting in
1038 \begin_inset Formula $U$
1042 \begin_inset Formula $(x,y)$
1045 in the middle of the arrow's shaft, rather than in the middle between the
1046 two objects it connects.
1047 This is achieved by prefixing the label with a minus sign, here:
1056 \begin_layout LyX-Code
1060 \begin_inset Newline newline
1078 \begin_inset Newline newline
1094 \begin_inset Newline newline
1102 \begin_layout LyX-Code
1103 \begin_inset Formula $\xymatrix{U\ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\
1104 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
1113 \begin_layout Standard
1117 \begin_layout Plain Layout
1126 -pic normally permits labels to be shifted towards the tip or towards the
1127 start of an arrow by prefixing the label with a ratio, such as e.
1128 \begin_inset space \thinspace{}
1132 \begin_inset space \space{}
1141 this works only for labels which are placed on top of the arrow, such
1154 \begin_layout Standard
1155 For labels placed to the left or to the right of the arrow this does not
1161 \begin_layout Plain Layout
1170 -pic code such as e.
1171 \begin_inset space \thinspace{}
1175 \begin_inset space \space{}
1194 is not correctly interpreted by \SpecialChar LyX
1196 Two workarounds are suggested in the last section of this note.
1199 \begin_layout Subsection
1203 \begin_layout Standard
1204 Modification of the design, the form or the positioning of arrows are introduced
1210 This is followed by a pair of matching brackets, where the form of the
1223 indicates, whether we want to modify the design, the or the curvature of
1225 Various modifications can be applied to an arrow at the same time.
1228 \begin_layout Subsubsection
1232 \begin_layout Standard
1233 Various designs such as
1249 are possible for the shaft of an arrow.
1250 These can be combined with various ends and various tips.
1251 In general, the design of an arrow is described by following the command
1262 -sign and a pair of braces {\SpecialChar ldots
1263 } containing characters describing the end,
1264 the shaft and the tip of the arrow.
1265 These characters are chosen to give some form of ASCII-rendering of the
1273 produces an arrow with split end, a dotted shaft and double head.
1274 A number of other arrow designs is given in the table below.
1275 Note that the ends of embedding arrows
1276 \begin_inset Formula $\xymatrix{A\ar@{^{(}->}[r] & B}
1280 are described by raising or lowering opening parentheses, such as in
1287 \begin_layout Standard
1289 \begin_inset Tabular
1290 <lyxtabular version="3" rows="11" columns="2">
1291 <features tabularvalignment="middle">
1292 <column alignment="center" valignment="top" width="0pt">
1293 <column alignment="center" valignment="top">
1295 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1298 \begin_layout Plain Layout
1304 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1307 \begin_layout Plain Layout
1308 Source code in \SpecialChar LyX
1316 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1319 \begin_layout Plain Layout
1320 \begin_inset Formula $\xymatrix{\ \ar[r] & \ }
1329 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1332 \begin_layout Plain Layout
1344 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1347 \begin_layout Plain Layout
1348 \begin_inset Formula $\xymatrix{\ \ar@{-->}[r] & \ }
1357 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1360 \begin_layout Plain Layout
1372 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1375 \begin_layout Plain Layout
1376 \begin_inset Formula $\xymatrix{\ \ar@{..>}[r] & \ }
1385 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1388 \begin_layout Plain Layout
1400 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1403 \begin_layout Plain Layout
1404 \begin_inset Formula $\xymatrix{\ \ar@{~>}[r] & \ }
1413 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1416 \begin_layout Plain Layout
1428 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1431 \begin_layout Plain Layout
1432 \begin_inset Formula $\xymatrix{\ \ar@{->>}[r] & \ }
1441 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1444 \begin_layout Plain Layout
1456 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1459 \begin_layout Plain Layout
1460 \begin_inset Formula $\xymatrix{\ \ar@{-->>}[r] & \ }
1469 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1472 \begin_layout Plain Layout
1484 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1487 \begin_layout Plain Layout
1488 \begin_inset Formula $\xymatrix{\ \ar@{>->>}[r] & \ }
1497 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1500 \begin_layout Plain Layout
1512 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1515 \begin_layout Plain Layout
1516 \begin_inset Formula $\xymatrix{\ \ar@{_{(}->}[r] & \ }
1525 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1528 \begin_layout Plain Layout
1540 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1543 \begin_layout Plain Layout
1544 \begin_inset Formula $\xymatrix{\ \ar@{^{(}->}[r] & \ }
1553 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1556 \begin_layout Plain Layout
1568 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1571 \begin_layout Plain Layout
1572 \begin_inset Formula $\xymatrix{\ \ar@{|-|}[r] & \ }
1581 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1584 \begin_layout Plain Layout
1602 \begin_layout Standard
1604 Following the @-character by either a 2, 3, _ or a ^, we can produce arrows
1605 with double, triple shaft or arrows showing only the lower or upper half
1606 of their tips and ends.
1607 Arrows need not have tips nor ends, as the last example shows:
1610 \begin_layout Standard
1612 \begin_inset Tabular
1613 <lyxtabular version="3" rows="8" columns="2">
1614 <features tabularvalignment="middle">
1615 <column alignment="center" valignment="top">
1616 <column alignment="center" valignment="top">
1618 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1621 \begin_layout Plain Layout
1627 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1630 \begin_layout Plain Layout
1631 Source code for \SpecialChar LyX
1639 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1642 \begin_layout Plain Layout
1643 \begin_inset Formula $\xymatrix{\ \ar@2[r] & \ }
1652 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1655 \begin_layout Plain Layout
1667 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1670 \begin_layout Plain Layout
1671 \begin_inset Formula $\xymatrix{\ \ar@3[r] & \ }
1680 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1683 \begin_layout Plain Layout
1695 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1698 \begin_layout Plain Layout
1699 \begin_inset Formula $\xymatrix{\ \ar@_{->}[r] & \ }
1708 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1711 \begin_layout Plain Layout
1723 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1726 \begin_layout Plain Layout
1727 \begin_inset Formula $\xymatrix{\ \ar@^{->}[r] & \ }
1736 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1739 \begin_layout Plain Layout
1751 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1754 \begin_layout Plain Layout
1755 \begin_inset Formula $\xymatrix{\ \ar@^{>>->>}[r] & \ }
1764 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1767 \begin_layout Plain Layout
1772 ar@^{>\SpecialChar ligaturebreak
1773 >->\SpecialChar ligaturebreak
1781 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1784 \begin_layout Plain Layout
1785 \begin_inset Formula $\xymatrix{\ \ar@{^{<}-_{>}}[r] & \ }
1794 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1797 \begin_layout Plain Layout
1809 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1812 \begin_layout Plain Layout
1813 \begin_inset Formula $\xymatrix{\ \ar@2{--}[r] & \ }
1822 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1825 \begin_layout Plain Layout
1843 \begin_layout Subsubsection
1844 Designing your own arrows
1847 \begin_layout Standard
1848 Within certain limits there is even a way to design your own arrows.
1849 Using some the characters
1853 one can even design one's own arrow tips using the
1859 command in the preamble.
1860 For explanations, we refer to the
1866 \begin_layout Plain Layout
1877 -manual, from which we take the example:
1880 \begin_layout Standard
1885 newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
1890 \begin_layout Standard
1892 This defines a new arrow tip, referred to as
1902 and which displays correctly in \SpecialChar LyX
1904 \begin_inset Formula
1906 \xymatrix{A\ar@{-|>}[r] & \ \ B}
1914 \begin_layout Subsection
1918 \begin_layout Standard
1919 Arrows are shifted sideways with the modifier
1924 \begin_inset Formula $\ldots$
1931 where the ellipsis is replaced by a positive or negative measure.
1932 For instance, to design a pair of mutually opposing arrows between two
1933 nodes, we shift them to see them apart.
1934 Note that the direction of the shift (positive) is to the left if one looks
1939 \begin_layout Standard
1955 \begin_layout Standard
1958 \begin_inset Formula
1960 \xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1968 \begin_layout Subsubsection
1969 Inline or centered diagrams
1972 \begin_layout Standard
1973 Arrows and diagrams can be used inline, such as this one:
1974 \begin_inset Formula $\xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1979 When their code is written inside \SpecialChar LyX
1980 as above, select it and choose either
1985 for inline appearance or
1990 Diagrams constructed inline can later be centered, or, conversely, centered
1991 diagrams can be changed to inline formulas with
1993 Edit\SpecialChar menuseparator
1998 \SpecialChar menuseparator
1999 Change Formula Type.
2002 \begin_layout Subsection
2006 \begin_layout Standard
2007 There are two simple methods to make arrows bend.
2008 The first is giving an explicit value by which the midpoint of the arrow's
2009 shaft is raised or depressed, the other is by forcing the arrow to leave
2010 its origin in a prescribed compass direction and to make him enter the
2011 target at another direction.
2012 The necessary bending of the arrow is determined automatically.
2013 We describe both methods.
2016 \begin_layout Subsubsection
2020 \begin_layout Standard
2021 For bending arrows we use the modifier
2026 \begin_inset Formula $\ldots$
2034 The ellipsis stands for a \SpecialChar TeX
2035 -measure which needs to be entered as a lower
2041 , we could simply write, e.
2042 \begin_inset space \thinspace{}
2046 \begin_inset space \space{}
2055 for an arrow bending
2059 downwards, this cannot directly be done in \SpecialChar LyX
2061 It is necessary, to enclose the measure in a pair of braces, such as e.
2062 \begin_inset space \thinspace{}
2066 \begin_inset space \space{}
2076 As an example, here are two opposing arrows between
2077 \begin_inset Formula $A$
2081 \begin_inset Formula $B$
2084 , each bending by .5 pica, given by the following source code:
2087 \begin_layout Standard
2099 \begin_layout Standard
2100 \begin_inset Formula
2102 \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]}
2110 \begin_layout Subsubsection
2111 Specifying exit- and entrance directions
2114 \begin_layout Standard
2115 An alternative for making arrows bend is by specifying their compass direction
2116 as they are leaving their source and their direction from which they enter
2118 Instead of north, north-east, east, etc., the directions are named
2150 , standing for up, up-right, right, down-right, etc..
2151 A direction is specified as
2169 stands for the direction the first object is left and
2173 stands for the direction from which the target is entered.
2174 As an example, we show some bending arrows and a loop, which arises when
2175 we do not specify a target for an arrow, just its incoming and outgoing
2179 \begin_layout Standard
2180 \begin_inset Formula
2182 \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\
2192 \begin_layout LyX-Code
2200 \begin_inset Newline newline
2210 \begin_inset Newline newline
2218 \begin_layout Subsection
2222 \begin_layout Standard
2223 The above example is reminiscent of an automata diagram, except that in
2224 such a diagram states would be enclosed in small circles, with double circles
2225 denoting final states.
2229 \begin_layout Subsubsection
2233 \begin_layout Standard
2238 \begin_layout Plain Layout
2247 -pic, entries can obtain a single or a double frame, such as
2248 \begin_inset Formula $\xymatrix{*+[F]{A}}
2253 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2257 by prefixing an entry with
2265 and enclosing the portion of the entry to be framed in braces.
2266 Normally, the frame will be very tight so that it must be widened by prefixing
2276 Round frames, such as
2277 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2282 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2286 are obtained by specifying the shape as
2291 So the latter figure was constructed as *++[o][F=]{B}.
2292 This way, the following automaton
2295 \begin_layout Standard
2296 \begin_inset Formula
2298 \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]}
2306 \begin_layout Standard
2311 \begin_layout LyX-Code
2321 \begin_layout LyX-Code
2327 \begin_layout LyX-Code
2335 \begin_layout LyX-Code
2339 \begin_layout Standard
2340 The \SpecialChar LaTeX
2352 will make a certain entry style the default, that can, of course be overridden
2353 for individual entries.
2358 entrymodifiers={++[o][F-]}
2360 , all following entries inside
2364 \begin_layout Plain Layout
2373 -matrices would be encircled.
2376 \begin_layout Subsubsection
2380 \begin_layout Standard
2381 Framing a whole rectangle inside an xymatrix is done with the macro pair
2401 The dimension of the rectangle is given as a dotted pair
2402 \begin_inset Formula $P_{0}.P_{1}$
2405 of points denoting the top left and lower right corners of the rectangle.
2406 Each point, in turn,is given as a doubly quoted comma separated pair
2407 \begin_inset Quotes eld
2411 \begin_inset Formula $x,y$
2415 \begin_inset Quotes erd
2419 \begin_inset Formula $x$
2423 \begin_inset Formula $y$
2427 These are followed by the framing commands, to produce figures such as
2429 \begin_inset Formula
2431 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2432 C & \save"1,1"."1,2"*++[F]\frm{}\restore
2449 save"1,1"."2,1"*+[F=]
2462 produces the doubly framed rectangle, and the code for the extra wide horizonta
2473 \begin_inset Newline newline
2478 save"1,1"."1,2"*++[F]
2492 \begin_inset Newline newline
2495 This code can be placed in arbitrary cells of the xymatrix.
2499 \begin_layout Section
2500 Using \SpecialChar LyX
2502 \begin_inset CommandInset label
2504 name "sec:math-editor"
2511 \begin_layout Standard
2512 As an alternative to writing the
2516 code, then transforming it into a math-editing environment by marking it
2525 , one may construct and modify the whole xypic-diagram inside \SpecialChar LyX
2527 We describe the editing steps for a figure just like the one above.
2531 \begin_layout Subsection
2532 Caveat - how to enter braces
2535 \begin_layout Standard
2536 Recall that in \SpecialChar LyX
2537 's math-editor any pair of braces
2545 that are to enclose a macro-parameter must be entered by typing just
2552 The closing brace is automatically supplied and in between a box into which
2553 to the parameter is entered.
2558 \begin_layout Plain Layout
2567 -diagrams, this applies in particular to arrow modifications that are normally
2577 with the ellipsis standing for the description of end, shaft and tip of
2579 Inside the math-editor, enter just
2585 and let \SpecialChar LyX
2586 provide the closing brace and the box into which to enter the
2587 description of the arrow.
2590 \begin_layout Standard
2591 Braces that are entered without the backslash
2597 will just appear as typed, but cannot be used to receive a macro parameter.
2598 They are useful, for instance to denote sets, e.
2599 \begin_inset space \thinspace{}
2603 \begin_inset space \space{}
2617 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2623 \begin_layout Subsection
2624 Setting up the matrix
2627 \begin_layout Standard
2636 open a formula environment and enter:
2644 \begin_inset Formula $\times$
2651 \begin_layout Plain Layout
2661 Add extra rows by typing
2665 and add columns by typing
2671 \begin_layout Standard
2672 At any time, further rows or columns can be entered or deleted using commands
2675 Edit\SpecialChar menuseparator
2679 their shortcuts, beginning with
2683 for the column commands or
2687 for the row commands.
2688 A more direct way uses the icons in the math toolbar once it has been activated
2691 View\SpecialChar menuseparator
2695 \begin_layout Subsection
2696 Entering nodes, arrows and labels
2699 \begin_layout Standard
2700 Type the nodes into the correct positions of the matrix.
2701 If you move the cursor out of the matrix, you should see a first rendering
2703 Next, add the arrows at the nodes from where they should emanate by typing
2720 can be any path made up from the characters
2737 Make sure that the path indeed leads to an existing node within the matrix.
2738 Otherwise, the figure will not display when the cursor leaves the editing
2742 \begin_layout Standard
2743 Next, label the arrows by attaching a label text as upper or lower indices
2744 to the end of the arrow's path.
2745 As always in \SpecialChar LyX
2746 's math editor, an underscore
2750 opens a box for a lower index and a
2754 followed by a space opens a box for an upper index.
2755 You can enter any \SpecialChar LaTeX
2759 \begin_layout Subsection
2763 \begin_layout Standard
2764 Finally, you can modify the appearance of the arrows by entering @-modifiers
2803 The above caveat applies to the first form only.
2804 It must be entered as
2810 with the arrow description entered inside the \SpecialChar LyX
2812 If this box remains empty, you have specified an empty arrow.
2813 This is a useful construction, too, as you will see in the next section.
2817 \begin_layout Standard
2818 The other modifiers,
2846 are typed as shown with the arrow description replacing the ellipsis.
2847 The code for bending arrows, which in
2876 is any valid \SpecialChar TeX
2877 -measure that should be entered as upper or lower index to
2879 Make sure that the ending slash does not end up being part of the upper
2883 \begin_layout Subsection
2884 What if something goes wrong
2887 \begin_layout Standard
2888 When constructing a diagram, you should at times check it by just moving
2889 the cursor out of the editing area to see whether instant preview can successfu
2890 lly convert it into graphical output.
2891 If this does not happen, it may either be that instant preview for some
2892 reason is not aware that it should retranslate the graphics.
2893 Moving the cursor into the editing area and out again sometimes wakes up
2897 \begin_layout Standard
2898 A more serious reason could be a syntactical error in your input (in that
2899 case, the math edition area disappears completely).
2900 If necessary, undo the last editing steps, using
2904 , or try to translate the \SpecialChar LyX
2915 View\SpecialChar menuseparator
2919 There should be some error generated, which hopefully gives you a hint
2920 as to the source of the mistake.
2923 \begin_layout Section
2927 \begin_layout Standard
2928 Certain things do not work correctly inside \SpecialChar LyX
2930 The ones that we (used to) miss most are the horizontal and vertical scaling
2931 of diagrams, and the correct positioning of arrows.
2932 There are some workarounds that we are explaining here.
2936 \begin_layout Subsection
2937 Horizontal and vertical scaling
2940 \begin_layout Standard
2941 It is often convenient to stretch the horizontal or the vertical dimensions
2942 of an entire diagram by using spacing commands for rows and/or columns.
2947 \begin_layout Plain Layout
2957 \begin_inset CommandInset citation
2979 \begin_layout Plain Layout
2988 -matrix with row spacing of 1
2989 \begin_inset space ~
3009 allows to modify the space between columns.
3010 Unfortunately, one cannot type
3011 \begin_inset Quotes eld
3021 \begin_inset Quotes erd
3024 into a formula to get the desired matrix because the @-character is interpreted
3033 But there are two other ways of getting the desired matrix:
3036 \begin_layout Itemize
3038 \begin_inset space \space{}
3047 as normal document text, then either highlight it and press
3053 to get a formula, or copy it into an existing formula.
3054 You can now continue as normal.
3055 \begin_inset Newline newline
3059 \begin_inset Note Greyedout
3062 \begin_layout Plain Layout
3067 This method only works for single spacing settings, so using
3068 \begin_inset Newline newline
3081 xymatrix@M=1pt@C=1dd
3084 The method also don't work if you use '!' to get a fixed grid with a defined
3086 \begin_inset space \space{}
3107 \begin_inset Newline newline
3110 For the following matrix, the command
3117 \begin_inset Formula
3119 \xymatrix@C=9pc{A\ar[r]\ar[d] & B\\
3120 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3129 \begin_layout Itemize
3133 \begin_layout Plain Layout
3143 \begin_inset space ~
3146 stores the values for row-spacing and column-spacing in the variables
3147 \begin_inset Newline newline
3163 So one can add the following macro to the preamble (
3165 Layout\SpecialChar menuseparator
3166 Document\SpecialChar menuseparator
3173 \begin_layout LyX-Code
3181 \begin_layout LyX-Code
3186 xymatrixrowsep@{#1}}
3189 \begin_layout Standard
3196 can be defined correspondingly by replacing
3209 Now, a figure can be scaled by entering
3211 xyR{ into the formula before the
3215 \begin_layout Plain Layout
3225 Place the cursor inside the matrix, just before the first entry.
3243 Don't forget the backslashes and remember, that the closing brace is automatica
3244 lly supplied by \SpecialChar LyX
3246 Inside the braces enter the dimensions.
3247 \begin_inset Newline newline
3251 \begin_inset Note Greyedout
3254 \begin_layout Plain Layout
3259 these commands affect all following
3263 \begin_layout Plain Layout
3273 Therefore don't forget to reset the values to default after the usage of
3286 \begin_inset Newline newline
3294 Here you see a diagram which is squashed vertically and stretched horizontally
3304 \begin_inset Formula
3306 \xyR{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
3307 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3314 \begin_inset Formula $\xyR{2pc}\xyC{2pc}$
3318 \begin_inset Note Note
3321 \begin_layout Plain Layout
3331 \begin_layout Subsection
3335 \begin_layout Standard
3340 \begin_layout Plain Layout
3349 -command allows the correct positioning of labels along the shaft of arrows.
3350 This feature is sometimes necessary, when the default position of a label
3351 would otherwise clutter the picture, or would even coincide with other
3352 items, such as the intersection of the arrows in the figure below.
3353 In order to shift a label position alongside the shaft of an arrow,
3357 \begin_layout Plain Layout
3367 \begin_inset space ~
3370 allows to prefix the label by a decimal number in parentheses, specifying
3371 the fraction of distance alongside the arrow where the label is to be placed.
3372 For instance, the code
3380 , will place the label on the shaft, but only about one third of the way.
3384 \begin_layout Standard
3385 Doing the same with labels above or below arrows as
3401 , does not work from inside \SpecialChar LyX
3403 Instead, one has to replace the hat-symbol ^, resp.
3404 the underscore _ , by the macros
3438 It is, in fact, possible to enter several labels this way and those labels
3439 are placed correctly, even if the arrow bends.
3440 In the following figure, the bending arrow with its four labels has been
3464 \begin_layout Standard
3465 \begin_inset Formula
3467 \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}}\\
3468 \circ\ar[ur]\sb(0.3)\phi & \bullet
3477 \begin_layout Subsection
3478 Invisible stretched arrows
3481 \begin_layout Standard
3482 A more general trick uses invisible arrows to place any object almost anywhere
3484 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3485 a decimal stretching ratio, e.
3486 \begin_inset space \thinspace{}
3490 \begin_inset space \space{}
3502 Attach a label to this invisible arrow.
3506 \begin_layout Standard
3507 Thus, the down pointing arrow with its label
3508 \begin_inset Formula $\varphi$
3511 at (0.3) of its way along the shaft might as well have been produced by
3512 adding to the regular arrow
3519 \begin_inset Formula $\varphi$
3530 , reaching only 0.6 of the way.
3531 Its label will now appear at 0.3 of the way of the original visible arrow.
3535 \begin_layout Standard
3536 This workaround has two minor drawbacks: First, it does not work with bending
3538 Secondly, prolonging an invisible arrow beyond the normal dimension of
3539 the figure will invisibly extend the figure box, and thereby cause too
3540 much vertical space between the figure and the preceding or the following
3545 \begin_layout Standard
3546 Nevertheless, invisible arrows are an important tool, since they can, in
3547 principle, be used to place information at any chosen place in a diagram.
3548 In the above figure, for instance, we have used an invisible arrow to carry
3555 as label and at the earlier figure we had used an invisible arrow to carry
3557 \begin_inset Quotes eld
3565 \begin_inset Quotes erd
3568 into the center of the figure.
3571 \begin_layout Subsection
3579 \begin_layout Standard
3580 Here we have focused only on the
3586 command, which is just one of the features available in Kris Rose's amazing
3591 \begin_layout Plain Layout
3605 \begin_layout Plain Layout
3615 \begin_inset CommandInset citation
3622 demonstrates many of the advanced possibilities of that package.
3623 Beware, that its style is rather terse and you will likely need a lot of
3624 experimenting and modifying the many worked examples.
3626 \begin_inset CommandInset citation
3637 \begin_layout Plain Layout
3646 -pic to make braids, cobordism, string diagrams, and much more.
3647 You might want to look on
3651 example shipped with \SpecialChar LyX
3652 , which demonstrates how to use more advanced
3656 \begin_layout Plain Layout
3669 \begin_inset space ~
3681 \begin_layout Standard
3682 \begin_inset Newpage newpage
3688 \begin_layout Bibliography
3689 \begin_inset CommandInset bibitem
3690 LatexCommand bibitem
3701 \begin_layout Plain Layout
3715 \begin_inset Newline newline
3719 \begin_inset Flex URL
3722 \begin_layout Plain Layout
3724 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyguide.pdf
3732 \begin_layout Bibliography
3733 \begin_inset CommandInset bibitem
3734 LatexCommand bibitem
3735 key "xypic reference"
3741 Rose and Ross Moore:
3745 \begin_layout Plain Layout
3756 -pic Reference Manual
3759 \begin_inset Newline newline
3763 \begin_inset Flex URL
3766 \begin_layout Plain Layout
3768 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyrefer.pdf
3776 \begin_layout Bibliography
3777 \begin_inset CommandInset bibitem
3778 LatexCommand bibitem
3784 Homepage of the package
3788 \begin_layout Plain Layout
3802 \begin_inset Flex URL
3805 \begin_layout Plain Layout
3807 https://www.ctan.org/pkg/xypic
3815 \begin_layout Bibliography
3816 \begin_inset CommandInset bibitem
3817 LatexCommand bibitem
3818 key "instant-preview"
3823 Homepage of preview-latex:
3824 \begin_inset Newline newline
3828 \begin_inset Flex URL
3831 \begin_layout Plain Layout
3833 https://www.gnu.org/software/auctex/preview-latex.html
3841 \begin_layout Bibliography
3842 \begin_inset CommandInset bibitem
3843 LatexCommand bibitem
3849 Homepage of AUC\SpecialChar TeX
3851 \begin_inset Flex URL
3854 \begin_layout Plain Layout
3856 https://www.gnu.org/software/auctex/
3864 \begin_layout Bibliography
3865 \begin_inset CommandInset bibitem
3866 LatexCommand bibitem
3876 \begin_layout Plain Layout
3891 tutorial with an archive of examples
3894 \begin_inset Newline newline
3898 \begin_inset Flex URL
3901 \begin_layout Plain Layout
3903 https://web.archive.org/web/20080222044349/https://www.dpmms.cam.ac.uk/~al366/xytutori