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
64 \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
114 \notefontcolor #0000ff
122 \paragraph_separation indent
123 \paragraph_indentation default
125 \math_numbering_side default
126 \quotes_style english
130 \paperpagestyle default
131 \tracking_changes false
132 \postpone_fragile_content false
133 \output_changes false
146 \begin_layout Plain Layout
155 -pic in \SpecialChar LyX
164 \begin_layout Abstract
165 With the recent versions of \SpecialChar LyX
170 -style installed in the \SpecialChar LaTeX
171 -System, the graph drawing package
175 \begin_layout Plain Layout
184 -pic can be conveniently used inside \SpecialChar LyX
186 Diagrams can be edited and displayed inside the main \SpecialChar LyX
188 Here, we shall describe how to use the
198 inside \SpecialChar LyX
199 in order to draw, to edit and to preview diagrams as typically
200 used in category theory, algebra, and related fields.
204 \begin_layout Abstract
205 \begin_inset CommandInset toc
206 LatexCommand tableofcontents
213 \begin_layout Section
217 \begin_layout Standard
222 -package has long served as a convenient tool for easily constructing graphs
223 and diagrams in \SpecialChar LaTeX
225 Unfortunately, its use in \SpecialChar LyX
226 had long been restricted to the infamous \SpecialChar TeX
228 boxes, meaning that the \SpecialChar LyX
229 editor could only display the \SpecialChar LaTeX
231 the finished diagram.
236 -style of \SpecialChar LaTeX
237 which is part of the AUC\SpecialChar TeX
239 \begin_inset CommandInset citation
246 , finally enables the editing and displaying of
250 -diagrams, constructed, displayed and interactively edited inside \SpecialChar LyX
254 \begin_layout Standard
255 \begin_inset VSpace defskip
261 \begin_layout Standard
263 \begin_inset Graphics
264 filename xyfigure.png
272 \begin_layout Standard
273 \begin_inset VSpace defskip
279 \begin_layout Standard
280 In this note, we describe how
284 \begin_layout Plain Layout
293 -pic can be used from inside \SpecialChar LyX
294 , how diagrams can be created and edited.
295 We have tested the following using \SpecialChar LyX
296 versions 1.3.7 up to 1.6, running under
298 \begin_inset space \thinspace{}
301 XP and under Windows Vista.
305 \begin_layout Standard
306 There are two modes of operations: For a start, and for some first tests,
307 it may be easiest to first enter the
311 \begin_layout Plain Layout
320 -pic code inside the \SpecialChar LyX
321 -window, select it all and convert it to a graphical
322 representation by pressing
335 \begin_layout Plain Layout
344 -pic more frequently, or if you want to modify your initial figure, you
345 will want to assemble and modify your figures using \SpecialChar LyX
350 \begin_layout Standard
351 Once the cursor is moved over a diagram, this is displayed as an array of
352 nodes and arrow-commands.
353 These can be changed interactively.
354 When the cursor leaves the editing area, the diagram reappears.
358 \begin_layout Standard
359 In the first two sections of this documentation, we explain how to use \SpecialChar LyX
361 in the first mentioned mode and we introduce all
365 \begin_layout Plain Layout
374 -pic features that might be of use for drawing commutative diagrams, graphs
377 \begin_inset CommandInset ref
379 reference "sec:math-editor"
383 explains how to use the
387 \begin_layout Plain Layout
396 -pic commands inside a math-editing area.
400 \begin_layout Standard
401 It is not our intention to write another introduction to
405 \begin_layout Plain Layout
414 -pic, rather our motivation is to give an introduction how the most important
415 commands work inside \SpecialChar LyX
416 , since the keystrokes as explained in the
420 \begin_layout Plain Layout
430 \begin_inset CommandInset citation
437 will not always function correctly inside \SpecialChar LyX
442 \begin_layout Section
446 \begin_layout Standard
447 The following requires that the \SpecialChar LaTeX
456 are installed in the \SpecialChar LaTeX
458 They are available from CTAN, see at
459 \begin_inset CommandInset citation
461 key "instant-preview"
468 \begin_inset CommandInset citation
476 After freshly installing them, it may be necessary, to run
478 Tools\SpecialChar menuseparator
481 from the main \SpecialChar LyX
483 The steps to a first diagram output in \SpecialChar LyX
487 \begin_layout Enumerate
494 \begin_layout Enumerate
495 Open \SpecialChar LyX
498 Tools\SpecialChar menuseparator
499 Preferences\SpecialChar menuseparator
500 Look and Feel\SpecialChar menuseparator
510 \begin_layout Enumerate
513 Document\SpecialChar menuseparator
514 Settings\SpecialChar menuseparator
523 Use AMS Math package automatically
532 \begin_layout Enumerate
537 works by opening a \SpecialChar LyX
538 -document and entering any math-formula, e.
539 \begin_inset space \thinspace{}
543 \begin_inset space \space{}
547 \begin_inset Formula $a+b=c$
554 \begin_layout Enumerate
555 Move the cursor out of the formula, and watch it change its appearance to
556 look just like in the finished DVI- or PostScript document.
561 \begin_layout Enumerate
566 \begin_layout Plain Layout
581 \begin_layout Enumerate
582 Inside your \SpecialChar LyX
583 -Document, enter the text
586 \begin_inset Newline newline
598 \begin_layout Enumerate
599 Select the whole text and choose
601 Insert\SpecialChar menuseparator
602 Math\SpecialChar menuseparator
605 , or use the corresponding keyboard shortcut
613 \begin_layout Enumerate
614 Move the mouse cursor out of the editing box and wait for a split second
615 to see an arrow appear:
616 \begin_inset Formula $\xymatrix{A\ar[r] & B}
624 \begin_layout Section
628 \begin_layout Standard
629 The following diagram, which is taken from the documentation of
633 \begin_layout Plain Layout
643 \begin_inset CommandInset citation
650 by its creator Kristoffer H.
651 Rose, will provide an example for many of the features available with that
656 \begin_layout LyX-Code
660 \begin_inset Newline newline
672 \begin_inset Newline newline
682 \begin_inset Newline newline
698 \begin_inset Newline newline
706 \begin_layout LyX-Code
710 \begin_layout Standard
711 Again, to turn this code into a graphical output, select it all at once
719 up to the closing brace \SpecialChar ldots
724 and turn it into display-math as explained above.
725 A moment after the cursor leaves the math-area, you should see the diagram
726 in its full graphical glory as shown below.
730 \begin_layout Standard
731 \begin_inset Formula $\xymatrix{U\ar@/_{1pc}/[ddr]_{\psi}\ar@/{}^{1pc}/[drr]^{\varphi}\ar@{.>}[dr]|-{(x,y)}\\
732 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
741 \begin_layout Subsection
742 The matrix layout of diagrams
745 \begin_layout Standard
750 uses a matrix to define the layout of the vertices of a diagram.
751 For the above example, we need a
752 \begin_inset Formula $3\times3$
755 -matrix of which 5 entries are used for the vertices
756 \begin_inset Formula $U$
760 \begin_inset Formula $X\times_{Z}Y$
764 \begin_inset Formula $X$
768 \begin_inset Formula $Y$
772 \begin_inset Formula $Z$
775 , the other positions remaining empty.
776 In this case, the following matrix determines the layout:
779 \begin_layout LyX-Code
783 \begin_inset Newline newline
791 \begin_inset Newline newline
801 \begin_inset Newline newline
807 \begin_layout Standard
808 The pattern should be familiar from \SpecialChar LaTeX
809 : We see three rows, the first two being
810 terminated by the end-of-line-marker
819 Each line consists of entries, separated by the ampersand
827 \begin_layout Subsection
831 \begin_layout Standard
832 Having entered the vertices, we add arrows between them.
837 -command to produce an arrow is
843 , it is entered into the cell of the matrix where the arrow is to start.
844 The target of the arrow is defined by direction commands
861 These can be combined to a path and enclosed in square brackets.
862 As an example, the arrows from the vertex
863 \begin_inset Formula $U$
866 in the upper left corner down and right to the vertices
867 \begin_inset Formula $X\times_{Z}Y$
871 \begin_inset Formula $Y$
875 \begin_inset Formula $X$
878 are, respectively, defined as
897 Thus the above diagram with all arrows added becomes:
900 \begin_layout LyX-Code
904 \begin_inset Newline newline
918 \begin_inset Newline newline
934 \begin_inset Newline newline
942 \begin_layout LyX-Code
943 \begin_inset Formula $\xymatrix{U\ar[ddr]\ar[drr]\ar[dr]\\
944 & X\times_{Z}Y\ar[d]\ar[r] & X\ar[d]\\
953 \begin_layout LyX-Code
957 \begin_layout LyX-Code
961 \begin_layout Subsection
965 \begin_layout Standard
966 Labels are attached to arrows by affixing them as upper or lower indices
982 defines an arrow going one cell down, two to the right and having the label
984 \begin_inset Formula $\varphi$
988 To attach a label below the arrow, make it a lower index as in
997 This explanation is correct only for arrows pointing to the right.
998 More precisely, imagine looking along the arrow in the direction it is
1000 Then an upper index places a label to the left and a lower index places
1002 Consequently, an arrow pointing from right to left, such as
1013 \begin_inset Formula $\alpha$
1017 \begin_inset Formula $\beta$
1021 \begin_inset space \thinspace{}
1025 \begin_inset space \space{}
1029 \begin_inset Formula $\xymatrix{\ & \ \ar[l]_{\beta}^{\alpha}.}
1033 Using the character | instead of ^ or _ , it is even possible to place the
1034 label right onto the arrow, obscuring part of its shaft.
1038 \begin_layout Standard
1039 Normally, a label is placed halfway between an arrow's start and target
1041 In the first diagram, the central arrow starting in
1042 \begin_inset Formula $U$
1046 \begin_inset Formula $(x,y)$
1049 in the middle of the arrow's shaft, rather than in the middle between the
1050 two objects it connects.
1051 This is achieved by prefixing the label with a minus sign, here:
1060 \begin_layout LyX-Code
1064 \begin_inset Newline newline
1082 \begin_inset Newline newline
1098 \begin_inset Newline newline
1106 \begin_layout LyX-Code
1107 \begin_inset Formula $\xymatrix{U\ar[ddr]_{\psi}\ar[drr]^{\varphi}\ar[dr]|-{(x,y)}\\
1108 & X\times_{Z}Y\ar[d]^{q}\ar[r]_{p} & X\ar[d]_{f}\\
1117 \begin_layout Standard
1121 \begin_layout Plain Layout
1130 -pic normally permits labels to be shifted towards the tip or towards the
1131 start of an arrow by prefixing the label with a ratio, such as e.
1132 \begin_inset space \thinspace{}
1136 \begin_inset space \space{}
1145 this works only for labels which are placed on top of the arrow, such
1158 \begin_layout Standard
1159 For labels placed to the left or to the right of the arrow this does not
1165 \begin_layout Plain Layout
1174 -pic code such as e.
1175 \begin_inset space \thinspace{}
1179 \begin_inset space \space{}
1198 is not correctly interpreted by \SpecialChar LyX
1200 Two workarounds are suggested in the last section of this note.
1203 \begin_layout Subsection
1207 \begin_layout Standard
1208 Modification of the design, the form or the positioning of arrows are introduced
1214 This is followed by a pair of matching brackets, where the form of the
1227 indicates, whether we want to modify the design, the or the curvature of
1229 Various modifications can be applied to an arrow at the same time.
1232 \begin_layout Subsubsection
1236 \begin_layout Standard
1237 Various designs such as
1253 are possible for the shaft of an arrow.
1254 These can be combined with various ends and various tips.
1255 In general, the design of an arrow is described by following the command
1266 -sign and a pair of braces {\SpecialChar ldots
1267 } containing characters describing the end,
1268 the shaft and the tip of the arrow.
1269 These characters are chosen to give some form of ASCII-rendering of the
1277 produces an arrow with split end, a dotted shaft and double head.
1278 A number of other arrow designs is given in the table below.
1279 Note that the ends of embedding arrows
1280 \begin_inset Formula $\xymatrix{A\ar@{^{(}->}[r] & B}
1284 are described by raising or lowering opening parentheses, such as in
1291 \begin_layout Standard
1293 \begin_inset Tabular
1294 <lyxtabular version="3" rows="11" columns="2">
1295 <features tabularvalignment="middle">
1296 <column alignment="center" valignment="top" width="0pt">
1297 <column alignment="center" valignment="top">
1299 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1302 \begin_layout Plain Layout
1308 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1311 \begin_layout Plain Layout
1312 Source code in \SpecialChar LyX
1320 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1323 \begin_layout Plain Layout
1324 \begin_inset Formula $\xymatrix{\ \ar[r] & \ }
1333 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1336 \begin_layout Plain Layout
1348 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1351 \begin_layout Plain Layout
1352 \begin_inset Formula $\xymatrix{\ \ar@{-->}[r] & \ }
1361 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1364 \begin_layout Plain Layout
1376 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1379 \begin_layout Plain Layout
1380 \begin_inset Formula $\xymatrix{\ \ar@{..>}[r] & \ }
1389 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1392 \begin_layout Plain Layout
1404 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1407 \begin_layout Plain Layout
1408 \begin_inset Formula $\xymatrix{\ \ar@{~>}[r] & \ }
1417 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1420 \begin_layout Plain Layout
1432 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1435 \begin_layout Plain Layout
1436 \begin_inset Formula $\xymatrix{\ \ar@{->>}[r] & \ }
1445 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1448 \begin_layout Plain Layout
1460 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1463 \begin_layout Plain Layout
1464 \begin_inset Formula $\xymatrix{\ \ar@{-->>}[r] & \ }
1473 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1476 \begin_layout Plain Layout
1488 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1491 \begin_layout Plain Layout
1492 \begin_inset Formula $\xymatrix{\ \ar@{>->>}[r] & \ }
1501 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1504 \begin_layout Plain Layout
1516 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1519 \begin_layout Plain Layout
1520 \begin_inset Formula $\xymatrix{\ \ar@{_{(}->}[r] & \ }
1529 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1532 \begin_layout Plain Layout
1544 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1547 \begin_layout Plain Layout
1548 \begin_inset Formula $\xymatrix{\ \ar@{^{(}->}[r] & \ }
1557 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1560 \begin_layout Plain Layout
1572 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1575 \begin_layout Plain Layout
1576 \begin_inset Formula $\xymatrix{\ \ar@{|-|}[r] & \ }
1585 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1588 \begin_layout Plain Layout
1606 \begin_layout Standard
1608 Following the @-character by either a 2, 3, _ or a ^, we can produce arrows
1609 with double, triple shaft or arrows showing only the lower or upper half
1610 of their tips and ends.
1611 Arrows need not have tips nor ends, as the last example shows:
1614 \begin_layout Standard
1616 \begin_inset Tabular
1617 <lyxtabular version="3" rows="8" columns="2">
1618 <features tabularvalignment="middle">
1619 <column alignment="center" valignment="top">
1620 <column alignment="center" valignment="top">
1622 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1625 \begin_layout Plain Layout
1631 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1634 \begin_layout Plain Layout
1635 Source code for \SpecialChar LyX
1643 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1646 \begin_layout Plain Layout
1647 \begin_inset Formula $\xymatrix{\ \ar@2[r] & \ }
1656 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1659 \begin_layout Plain Layout
1671 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1674 \begin_layout Plain Layout
1675 \begin_inset Formula $\xymatrix{\ \ar@3[r] & \ }
1684 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1687 \begin_layout Plain Layout
1699 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1702 \begin_layout Plain Layout
1703 \begin_inset Formula $\xymatrix{\ \ar@_{->}[r] & \ }
1712 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1715 \begin_layout Plain Layout
1727 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1730 \begin_layout Plain Layout
1731 \begin_inset Formula $\xymatrix{\ \ar@^{->}[r] & \ }
1740 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1743 \begin_layout Plain Layout
1755 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1758 \begin_layout Plain Layout
1759 \begin_inset Formula $\xymatrix{\ \ar@^{>>->>}[r] & \ }
1768 <cell alignment="center" valignment="top" topline="true" rightline="true" usebox="none">
1771 \begin_layout Plain Layout
1776 ar@^{>\SpecialChar ligaturebreak
1777 >->\SpecialChar ligaturebreak
1785 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1788 \begin_layout Plain Layout
1789 \begin_inset Formula $\xymatrix{\ \ar@{^{<}-_{>}}[r] & \ }
1798 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1801 \begin_layout Plain Layout
1813 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1816 \begin_layout Plain Layout
1817 \begin_inset Formula $\xymatrix{\ \ar@2{--}[r] & \ }
1826 <cell alignment="center" valignment="top" topline="true" bottomline="true" rightline="true" usebox="none">
1829 \begin_layout Plain Layout
1847 \begin_layout Subsubsection
1848 Designing your own arrows
1851 \begin_layout Standard
1852 Within certain limits there is even a way to design your own arrows.
1853 Using some the characters
1857 one can even design one's own arrow tips using the
1863 command in the preamble.
1864 For explanations, we refer to the
1870 \begin_layout Plain Layout
1881 -manual, from which we take the example:
1884 \begin_layout Standard
1889 newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
1894 \begin_layout Standard
1896 This defines a new arrow tip, referred to as
1906 and which displays correctly in \SpecialChar LyX
1908 \begin_inset Formula
1910 \xymatrix{A\ar@{-|>}[r] & \ \ B}
1918 \begin_layout Subsection
1922 \begin_layout Standard
1923 Arrows are shifted sideways with the modifier
1928 \begin_inset Formula $\ldots$
1935 where the ellipsis is replaced by a positive or negative measure.
1936 For instance, to design a pair of mutually opposing arrows between two
1937 nodes, we shift them to see them apart.
1938 Note that the direction of the shift (positive) is to the left if one looks
1943 \begin_layout Standard
1959 \begin_layout Standard
1962 \begin_inset Formula
1964 \xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1972 \begin_layout Subsubsection
1973 Inline or centered diagrams
1976 \begin_layout Standard
1977 Arrows and diagrams can be used inline, such as this one:
1978 \begin_inset Formula $\xymatrix{\circ\ar@<1ex>[r] & \circ\ar@<1ex>[l]}
1983 When their code is written inside \SpecialChar LyX
1984 as above, select it and choose either
1989 for inline appearance or
1994 Diagrams constructed inline can later be centered, or, conversely, centered
1995 diagrams can be changed to inline formulas with
1997 Edit\SpecialChar menuseparator
2002 \SpecialChar menuseparator
2003 Change Formula Type.
2006 \begin_layout Subsection
2010 \begin_layout Standard
2011 There are two simple methods to make arrows bend.
2012 The first is giving an explicit value by which the midpoint of the arrow's
2013 shaft is raised or depressed, the other is by forcing the arrow to leave
2014 its origin in a prescribed compass direction and to make him enter the
2015 target at another direction.
2016 The necessary bending of the arrow is determined automatically.
2017 We describe both methods.
2020 \begin_layout Subsubsection
2024 \begin_layout Standard
2025 For bending arrows we use the modifier
2030 \begin_inset Formula $\ldots$
2038 The ellipsis stands for a \SpecialChar TeX
2039 -measure which needs to be entered as a lower
2045 , we could simply write, e.
2046 \begin_inset space \thinspace{}
2050 \begin_inset space \space{}
2059 for an arrow bending
2063 downwards, this cannot directly be done in \SpecialChar LyX
2065 It is necessary, to enclose the measure in a pair of braces, such as e.
2066 \begin_inset space \thinspace{}
2070 \begin_inset space \space{}
2080 As an example, here are two opposing arrows between
2081 \begin_inset Formula $A$
2085 \begin_inset Formula $B$
2088 , each bending by .5 pica, given by the following source code:
2091 \begin_layout Standard
2103 \begin_layout Standard
2104 \begin_inset Formula
2106 \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]}
2114 \begin_layout Subsubsection
2115 Specifying exit- and entrance directions
2118 \begin_layout Standard
2119 An alternative for making arrows bend is by specifying their compass direction
2120 as they are leaving their source and their direction from which they enter
2122 Instead of north, north-east, east, etc., the directions are named
2154 , standing for up, up-right, right, down-right, etc..
2155 A direction is specified as
2173 stands for the direction the first object is left and
2177 stands for the direction from which the target is entered.
2178 As an example, we show some bending arrows and a loop, which arises when
2179 we do not specify a target for an arrow, just its incoming and outgoing
2183 \begin_layout Standard
2184 \begin_inset Formula
2186 \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\
2196 \begin_layout LyX-Code
2204 \begin_inset Newline newline
2214 \begin_inset Newline newline
2222 \begin_layout Subsection
2226 \begin_layout Standard
2227 The above example is reminiscent of an automata diagram, except that in
2228 such a diagram states would be enclosed in small circles, with double circles
2229 denoting final states.
2233 \begin_layout Subsubsection
2237 \begin_layout Standard
2242 \begin_layout Plain Layout
2251 -pic, entries can obtain a single or a double frame, such as
2252 \begin_inset Formula $\xymatrix{*+[F]{A}}
2257 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2261 by prefixing an entry with
2269 and enclosing the portion of the entry to be framed in braces.
2270 Normally, the frame will be very tight so that it must be widened by prefixing
2280 Round frames, such as
2281 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2286 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2290 are obtained by specifying the shape as
2295 So the latter figure was constructed as *++[o][F=]{B}.
2296 This way, the following automaton
2299 \begin_layout Standard
2300 \begin_inset Formula
2302 \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]}
2310 \begin_layout Standard
2315 \begin_layout LyX-Code
2325 \begin_layout LyX-Code
2331 \begin_layout LyX-Code
2339 \begin_layout LyX-Code
2343 \begin_layout Standard
2344 The \SpecialChar LaTeX
2356 will make a certain entry style the default, that can, of course be overridden
2357 for individual entries.
2362 entrymodifiers={++[o][F-]}
2364 , all following entries inside
2368 \begin_layout Plain Layout
2377 -matrices would be encircled.
2380 \begin_layout Subsubsection
2384 \begin_layout Standard
2385 Framing a whole rectangle inside an xymatrix is done with the macro pair
2405 The dimension of the rectangle is given as a dotted pair
2406 \begin_inset Formula $P_{0}.P_{1}$
2409 of points denoting the top left and lower right corners of the rectangle.
2410 Each point, in turn,is given as a doubly quoted comma separated pair
2411 \begin_inset Quotes eld
2415 \begin_inset Formula $x,y$
2419 \begin_inset Quotes erd
2423 \begin_inset Formula $x$
2427 \begin_inset Formula $y$
2431 These are followed by the framing commands, to produce figures such as
2433 \begin_inset Formula
2435 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2436 C & \save"1,1"."1,2"*++[F]\frm{}\restore
2453 save"1,1"."2,1"*+[F=]
2466 produces the doubly framed rectangle, and the code for the extra wide horizonta
2477 \begin_inset Newline newline
2482 save"1,1"."1,2"*++[F]
2496 \begin_inset Newline newline
2499 This code can be placed in arbitrary cells of the xymatrix.
2503 \begin_layout Section
2504 Using \SpecialChar LyX
2506 \begin_inset CommandInset label
2508 name "sec:math-editor"
2515 \begin_layout Standard
2516 As an alternative to writing the
2520 code, then transforming it into a math-editing environment by marking it
2529 , one may construct and modify the whole xypic-diagram inside \SpecialChar LyX
2531 We describe the editing steps for a figure just like the one above.
2535 \begin_layout Subsection
2536 Caveat - how to enter braces
2539 \begin_layout Standard
2540 Recall that in \SpecialChar LyX
2541 's math-editor any pair of braces
2549 that are to enclose a macro-parameter must be entered by typing just
2556 The closing brace is automatically supplied and in between a box into which
2557 to the parameter is entered.
2562 \begin_layout Plain Layout
2571 -diagrams, this applies in particular to arrow modifications that are normally
2581 with the ellipsis standing for the description of end, shaft and tip of
2583 Inside the math-editor, enter just
2589 and let \SpecialChar LyX
2590 provide the closing brace and the box into which to enter the
2591 description of the arrow.
2594 \begin_layout Standard
2595 Braces that are entered without the backslash
2601 will just appear as typed, but cannot be used to receive a macro parameter.
2602 They are useful, for instance to denote sets, e.
2603 \begin_inset space \thinspace{}
2607 \begin_inset space \space{}
2621 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2627 \begin_layout Subsection
2628 Setting up the matrix
2631 \begin_layout Standard
2640 open a formula environment and enter:
2648 \begin_inset Formula $\times$
2655 \begin_layout Plain Layout
2665 Add extra rows by typing
2669 and add columns by typing
2675 \begin_layout Standard
2676 At any time, further rows or columns can be entered or deleted using commands
2679 Edit\SpecialChar menuseparator
2683 their shortcuts, beginning with
2687 for the column commands or
2691 for the row commands.
2692 A more direct way uses the icons in the math toolbar once it has been activated
2695 View\SpecialChar menuseparator
2699 \begin_layout Subsection
2700 Entering nodes, arrows and labels
2703 \begin_layout Standard
2704 Type the nodes into the correct positions of the matrix.
2705 If you move the cursor out of the matrix, you should see a first rendering
2707 Next, add the arrows at the nodes from where they should emanate by typing
2724 can be any path made up from the characters
2741 Make sure that the path indeed leads to an existing node within the matrix.
2742 Otherwise, the figure will not display when the cursor leaves the editing
2746 \begin_layout Standard
2747 Next, label the arrows by attaching a label text as upper or lower indices
2748 to the end of the arrow's path.
2749 As always in \SpecialChar LyX
2750 's math editor, an underscore
2754 opens a box for a lower index and a
2758 followed by a space opens a box for an upper index.
2759 You can enter any \SpecialChar LaTeX
2763 \begin_layout Subsection
2767 \begin_layout Standard
2768 Finally, you can modify the appearance of the arrows by entering @-modifiers
2807 The above caveat applies to the first form only.
2808 It must be entered as
2814 with the arrow description entered inside the \SpecialChar LyX
2816 If this box remains empty, you have specified an empty arrow.
2817 This is a useful construction, too, as you will see in the next section.
2821 \begin_layout Standard
2822 The other modifiers,
2850 are typed as shown with the arrow description replacing the ellipsis.
2851 The code for bending arrows, which in
2880 is any valid \SpecialChar TeX
2881 -measure that should be entered as upper or lower index to
2883 Make sure that the ending slash does not end up being part of the upper
2887 \begin_layout Subsection
2888 What if something goes wrong
2891 \begin_layout Standard
2892 When constructing a diagram, you should at times check it by just moving
2893 the cursor out of the editing area to see whether instant preview can successfu
2894 lly convert it into graphical output.
2895 If this does not happen, it may either be that instant preview for some
2896 reason is not aware that it should retranslate the graphics.
2897 Moving the cursor into the editing area and out again sometimes wakes up
2901 \begin_layout Standard
2902 A more serious reason could be a syntactical error in your input (in that
2903 case, the math edition area disappears completely).
2904 If necessary, undo the last editing steps, using
2908 , or try to translate the \SpecialChar LyX
2919 View\SpecialChar menuseparator
2923 There should be some error generated, which hopefully gives you a hint
2924 as to the source of the mistake.
2927 \begin_layout Section
2931 \begin_layout Standard
2932 Certain things do not work correctly inside \SpecialChar LyX
2934 The ones that we (used to) miss most are the horizontal and vertical scaling
2935 of diagrams, and the correct positioning of arrows.
2936 There are some workarounds that we are explaining here.
2940 \begin_layout Subsection
2941 Horizontal and vertical scaling
2944 \begin_layout Standard
2945 It is often convenient to stretch the horizontal or the vertical dimensions
2946 of an entire diagram by using spacing commands for rows and/or columns.
2951 \begin_layout Plain Layout
2961 \begin_inset CommandInset citation
2983 \begin_layout Plain Layout
2992 -matrix with row spacing of 1
2993 \begin_inset space ~
3013 allows to modify the space between columns.
3014 Unfortunately, one cannot type
3015 \begin_inset Quotes eld
3025 \begin_inset Quotes erd
3028 into a formula to get the desired matrix because the @-character is interpreted
3037 But there are two other ways of getting the desired matrix:
3040 \begin_layout Itemize
3042 \begin_inset space \space{}
3051 as normal document text, then either highlight it and press
3057 to get a formula, or copy it into an existing formula.
3058 You can now continue as normal.
3059 \begin_inset Newline newline
3063 \begin_inset Note Greyedout
3066 \begin_layout Plain Layout
3071 This method only works for single spacing settings, so using
3072 \begin_inset Newline newline
3085 xymatrix@M=1pt@C=1dd
3088 The method also don't work if you use '!' to get a fixed grid with a defined
3090 \begin_inset space \space{}
3111 \begin_inset Newline newline
3114 For the following matrix, the command
3121 \begin_inset Formula
3123 \xymatrix@C=9pc{A\ar[r]\ar[d] & B\\
3124 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3133 \begin_layout Itemize
3137 \begin_layout Plain Layout
3147 \begin_inset space ~
3150 stores the values for row-spacing and column-spacing in the variables
3151 \begin_inset Newline newline
3167 So one can add the following macro to the preamble (
3169 Layout\SpecialChar menuseparator
3170 Document\SpecialChar menuseparator
3177 \begin_layout LyX-Code
3185 \begin_layout LyX-Code
3190 xymatrixrowsep@{#1}}
3193 \begin_layout Standard
3200 can be defined correspondingly by replacing
3213 Now, a figure can be scaled by entering
3215 xyR{ into the formula before the
3219 \begin_layout Plain Layout
3229 Place the cursor inside the matrix, just before the first entry.
3247 Don't forget the backslashes and remember, that the closing brace is automatica
3248 lly supplied by \SpecialChar LyX
3250 Inside the braces enter the dimensions.
3251 \begin_inset Newline newline
3255 \begin_inset Note Greyedout
3258 \begin_layout Plain Layout
3263 these commands affect all following
3267 \begin_layout Plain Layout
3277 Therefore don't forget to reset the values to default after the usage of
3290 \begin_inset Newline newline
3298 Here you see a diagram which is squashed vertically and stretched horizontally
3308 \begin_inset Formula
3310 \xyR{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
3311 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3318 \begin_inset Formula $\xyR{2pc}\xyC{2pc}$
3322 \begin_inset Note Note
3325 \begin_layout Plain Layout
3335 \begin_layout Subsection
3339 \begin_layout Standard
3344 \begin_layout Plain Layout
3353 -command allows the correct positioning of labels along the shaft of arrows.
3354 This feature is sometimes necessary, when the default position of a label
3355 would otherwise clutter the picture, or would even coincide with other
3356 items, such as the intersection of the arrows in the figure below.
3357 In order to shift a label position alongside the shaft of an arrow,
3361 \begin_layout Plain Layout
3371 \begin_inset space ~
3374 allows to prefix the label by a decimal number in parentheses, specifying
3375 the fraction of distance alongside the arrow where the label is to be placed.
3376 For instance, the code
3384 , will place the label on the shaft, but only about one third of the way.
3388 \begin_layout Standard
3389 Doing the same with labels above or below arrows as
3405 , does not work from inside \SpecialChar LyX
3407 Instead, one has to replace the hat-symbol ^, resp.
3408 the underscore _ , by the macros
3442 It is, in fact, possible to enter several labels this way and those labels
3443 are placed correctly, even if the arrow bends.
3444 In the following figure, the bending arrow with its four labels has been
3468 \begin_layout Standard
3469 \begin_inset Formula
3471 \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}}\\
3472 \circ\ar[ur]\sb(0.3)\phi & \bullet
3481 \begin_layout Subsection
3482 Invisible stretched arrows
3485 \begin_layout Standard
3486 A more general trick uses invisible arrows to place any object almost anywhere
3488 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3489 a decimal stretching ratio, e.
3490 \begin_inset space \thinspace{}
3494 \begin_inset space \space{}
3506 Attach a label to this invisible arrow.
3510 \begin_layout Standard
3511 Thus, the down pointing arrow with its label
3512 \begin_inset Formula $\varphi$
3515 at (0.3) of its way along the shaft might as well have been produced by
3516 adding to the regular arrow
3523 \begin_inset Formula $\varphi$
3534 , reaching only 0.6 of the way.
3535 Its label will now appear at 0.3 of the way of the original visible arrow.
3539 \begin_layout Standard
3540 This workaround has two minor drawbacks: First, it does not work with bending
3542 Secondly, prolonging an invisible arrow beyond the normal dimension of
3543 the figure will invisibly extend the figure box, and thereby cause too
3544 much vertical space between the figure and the preceding or the following
3549 \begin_layout Standard
3550 Nevertheless, invisible arrows are an important tool, since they can, in
3551 principle, be used to place information at any chosen place in a diagram.
3552 In the above figure, for instance, we have used an invisible arrow to carry
3559 as label and at the earlier figure we had used an invisible arrow to carry
3561 \begin_inset Quotes eld
3569 \begin_inset Quotes erd
3572 into the center of the figure.
3575 \begin_layout Subsection
3583 \begin_layout Standard
3584 Here we have focused only on the
3590 command, which is just one of the features available in Kris Rose's amazing
3595 \begin_layout Plain Layout
3609 \begin_layout Plain Layout
3619 \begin_inset CommandInset citation
3626 demonstrates many of the advanced possibilities of that package.
3627 Beware, that its style is rather terse and you will likely need a lot of
3628 experimenting and modifying the many worked examples.
3630 \begin_inset CommandInset citation
3641 \begin_layout Plain Layout
3650 -pic to make braids, cobordism, string diagrams, and much more.
3651 You might want to look on
3655 example shipped with \SpecialChar LyX
3656 , which demonstrates how to use more advanced
3660 \begin_layout Plain Layout
3673 \begin_inset space ~
3685 \begin_layout Standard
3686 \begin_inset Newpage newpage
3692 \begin_layout Bibliography
3693 \begin_inset CommandInset bibitem
3694 LatexCommand bibitem
3705 \begin_layout Plain Layout
3719 \begin_inset Newline newline
3723 \begin_inset Flex URL
3726 \begin_layout Plain Layout
3728 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyguide.pdf
3736 \begin_layout Bibliography
3737 \begin_inset CommandInset bibitem
3738 LatexCommand bibitem
3739 key "xypic reference"
3745 Rose and Ross Moore:
3749 \begin_layout Plain Layout
3760 -pic Reference Manual
3763 \begin_inset Newline newline
3767 \begin_inset Flex URL
3770 \begin_layout Plain Layout
3772 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyrefer.pdf
3780 \begin_layout Bibliography
3781 \begin_inset CommandInset bibitem
3782 LatexCommand bibitem
3788 Homepage of the package
3792 \begin_layout Plain Layout
3806 \begin_inset Flex URL
3809 \begin_layout Plain Layout
3811 https://www.ctan.org/pkg/xypic
3819 \begin_layout Bibliography
3820 \begin_inset CommandInset bibitem
3821 LatexCommand bibitem
3822 key "instant-preview"
3827 Homepage of preview-latex:
3828 \begin_inset Newline newline
3832 \begin_inset Flex URL
3835 \begin_layout Plain Layout
3837 https://www.gnu.org/software/auctex/preview-latex.html
3845 \begin_layout Bibliography
3846 \begin_inset CommandInset bibitem
3847 LatexCommand bibitem
3853 Homepage of AUC\SpecialChar TeX
3855 \begin_inset Flex URL
3858 \begin_layout Plain Layout
3860 https://www.gnu.org/software/auctex/
3868 \begin_layout Bibliography
3869 \begin_inset CommandInset bibitem
3870 LatexCommand bibitem
3880 \begin_layout Plain Layout
3895 tutorial with an archive of examples
3898 \begin_inset Newline newline
3902 \begin_inset Flex URL
3905 \begin_layout Plain Layout
3907 https://web.archive.org/web/20080222044349/https://www.dpmms.cam.ac.uk/~al366/xytutori