1 #LyX 2.4 created this file. For more info see https://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 no
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
65 \font_typewriter_osf false
66 \font_sf_scale 100 100
67 \font_tt_scale 100 100
69 \use_dash_ligatures false
71 \default_output_format default
73 \bibtex_command default
74 \index_command default
78 \pdf_title "Using XY-pc in LyX"
79 \pdf_author "H. Peter Gumm"
80 \pdf_subject "LyX's XY-pic manual"
81 \pdf_keywords "LyX, documentation"
83 \pdf_bookmarksnumbered true
84 \pdf_bookmarksopen true
85 \pdf_bookmarksopenlevel 2
90 \pdf_pdfusetitle false
91 \pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue,pdfpagelayout=OneColumn, pdfnewwindow=true,pdfstartview=XYZ, plainpages=false"
94 \use_package amsmath 1
95 \use_package amssymb 1
98 \use_package mathdots 1
99 \use_package mathtools 1
100 \use_package mhchem 1
101 \use_package stackrel 1
102 \use_package stmaryrd 1
103 \use_package undertilde 1
105 \cite_engine_type default
109 \paperorientation portrait
115 \notefontcolor #0000ff
122 \paragraph_separation indent
123 \paragraph_indentation default
125 \math_numbering_side default
126 \quotes_style english
130 \paperpagestyle default
132 \tracking_changes false
133 \output_changes false
135 \postpone_fragile_content false
139 \docbook_table_output 0
140 \docbook_mathml_prefix 1
150 \begin_layout Plain Layout
159 -pic in \SpecialChar LyX
168 \begin_layout Abstract
169 With the recent versions of \SpecialChar LyX
174 -style installed in the \SpecialChar LaTeX
176 the graph drawing package
180 \begin_layout Plain Layout
189 -pic can be conveniently used inside \SpecialChar LyX
191 Diagrams can be edited and displayed inside the main \SpecialChar LyX
194 we shall describe how to use the
204 inside \SpecialChar LyX
206 to edit and to preview diagrams as typically used in category theory,
212 \begin_layout Abstract
213 \begin_inset CommandInset toc
214 LatexCommand tableofcontents
221 \begin_layout Section
225 \begin_layout Standard
230 -package has long served as a convenient tool for easily constructing graphs and diagrams in \SpecialChar LaTeX
233 its use in \SpecialChar LyX
234 had long been restricted to the infamous \SpecialChar TeX
236 meaning that the \SpecialChar LyX
237 editor could only display the \SpecialChar LaTeX
238 -source and not the finished diagram.
243 -style of \SpecialChar LaTeX
244 which is part of the AUC\SpecialChar TeX
246 \begin_inset CommandInset citation
254 finally enables the editing and displaying of
260 displayed and interactively edited inside \SpecialChar LyX
264 \begin_layout Standard
265 \begin_inset VSpace defskip
271 \begin_layout Standard
273 \begin_inset Graphics
274 filename xyfigure.png
282 \begin_layout Standard
283 \begin_inset VSpace defskip
289 \begin_layout Standard
295 \begin_layout Plain Layout
304 -pic can be used from inside \SpecialChar LyX
306 how diagrams can be created and edited.
307 We have tested the following using \SpecialChar LyX
308 versions 1.3.7 up to 1.6,
309 running under Windows
310 \begin_inset space \thinspace{}
313 XP and under Windows Vista.
317 \begin_layout Standard
318 There are two modes of operations:
320 and for some first tests,
321 it may be easiest to first enter the
325 \begin_layout Plain Layout
334 -pic code inside the \SpecialChar LyX
336 select it all and convert it to a graphical representation by pressing
349 \begin_layout Plain Layout
358 -pic more frequently,
359 or if you want to modify your initial figure,
360 you will want to assemble and modify your figures using \SpecialChar LyX
365 \begin_layout Standard
366 Once the cursor is moved over a diagram,
367 this is displayed as an array of nodes and arrow-commands.
368 These can be changed interactively.
369 When the cursor leaves the editing area,
370 the diagram reappears.
374 \begin_layout Standard
375 In the first two sections of this documentation,
376 we explain how to use \SpecialChar LyX
377 in the first mentioned mode and we introduce all
381 \begin_layout Plain Layout
390 -pic features that might be of use for drawing commutative diagrams,
393 \begin_inset CommandInset ref
395 reference "sec:math-editor"
400 explains how to use the
404 \begin_layout Plain Layout
413 -pic commands inside a math-editing area.
417 \begin_layout Standard
418 It is not our intention to write another introduction to
422 \begin_layout Plain Layout
432 rather our motivation is to give an introduction how the most important commands work inside \SpecialChar LyX
434 since the keystrokes as explained in the
438 \begin_layout Plain Layout
448 \begin_inset CommandInset citation
455 will not always function correctly inside \SpecialChar LyX
460 \begin_layout Section
464 \begin_layout Standard
465 The following requires that the \SpecialChar LaTeX
474 are installed in the \SpecialChar LaTeX
476 They are available from CTAN,
478 \begin_inset CommandInset citation
480 key "instant-preview"
488 \begin_inset CommandInset citation
496 After freshly installing them,
500 Tools\SpecialChar menuseparator
503 from the main \SpecialChar LyX
505 The steps to a first diagram output in \SpecialChar LyX
509 \begin_layout Enumerate
516 \begin_layout Enumerate
517 Open \SpecialChar LyX
521 Tools\SpecialChar menuseparator
522 Preferences\SpecialChar menuseparator
523 Look and Feel\SpecialChar menuseparator
533 \begin_layout Enumerate
536 Document\SpecialChar menuseparator
537 Settings\SpecialChar menuseparator
547 Use AMS Math package automatically
556 \begin_layout Enumerate
562 works by opening a \SpecialChar LyX
563 -document and entering any math-formula,
565 \begin_inset space \thinspace{}
569 \begin_inset space \space{}
573 \begin_inset Formula $a+b=c$
580 \begin_layout Enumerate
581 Move the cursor out of the formula,
582 and watch it change its appearance to look just like in the finished DVI- or PostScript document.
587 \begin_layout Enumerate
592 \begin_layout Plain Layout
607 \begin_layout Enumerate
608 Inside your \SpecialChar LyX
613 \begin_inset Newline newline
625 \begin_layout Enumerate
626 Select the whole text and choose
628 Insert\SpecialChar menuseparator
629 Math\SpecialChar menuseparator
633 or use the corresponding keyboard shortcut
641 \begin_layout Enumerate
642 Move the mouse cursor out of the editing box and wait for a split second to see an arrow appear:
644 \begin_inset Formula $\xymatrix{A\ar[r] & B}
652 \begin_layout Section
656 \begin_layout Standard
657 The following diagram,
658 which is taken from the documentation of
662 \begin_layout Plain Layout
672 \begin_inset CommandInset citation
679 by its creator Kristoffer H.
681 will provide an example for many of the features available with that package.
686 \begin_layout LyX-Code
690 \begin_inset Newline newline
702 \begin_inset Newline newline
712 \begin_inset Newline newline
728 \begin_inset Newline newline
736 \begin_layout LyX-Code
740 \begin_layout Standard
742 to turn this code into a graphical output,
743 select it all at once starting from the
750 up to the closing brace \SpecialChar ldots
755 and turn it into display-math as explained above.
756 A moment after the cursor leaves the math-area,
757 you should see the diagram in its full graphical glory as shown below.
761 \begin_layout Standard
762 \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\
763 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
772 \begin_layout Subsection
773 The matrix layout of diagrams
776 \begin_layout Standard
781 uses a matrix to define the layout of the vertices of a diagram.
782 For the above example,
784 \begin_inset Formula $3\times3$
787 -matrix of which 5 entries are used for the vertices
788 \begin_inset Formula $U$
793 \begin_inset Formula $X\times_{Z}Y$
798 \begin_inset Formula $X$
803 \begin_inset Formula $Y$
808 \begin_inset Formula $Z$
812 the other positions remaining empty.
814 the following matrix determines the layout:
817 \begin_layout LyX-Code
821 \begin_inset Newline newline
829 \begin_inset Newline newline
839 \begin_inset Newline newline
845 \begin_layout Standard
846 The pattern should be familiar from \SpecialChar LaTeX
849 the first two being terminated by the end-of-line-marker
858 Each line consists of entries,
859 separated by the ampersand
867 \begin_layout Subsection
871 \begin_layout Standard
872 Having entered the vertices,
873 we add arrows between them.
878 -command to produce an arrow is
885 it is entered into the cell of the matrix where the arrow is to start.
886 The target of the arrow is defined by direction commands
904 These can be combined to a path and enclosed in square brackets.
906 the arrows from the vertex
907 \begin_inset Formula $U$
910 in the upper left corner down and right to the vertices
911 \begin_inset Formula $X\times_{Z}Y$
916 \begin_inset Formula $Y$
921 \begin_inset Formula $X$
946 Thus the above diagram with all arrows added becomes:
949 \begin_layout LyX-Code
953 \begin_inset Newline newline
967 \begin_inset Newline newline
983 \begin_inset Newline newline
991 \begin_layout LyX-Code
992 \begin_inset Formula $\xymatrix{U\ar[ddr]\ar[drr]\ar[dr]\\
993 & X\times_{Z}Y\ar[d]\ar[r] & X\ar[d]\\
1002 \begin_layout LyX-Code
1006 \begin_layout LyX-Code
1010 \begin_layout Subsection
1014 \begin_layout Standard
1015 Labels are attached to arrows by affixing them as upper or lower indices to the
1031 defines an arrow going one cell down,
1032 two to the right and having the label
1033 \begin_inset Formula $\varphi$
1037 To attach a label below the arrow,
1038 make it a lower index as in
1047 This explanation is correct only for arrows pointing to the right.
1049 imagine looking along the arrow in the direction it is pointing.
1050 Then an upper index places a label to the left and a lower index places it to the right.
1052 an arrow pointing from right to left,
1064 \begin_inset Formula $\alpha$
1068 \begin_inset Formula $\beta$
1073 \begin_inset space \thinspace{}
1077 \begin_inset space \space{}
1081 \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.}
1085 Using the character | instead of ^ or _ ,
1086 it is even possible to place the label right onto the arrow,
1087 obscuring part of its shaft.
1091 \begin_layout Standard
1093 a label is placed halfway between an arrow's start and target objects.
1094 In the first diagram,
1095 the central arrow starting in
1096 \begin_inset Formula $U$
1100 \begin_inset Formula $(x,y)$
1103 in the middle of the arrow's shaft,
1104 rather than in the middle between the two objects it connects.
1105 This is achieved by prefixing the label with a minus sign,
1116 \begin_layout LyX-Code
1120 \begin_inset Newline newline
1138 \begin_inset Newline newline
1154 \begin_inset Newline newline
1162 \begin_layout LyX-Code
1163 \begin_inset Formula $\xymatrix{U\ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\
1164 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
1173 \begin_layout Standard
1177 \begin_layout Plain Layout
1186 -pic normally permits labels to be shifted towards the tip or towards the start of an arrow by prefixing the label with a ratio,
1188 \begin_inset space \thinspace{}
1192 \begin_inset space \space{}
1201 this works only for labels which are placed on top of the arrow,
1214 \begin_layout Standard
1215 For labels placed to the left or to the right of the arrow this does not work.
1220 \begin_layout Plain Layout
1229 -pic code such as e.
1230 \begin_inset space \thinspace{}
1234 \begin_inset space \space{}
1253 is not correctly interpreted by \SpecialChar LyX
1255 Two workarounds are suggested in the last section of this note.
1258 \begin_layout Subsection
1262 \begin_layout Standard
1263 Modification of the design,
1264 the form or the positioning of arrows are introduced by the
1269 This is followed by a pair of matching brackets,
1270 where the form of the bracket pair,
1284 whether we want to modify the design,
1285 the or the curvature of the arrow.
1286 Various modifications can be applied to an arrow at the same time.
1289 \begin_layout Subsubsection
1293 \begin_layout Standard
1294 Various designs such as
1312 are possible for the shaft of an arrow.
1313 These can be combined with various ends and various tips.
1315 the design of an arrow is described by following the command
1325 -sign and a pair of braces {\SpecialChar ldots
1326 } containing characters describing the end,
1327 the shaft and the tip of the arrow.
1328 These characters are chosen to give some form of ASCII-rendering of the real thing.
1335 produces an arrow with split end,
1336 a dotted shaft and double head.
1337 A number of other arrow designs is given in the table below.
1338 Note that the ends of embedding arrows
1339 \begin_inset Formula $\xymatrix{A\ar@{^{(}->}[r] & B}
1343 are described by raising or lowering opening parentheses,
1351 \begin_layout Standard
1353 \begin_inset Tabular
1354 <lyxtabular version="3" rows="11" columns="2">
1355 <features tabularvalignment="middle">
1356 <column alignment="center" valignment="top" width="0pt">
1357 <column alignment="center" valignment="top">
1359 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1362 \begin_layout Plain Layout
1368 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1371 \begin_layout Plain Layout
1372 Source code in \SpecialChar LyX
1380 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1383 \begin_layout Plain Layout
1384 \begin_inset Formula $\xymatrix{\ \ar[r] & \ }
1393 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1396 \begin_layout Plain Layout
1408 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1411 \begin_layout Plain Layout
1412 \begin_inset Formula $\xymatrix{\ \ar@{-->}[r] & \ }
1421 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1424 \begin_layout Plain Layout
1436 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1439 \begin_layout Plain Layout
1440 \begin_inset Formula $\xymatrix{\ \ar@{..>}[r] & \ }
1449 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1452 \begin_layout Plain Layout
1464 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1467 \begin_layout Plain Layout
1468 \begin_inset Formula $\xymatrix{\ \ar@{~>}[r] & \ }
1477 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1480 \begin_layout Plain Layout
1492 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1495 \begin_layout Plain Layout
1496 \begin_inset Formula $\xymatrix{\ \ar@{->>}[r] & \ }
1505 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1508 \begin_layout Plain Layout
1520 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1523 \begin_layout Plain Layout
1524 \begin_inset Formula $\xymatrix{\ \ar@{-->>}[r] & \ }
1533 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1536 \begin_layout Plain Layout
1548 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1551 \begin_layout Plain Layout
1552 \begin_inset Formula $\xymatrix{\ \ar@{>->>}[r] & \ }
1561 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1564 \begin_layout Plain Layout
1576 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1579 \begin_layout Plain Layout
1580 \begin_inset Formula $\xymatrix{\ \ar@{_{(}->}[r] & \ }
1589 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1592 \begin_layout Plain Layout
1604 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1607 \begin_layout Plain Layout
1608 \begin_inset Formula $\xymatrix{\ \ar@{^{(}->}[r] & \ }
1617 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1620 \begin_layout Plain Layout
1632 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1635 \begin_layout Plain Layout
1636 \begin_inset Formula $\xymatrix{\ \ar@{|-|}[r] & \ }
1645 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1648 \begin_layout Plain Layout
1666 \begin_layout Standard
1668 Following the @-character by either a 2,
1671 we can produce arrows with double,
1672 triple shaft or arrows showing only the lower or upper half of their tips and ends.
1673 Arrows need not have tips nor ends,
1674 as the last example shows:
1677 \begin_layout Standard
1679 \begin_inset Tabular
1680 <lyxtabular version="3" rows="8" columns="2">
1681 <features tabularvalignment="middle">
1682 <column alignment="center" valignment="top">
1683 <column alignment="center" valignment="top">
1685 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1688 \begin_layout Plain Layout
1694 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1697 \begin_layout Plain Layout
1698 Source code for \SpecialChar LyX
1706 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1709 \begin_layout Plain Layout
1710 \begin_inset Formula $\xymatrix{\ \ar@2[r] & \ }
1719 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1722 \begin_layout Plain Layout
1734 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1737 \begin_layout Plain Layout
1738 \begin_inset Formula $\xymatrix{\ \ar@3[r] & \ }
1747 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1750 \begin_layout Plain Layout
1762 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1765 \begin_layout Plain Layout
1766 \begin_inset Formula $\xymatrix{\ \ar@_{->}[r] & \ }
1775 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1778 \begin_layout Plain Layout
1790 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1793 \begin_layout Plain Layout
1794 \begin_inset Formula $\xymatrix{\ \ar@^{->}[r] & \ }
1803 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1806 \begin_layout Plain Layout
1818 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1821 \begin_layout Plain Layout
1822 \begin_inset Formula $\xymatrix{\ \ar@^{>>->>}[r] & \ }
1831 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1834 \begin_layout Plain Layout
1839 ar@^{>\SpecialChar ligaturebreak
1840 >->\SpecialChar ligaturebreak
1848 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1851 \begin_layout Plain Layout
1852 \begin_inset Formula $\xymatrix{\ \ar@{^{<}-_{>}}[r] & \ }
1861 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1864 \begin_layout Plain Layout
1876 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1879 \begin_layout Plain Layout
1880 \begin_inset Formula $\xymatrix{\ \ar@2{--}[r] & \ }
1889 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1892 \begin_layout Plain Layout
1910 \begin_layout Subsubsection
1911 Designing your own arrows
1914 \begin_layout Standard
1915 Within certain limits there is even a way to design your own arrows.
1916 Using some the characters
1920 one can even design one's own arrow tips using the
1926 command in the preamble.
1934 \begin_layout Plain Layout
1946 from which we take the example:
1950 \begin_layout Standard
1955 newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
1960 \begin_layout Standard
1962 This defines a new arrow tip,
1973 and which displays correctly in \SpecialChar LyX
1975 \begin_inset Formula
1977 \xymatrix{A\ar@{-|>}[r] & \ \ B}
1985 \begin_layout Subsection
1989 \begin_layout Standard
1990 Arrows are shifted sideways with the modifier
1995 \begin_inset Formula $\ldots$
2002 where the ellipsis is replaced by a positive or negative measure.
2004 to design a pair of mutually opposing arrows between two nodes,
2005 we shift them to see them apart.
2006 Note that the direction of the shift (positive) is to the left if one looks along the arrow.
2010 \begin_layout Standard
2026 \begin_layout Standard
2029 \begin_inset Formula
2031 \xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
2039 \begin_layout Subsubsection
2040 Inline or centered diagrams
2043 \begin_layout Standard
2044 Arrows and diagrams can be used inline,
2047 \begin_inset Formula $\xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
2052 When their code is written inside \SpecialChar LyX
2054 select it and choose either
2058 for inline appearance or
2063 Diagrams constructed inline can later be centered,
2066 centered diagrams can be changed to inline formulas with
2068 Edit\SpecialChar menuseparator
2073 \SpecialChar menuseparator
2074 Change Formula Type.
2077 \begin_layout Subsection
2081 \begin_layout Standard
2082 There are two simple methods to make arrows bend.
2083 The first is giving an explicit value by which the midpoint of the arrow's shaft is raised or depressed,
2084 the other is by forcing the arrow to leave its origin in a prescribed compass direction and to make him enter the target at another direction.
2085 The necessary bending of the arrow is determined automatically.
2086 We describe both methods.
2089 \begin_layout Subsubsection
2093 \begin_layout Standard
2094 For bending arrows we use the modifier
2099 \begin_inset Formula $\ldots$
2107 The ellipsis stands for a \SpecialChar TeX
2108 -measure which needs to be entered as a lower or upper index.
2114 we could simply write,
2116 \begin_inset space \thinspace{}
2120 \begin_inset space \space{}
2129 for an arrow bending
2134 this cannot directly be done in \SpecialChar LyX
2137 to enclose the measure in a pair of braces,
2139 \begin_inset space \thinspace{}
2143 \begin_inset space \space{}
2154 here are two opposing arrows between
2155 \begin_inset Formula $A$
2159 \begin_inset Formula $B$
2163 each bending by .5 pica,
2164 given by the following source code:
2168 \begin_layout Standard
2180 \begin_layout Standard
2181 \begin_inset Formula
2183 \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]}
2191 \begin_layout Subsubsection
2192 Specifying exit- and entrance directions
2195 \begin_layout Standard
2196 An alternative for making arrows bend is by specifying their compass direction as they are leaving their source and their direction from which they enter their target.
2201 the directions are named
2246 A direction is specified as
2264 stands for the direction the first object is left and
2268 stands for the direction from which the target is entered.
2270 we show some bending arrows and a loop,
2271 which arises when we do not specify a target for an arrow,
2272 just its incoming and outgoing direction:
2275 \begin_layout Standard
2276 \begin_inset Formula
2278 \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\
2288 \begin_layout LyX-Code
2296 \begin_inset Newline newline
2306 \begin_inset Newline newline
2314 \begin_layout Subsection
2318 \begin_layout Standard
2319 The above example is reminiscent of an automata diagram,
2320 except that in such a diagram states would be enclosed in small circles,
2321 with double circles denoting final states.
2325 \begin_layout Subsubsection
2329 \begin_layout Standard
2334 \begin_layout Plain Layout
2344 entries can obtain a single or a double frame,
2346 \begin_inset Formula $\xymatrix{*+[F]{A}}
2351 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2355 by prefixing an entry with
2363 and enclosing the portion of the entry to be framed in braces.
2365 the frame will be very tight so that it must be widened by prefixing with
2376 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2381 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2385 are obtained by specifying the shape as
2390 So the latter figure was constructed as *++[o][F=]{B}.
2392 the following automaton
2395 \begin_layout Standard
2396 \begin_inset Formula
2398 \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]}
2406 \begin_layout Standard
2411 \begin_layout LyX-Code
2421 \begin_layout LyX-Code
2427 \begin_layout LyX-Code
2435 \begin_layout LyX-Code
2439 \begin_layout Standard
2440 The \SpecialChar LaTeX
2452 will make a certain entry style the default,
2454 of course be overridden for individual entries.
2460 entrymodifiers={++[o][F-]}
2463 all following entries inside
2467 \begin_layout Plain Layout
2476 -matrices would be encircled.
2479 \begin_layout Subsubsection
2483 \begin_layout Standard
2484 Framing a whole rectangle inside an xymatrix is done with the macro pair
2503 The dimension of the rectangle is given as a dotted pair
2504 \begin_inset Formula $P_{0}.P_{1}$
2507 of points denoting the top left and lower right corners of the rectangle.
2509 in turn,is given as a doubly quoted comma separated pair
2510 \begin_inset Quotes eld
2514 \begin_inset Formula $x,y$
2518 \begin_inset Quotes erd
2522 \begin_inset Formula $x$
2526 \begin_inset Formula $y$
2530 These are followed by the framing commands,
2531 to produce figures such as the following:
2533 \begin_inset Formula
2535 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2536 C & \save"1,1"."1,2"*++[F]\frm{}\restore
2554 save"1,1"."2,1"*+[F=]
2567 produces the doubly framed rectangle,
2568 and the code for the extra wide horizontal rectangle is
2578 \begin_inset Newline newline
2583 save"1,1"."1,2"*++[F]
2597 \begin_inset Newline newline
2600 This code can be placed in arbitrary cells of the xymatrix.
2604 \begin_layout Section
2605 Using \SpecialChar LyX
2607 \begin_inset CommandInset label
2609 name "sec:math-editor"
2616 \begin_layout Standard
2617 As an alternative to writing the
2622 then transforming it into a math-editing environment by marking it and applying
2632 one may construct and modify the whole xypic-diagram inside \SpecialChar LyX
2634 We describe the editing steps for a figure just like the one above.
2638 \begin_layout Subsection
2639 Caveat - how to enter braces
2642 \begin_layout Standard
2643 Recall that in \SpecialChar LyX
2644 's math-editor any pair of braces
2652 that are to enclose a macro-parameter must be entered by typing just
2659 The closing brace is automatically supplied and in between a box into which to the parameter is entered.
2664 \begin_layout Plain Layout
2674 this applies in particular to arrow modifications that are normally given in the form
2683 with the ellipsis standing for the description of end,
2684 shaft and tip of the arrow.
2685 Inside the math-editor,
2692 and let \SpecialChar LyX
2693 provide the closing brace and the box into which to enter the description of the arrow.
2696 \begin_layout Standard
2697 Braces that are entered without the backslash
2703 will just appear as typed,
2704 but cannot be used to receive a macro parameter.
2706 for instance to denote sets,
2708 \begin_inset space \thinspace{}
2712 \begin_inset space \space{}
2726 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2732 \begin_layout Subsection
2733 Setting up the matrix
2736 \begin_layout Standard
2745 open a formula environment and enter:
2754 \begin_inset Formula $\times$
2761 \begin_layout Plain Layout
2771 Add extra rows by typing
2775 and add columns by typing
2781 \begin_layout Standard
2783 further rows or columns can be entered or deleted using commands available from
2785 Edit\SpecialChar menuseparator
2795 for the column commands or
2799 for the row commands.
2800 A more direct way uses the icons in the math toolbar once it has been activated via
2802 View\SpecialChar menuseparator
2806 \begin_layout Subsection
2811 \begin_layout Standard
2812 Type the nodes into the correct positions of the matrix.
2813 If you move the cursor out of the matrix,
2814 you should see a first rendering of the node layout.
2816 add the arrows at the nodes from where they should emanate by typing
2833 can be any path made up from the characters
2853 Make sure that the path indeed leads to an existing node within the matrix.
2855 the figure will not display when the cursor leaves the editing area.
2858 \begin_layout Standard
2860 label the arrows by attaching a label text as upper or lower indices to the end of the arrow's path.
2861 As always in \SpecialChar LyX
2867 opens a box for a lower index and a
2871 followed by a space opens a box for an upper index.
2872 You can enter any \SpecialChar LaTeX
2876 \begin_layout Subsection
2880 \begin_layout Standard
2882 you can modify the appearance of the arrows by entering @-modifiers
2922 The above caveat applies to the first form only.
2923 It must be entered as
2929 with the arrow description entered inside the \SpecialChar LyX
2931 If this box remains empty,
2932 you have specified an empty arrow.
2933 This is a useful construction,
2935 as you will see in the next section.
2939 \begin_layout Standard
2940 The other modifiers,
2970 are typed as shown with the arrow description replacing the ellipsis.
2971 The code for bending arrows,
3001 is any valid \SpecialChar TeX
3002 -measure that should be entered as upper or lower index to the first slash /.
3003 Make sure that the ending slash does not end up being part of the upper or lower index.
3006 \begin_layout Subsection
3007 What if something goes wrong
3010 \begin_layout Standard
3011 When constructing a diagram,
3012 you should at times check it by just moving the cursor out of the editing area to see whether instant preview can successfully convert it into graphical output.
3013 If this does not happen,
3014 it may either be that instant preview for some reason is not aware that it should retranslate the graphics.
3015 Moving the cursor into the editing area and out again sometimes wakes up instant preview.
3018 \begin_layout Standard
3019 A more serious reason could be a syntactical error in your input (in that case,
3020 the math edition area disappears completely).
3022 undo the last editing steps,
3028 or try to translate the \SpecialChar LyX
3039 View\SpecialChar menuseparator
3043 There should be some error generated,
3044 which hopefully gives you a hint as to the source of the mistake.
3047 \begin_layout Section
3051 \begin_layout Standard
3052 Certain things do not work correctly inside \SpecialChar LyX
3054 The ones that we (used to) miss most are the horizontal and vertical scaling of diagrams,
3055 and the correct positioning of arrows.
3056 There are some workarounds that we are explaining here.
3060 \begin_layout Subsection
3061 Horizontal and vertical scaling
3064 \begin_layout Standard
3065 It is often convenient to stretch the horizontal or the vertical dimensions of an entire diagram by using spacing commands for rows and/or columns.
3070 \begin_layout Plain Layout
3081 \begin_inset CommandInset citation
3105 \begin_layout Plain Layout
3114 -matrix with row spacing of 1
3115 \begin_inset space ~
3136 allows to modify the space between columns.
3139 \begin_inset Quotes eld
3149 \begin_inset Quotes erd
3152 into a formula to get the desired matrix because the @-character is interpreted by \SpecialChar LyX
3160 But there are two other ways of getting the desired matrix:
3163 \begin_layout Itemize
3165 \begin_inset space \space{}
3174 as normal document text,
3175 then either highlight it and press
3182 or copy it into an existing formula.
3183 You can now continue as normal.
3184 \begin_inset Newline newline
3188 \begin_inset Note Greyedout
3191 \begin_layout Plain Layout
3197 This method only works for single spacing settings,
3199 \begin_inset Newline newline
3212 xymatrix@M=1pt@C=1dd
3215 The method also don't work if you use '!' to get a fixed grid with a defined dimension,
3217 \begin_inset space \space{}
3238 \begin_inset Newline newline
3241 For the following matrix,
3249 \begin_inset Formula
3251 \xymatrix@C=9pc{A\ar[r]\ar[d] & B\\
3252 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3261 \begin_layout Itemize
3265 \begin_layout Plain Layout
3275 \begin_inset space ~
3278 stores the values for row-spacing and column-spacing in the variables
3279 \begin_inset Newline newline
3295 So one can add the following macro to the preamble (
3297 Layout\SpecialChar menuseparator
3298 Document\SpecialChar menuseparator
3305 \begin_layout LyX-Code
3313 \begin_layout LyX-Code
3318 xymatrixrowsep@{#1}}
3321 \begin_layout Standard
3328 can be defined correspondingly by replacing
3342 a figure can be scaled by entering
3344 xyR{ into the formula before the
3348 \begin_layout Plain Layout
3358 Place the cursor inside the matrix,
3359 just before the first entry.
3377 Don't forget the backslashes and remember,
3378 that the closing brace is automatically supplied by \SpecialChar LyX
3380 Inside the braces enter the dimensions.
3381 \begin_inset Newline newline
3385 \begin_inset Note Greyedout
3388 \begin_layout Plain Layout
3394 these commands affect all following
3398 \begin_layout Plain Layout
3408 Therefore don't forget to reset the values to default after the usage of
3420 \begin_inset Newline newline
3428 Here you see a diagram which is squashed vertically and stretched horizontally with
3437 \begin_inset Formula
3439 \xyR{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
3440 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3447 \begin_inset Formula $\xyR{2pc}\xyC{2pc}$
3451 \begin_inset Note Note
3454 \begin_layout Plain Layout
3464 \begin_layout Subsection
3468 \begin_layout Standard
3473 \begin_layout Plain Layout
3482 -command allows the correct positioning of labels along the shaft of arrows.
3483 This feature is sometimes necessary,
3484 when the default position of a label would otherwise clutter the picture,
3485 or would even coincide with other items,
3486 such as the intersection of the arrows in the figure below.
3487 In order to shift a label position alongside the shaft of an arrow,
3492 \begin_layout Plain Layout
3502 \begin_inset space ~
3505 allows to prefix the label by a decimal number in parentheses,
3506 specifying the fraction of distance alongside the arrow where the label is to be placed.
3517 will place the label on the shaft,
3518 but only about one third of the way.
3522 \begin_layout Standard
3523 Doing the same with labels above or below arrows as
3541 does not work from inside \SpecialChar LyX
3544 one has to replace the hat-symbol ^,
3585 possible to enter several labels this way and those labels are placed correctly,
3586 even if the arrow bends.
3587 In the following figure,
3588 the bending arrow with its four labels has been produced with
3611 \begin_layout Standard
3612 \begin_inset Formula
3614 \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}}\\
3615 \circ\ar[ur]\sb(0.3)\phi & \bullet
3624 \begin_layout Subsection
3625 Invisible stretched arrows
3628 \begin_layout Standard
3629 A more general trick uses invisible arrows to place any object almost anywhere inside a diagram.
3630 Produce an invisible arrow,
3631 shorten (or prolong) it past its goal by adding a decimal stretching ratio,
3633 \begin_inset space \thinspace{}
3637 \begin_inset space \space{}
3649 Attach a label to this invisible arrow.
3653 \begin_layout Standard
3655 the down pointing arrow with its label
3656 \begin_inset Formula $\varphi$
3659 at (0.3) of its way along the shaft might as well have been produced by adding to the regular arrow
3666 \begin_inset Formula $\varphi$
3678 reaching only 0.6 of the way.
3679 Its label will now appear at 0.3 of the way of the original visible arrow.
3683 \begin_layout Standard
3684 This workaround has two minor drawbacks:
3686 it does not work with bending arrows.
3688 prolonging an invisible arrow beyond the normal dimension of the figure will invisibly extend the figure box,
3689 and thereby cause too much vertical space between the figure and the preceding or the following paragraph.
3693 \begin_layout Standard
3695 invisible arrows are an important tool,
3698 be used to place information at any chosen place in a diagram.
3699 In the above figure,
3701 we have used an invisible arrow to carry the
3707 as label and at the earlier figure we had used an invisible arrow to carry the text
3708 \begin_inset Quotes eld
3716 \begin_inset Quotes erd
3719 into the center of the figure.
3722 \begin_layout Subsection
3730 \begin_layout Standard
3731 Here we have focused only on the
3738 which is just one of the features available in Kris Rose's amazing
3742 \begin_layout Plain Layout
3756 \begin_layout Plain Layout
3766 \begin_inset CommandInset citation
3773 demonstrates many of the advanced possibilities of that package.
3775 that its style is rather terse and you will likely need a lot of experimenting and modifying the many worked examples.
3777 \begin_inset CommandInset citation
3788 \begin_layout Plain Layout
3797 -pic to make braids,
3801 You might want to look on
3805 example shipped with \SpecialChar LyX
3807 which demonstrates how to use more advanced
3811 \begin_layout Plain Layout
3824 \begin_inset space ~
3836 \begin_layout Standard
3837 \begin_inset Newpage newpage
3843 \begin_layout Bibliography
3844 \begin_inset CommandInset bibitem
3845 LatexCommand bibitem
3857 \begin_layout Plain Layout
3871 \begin_inset Newline newline
3875 \begin_inset Flex URL
3878 \begin_layout Plain Layout
3880 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyguide.pdf
3888 \begin_layout Bibliography
3889 \begin_inset CommandInset bibitem
3890 LatexCommand bibitem
3891 key "xypic reference"
3897 Rose and Ross Moore:
3902 \begin_layout Plain Layout
3913 -pic Reference Manual
3916 \begin_inset Newline newline
3920 \begin_inset Flex URL
3923 \begin_layout Plain Layout
3925 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyrefer.pdf
3933 \begin_layout Bibliography
3934 \begin_inset CommandInset bibitem
3935 LatexCommand bibitem
3941 Homepage of the package
3945 \begin_layout Plain Layout
3960 \begin_inset Flex URL
3963 \begin_layout Plain Layout
3965 https://www.ctan.org/pkg/xypic
3973 \begin_layout Bibliography
3974 \begin_inset CommandInset bibitem
3975 LatexCommand bibitem
3976 key "instant-preview"
3981 Homepage of preview-latex:
3982 \begin_inset Newline newline
3986 \begin_inset Flex URL
3989 \begin_layout Plain Layout
3991 https://www.gnu.org/software/auctex/preview-latex.html
3999 \begin_layout Bibliography
4000 \begin_inset CommandInset bibitem
4001 LatexCommand bibitem
4007 Homepage of AUC\SpecialChar TeX
4010 \begin_inset Flex URL
4013 \begin_layout Plain Layout
4015 https://www.gnu.org/software/auctex/
4023 \begin_layout Bibliography
4024 \begin_inset CommandInset bibitem
4025 LatexCommand bibitem
4036 \begin_layout Plain Layout
4051 tutorial with an archive of examples
4054 \begin_inset Newline newline
4058 \begin_inset Flex URL
4061 \begin_layout Plain Layout
4063 https://web.archive.org/web/20080222044349/https://www.dpmms.cam.ac.uk/~al366/xytutorial.html