1 #LyX 2.3 created this file. For more info see http://www.lyx.org/
5 \save_transient_properties true
6 \origin /systemlyxdir/examples/
9 % DO NOT ALTER THIS PREAMBLE!!!
11 % This preamble is designed to ensure that the file prints
12 % out as advertised. If you mess with this preamble,
13 % parts of this document may not print out as expected. If you
14 % have problems LaTeXing this file, please contact
15 % the documentation team
16 % email: lyx-docs@lists.lyx.org
20 % define new commands used in sec. 5.1
22 \xydef@\xymatrixrowsep@{#1}}
24 \xydef@\xymatrixcolsep@{#1}}
26 \newdir{|>}{!/4.5pt/@{|}*:(1,-.2)@^{>}*:(1,+.2)@_{>}}
28 % a pdf-bookmark for the TOC is added
29 \let\myTOC\tableofcontents
30 \renewcommand\tableofcontents{%
31 \pdfbookmark[1]{\contentsname}{}
34 % redefine the \LyX macro for PDF bookmarks
35 \def\LyX{\texorpdfstring{%
36 L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}
43 % set fonts for nicer pdf view
44 \IfFileExists{lmodern.sty}
45 {\usepackage{lmodern}}{}
47 \fi % end if pdflatex is used
50 \use_default_options false
51 \maintain_unincluded_children false
53 \language_package default
56 \font_roman "default" "default"
57 \font_sans "default" "default"
58 \font_typewriter "default" "default"
59 \font_math "auto" "auto"
60 \font_default_family default
61 \use_non_tex_fonts false
64 \font_sf_scale 100 100
65 \font_tt_scale 100 100
67 \use_dash_ligatures false
69 \default_output_format default
71 \bibtex_command default
72 \index_command default
76 \pdf_title "Using XY-pc in LyX"
77 \pdf_author "H. Peter Gumm"
78 \pdf_subject "LyX's XY-pic manual"
79 \pdf_keywords "LyX, documentation"
81 \pdf_bookmarksnumbered true
82 \pdf_bookmarksopen true
83 \pdf_bookmarksopenlevel 2
88 \pdf_pdfusetitle false
89 \pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue,pdfpagelayout=OneColumn, pdfnewwindow=true,pdfstartview=XYZ, plainpages=false"
92 \use_package amsmath 1
93 \use_package amssymb 1
96 \use_package mathdots 1
97 \use_package mathtools 1
99 \use_package stackrel 1
100 \use_package stmaryrd 1
101 \use_package undertilde 1
103 \cite_engine_type default
107 \paperorientation portrait
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
173 \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 @/
2026 \begin_inset Formula $\ldots$
2030 The ellipsis stands for a \SpecialChar TeX
2031 -measure which needs to be entered as a lower
2037 , we could simply write, e.
2038 \begin_inset space \thinspace{}
2042 \begin_inset space \space{}
2051 for an arrow bending
2055 downwards, this cannot directly be done in \SpecialChar LyX
2057 It is necessary, to enclose the measure in a pair of braces, such as e.
2058 \begin_inset space \thinspace{}
2062 \begin_inset space \space{}
2072 As an example, here are two opposing arrows between
2073 \begin_inset Formula $A$
2077 \begin_inset Formula $B$
2080 , each bending by .5 pica, given by the following source code:
2083 \begin_layout Standard
2095 \begin_layout Standard
2096 \begin_inset Formula
2098 \xymatrix{A\ar@/{}_{.5pc}/[r] & B\ar@/{}_{.5pc}/[l]}
2106 \begin_layout Subsubsection
2107 Specifying exit- and entrance directions
2110 \begin_layout Standard
2111 An alternative for making arrows bend is by specifying their compass direction
2112 as they are leaving their source and their direction from which they enter
2114 Instead of north, north-east, east, etc., the directions are named
2146 , standing for up, up-right, right, down-right, etc..
2147 A direction is specified as @(
2159 stands for the direction the first object is left and
2163 stands for the direction from which the target is entered.
2164 As an example, we show some bending arrows and a loop, which arises when
2165 we do not specify a target for an arrow, just its incoming and outgoing
2169 \begin_layout Standard
2170 \begin_inset Formula
2172 \xymatrix{A\ar@(dr,dl)[r]\ar@(dr,dl)[rr] & B\ar@(d,r)[dl] & C\\
2182 \begin_layout LyX-Code
2190 \begin_inset Newline newline
2200 \begin_inset Newline newline
2208 \begin_layout Subsection
2212 \begin_layout Standard
2213 The above example is reminiscent of an automata diagram, except that in
2214 such a diagram states would be enclosed in small circles, with double circles
2215 denoting final states.
2219 \begin_layout Subsubsection
2223 \begin_layout Standard
2228 \begin_layout Plain Layout
2237 -pic, entries can obtain a single or a double frame, such as
2238 \begin_inset Formula $\xymatrix{*+[F]{A}}
2243 \begin_inset Formula $\xymatrix{*+[F=]{B}}
2247 by prefixing an entry with
2255 and enclosing the portion of the entry to be framed in braces.
2256 Normally, the frame will be very tight so that it must be widened by prefixing
2266 Round frames, such as
2267 \begin_inset Formula $\xymatrix{*++[o][F]{A}}
2272 \begin_inset Formula $\xymatrix{*++[o][F=]{B}}
2276 are obtained by specifying the shape as
2281 So the latter figure was constructed as *++[o][F=]{B}.
2282 This way, the following automaton
2285 \begin_layout Standard
2286 \begin_inset Formula
2288 \xymatrix{\txt{start}\ar[r] & *++[o][F]{1}\ar[r] & *++[o][F=]{2}\ar@(ur,dr)\ar@(ur,ul)[l]}
2296 \begin_layout Standard
2301 \begin_layout LyX-Code
2311 \begin_layout LyX-Code
2317 \begin_layout LyX-Code
2325 \begin_layout LyX-Code
2329 \begin_layout Standard
2330 The \SpecialChar LaTeX
2342 will make a certain entry style the default, that can, of course be overridden
2343 for individual entries.
2348 entrymodifiers={++[o][F-]}
2350 , all following entries inside
2354 \begin_layout Plain Layout
2363 -matrices would be encircled.
2366 \begin_layout Subsubsection
2370 \begin_layout Standard
2371 Framing a whole rectangle inside an xymatrix is done with the macro pair
2391 The dimension of the rectangle is given as a dotted pair
2392 \begin_inset Formula $P_{0}.P_{1}$
2395 of points denoting the top left and lower right corners of the rectangle.
2396 Each point, in turn,is given as a doubly quoted comma separated pair
2397 \begin_inset Quotes eld
2401 \begin_inset Formula $x,y$
2405 \begin_inset Quotes erd
2409 \begin_inset Formula $x$
2413 \begin_inset Formula $y$
2417 These are followed by the framing commands, to produce figures such as
2419 \begin_inset Formula
2421 \xymatrix{A & B\ar@(d,r)[dl]\sp(0.2)\phi\sp(0.7)\psi\save"1,1"."2,1"*+[F=]\frm{}\restore\,\\
2422 C & \save"1,1"."1,2"*++[F]\frm{}\restore
2439 save"1,1"."2,1"*+[F=]
2452 produces the doubly framed rectangle, and the code for the extra wide horizonta
2464 save"1,1"."1,2"*++[F]
2478 This code can be placed in arbitrary cells of the xymatrix.
2482 \begin_layout Section
2483 Using \SpecialChar LyX
2485 \begin_inset CommandInset label
2487 name "sec:math-editor"
2494 \begin_layout Standard
2495 As an alternative to writing the
2499 code, then transforming it into a math-editing environment by marking it
2508 , one may construct and modify the whole xypic-diagram inside \SpecialChar LyX
2510 We describe the editing steps for a figure just like the one above.
2514 \begin_layout Subsection
2515 Caveat - how to enter braces
2518 \begin_layout Standard
2519 Recall that in \SpecialChar LyX
2520 's math-editor any pair of braces
2528 that are to enclose a macro-parameter must be entered by typing just
2535 The closing brace is automatically supplied and in between a box into which
2536 to the parameter is entered.
2541 \begin_layout Plain Layout
2550 -diagrams, this applies in particular to arrow modifications that are normally
2560 with the ellipsis standing for the description of end, shaft and tip of
2562 Inside the math-editor, enter just
2568 and let \SpecialChar LyX
2569 provide the closing brace and the box into which to enter the
2570 description of the arrow.
2573 \begin_layout Standard
2574 Braces that are entered without the backslash
2580 will just appear as typed, but cannot be used to receive a macro parameter.
2581 They are useful, for instance to denote sets, e.
2582 \begin_inset space \thinspace{}
2586 \begin_inset space \space{}
2600 \begin_inset Formula $\{x\in X\mid x\notin x\}$
2606 \begin_layout Subsection
2607 Setting up the matrix
2610 \begin_layout Standard
2619 open a formula environment and enter:
2627 \begin_inset Formula $\times$
2634 \begin_layout Plain Layout
2644 Add extra rows by typing
2648 and add columns by typing
2654 \begin_layout Standard
2655 At any time, further rows or columns can be entered or deleted using commands
2658 Edit\SpecialChar menuseparator
2662 their shortcuts, beginning with
2666 for the column commands or
2670 for the row commands.
2671 A more direct way uses the icons in the math toolbar once it has been activated
2674 View\SpecialChar menuseparator
2678 \begin_layout Subsection
2679 Entering nodes, arrows and labels
2682 \begin_layout Standard
2683 Type the nodes into the correct positions of the matrix.
2684 If you move the cursor out of the matrix, you should see a first rendering
2686 Next, add the arrows at the nodes from where they should emanate by typing
2703 can be any path made up from the characters
2720 Make sure that the path indeed leads to an existing node within the matrix.
2721 Otherwise, the figure will not display when the cursor leaves the editing
2725 \begin_layout Standard
2726 Next, label the arrows by attaching a label text as upper or lower indices
2727 to the end of the arrow's path.
2728 As always in \SpecialChar LyX
2729 's math editor, an underscore
2733 opens a box for a lower index and a
2737 followed by a space opens a box for an upper index.
2738 You can enter any \SpecialChar LaTeX
2742 \begin_layout Subsection
2746 \begin_layout Standard
2747 Finally, you can modify the appearance of the arrows by entering @-modifiers
2778 The above caveat applies to the first form only.
2779 It must be entered as
2785 with the arrow description entered inside the \SpecialChar LyX
2787 If this box remains empty, you have specified an empty arrow.
2788 This is a useful construction, too, as you will see in the next section.
2792 \begin_layout Standard
2793 The other modifiers,
2821 are typed as shown with the arrow description replacing the ellipsis.
2822 The code for bending arrows, which in
2851 is any valid \SpecialChar TeX
2852 -measure that should be entered as upper or lower index to
2854 Make sure that the ending slash does not end up being part of the upper
2858 \begin_layout Subsection
2859 What if something goes wrong
2862 \begin_layout Standard
2863 When constructing a diagram, you should at times check it by just moving
2864 the cursor out of the editing area to see whether instant preview can successfu
2865 lly convert it into graphical output.
2866 If this does not happen, it may either be that instant preview for some
2867 reason is not aware that it should retranslate the graphics.
2868 Moving the cursor into the editing area and out again sometimes wakes up
2872 \begin_layout Standard
2873 A more serious reason could be a syntactical error in your input (in that
2874 case, the math edition area disappears completely).
2875 If necessary, undo the last editing steps, using
2879 , or try to translate the \SpecialChar LyX
2890 View\SpecialChar menuseparator
2894 There should be some error generated, which hopefully gives you a hint
2895 as to the source of the mistake.
2898 \begin_layout Section
2902 \begin_layout Standard
2903 Certain things do not work correctly inside \SpecialChar LyX
2905 The ones that we (used to) miss most are the horizontal and vertical scaling
2906 of diagrams, and the correct positioning of arrows.
2907 There are some workarounds that we are explaining here.
2911 \begin_layout Subsection
2912 Horizontal and vertical scaling
2915 \begin_layout Standard
2916 It is often convenient to stretch the horizontal or the vertical dimensions
2917 of an entire diagram by using spacing commands for rows and/or columns.
2922 \begin_layout Plain Layout
2932 \begin_inset CommandInset citation
2954 \begin_layout Plain Layout
2963 -matrix with row spacing of 1
2964 \begin_inset space ~
2984 allows to modify the space between columns.
2985 Unfortunately, one cannot type
2986 \begin_inset Quotes eld
2996 \begin_inset Quotes erd
2999 into a formula to get the desired matrix because the @-character is interpreted
3008 But there are two other ways of getting the desired matrix:
3011 \begin_layout Itemize
3013 \begin_inset space \space{}
3022 as normal document text, then either highlight it and press
3028 to get a formula, or copy it into an existing formula.
3029 You can now continue as normal.
3030 \begin_inset Newline newline
3034 \begin_inset Note Greyedout
3037 \begin_layout Plain Layout
3042 This method only works for single spacing settings, so using
3043 \begin_inset Newline newline
3056 xymatrix@M=1pt@C=1dd
3059 The method also don't work if you use '!' to get a fixed grid with a defined
3061 \begin_inset space \space{}
3082 \begin_inset Newline newline
3085 For the following matrix, the command
3092 \begin_inset Formula
3094 \xymatrix@C=9pc{A\ar[r]\ar[d] & B\\
3095 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3104 \begin_layout Itemize
3108 \begin_layout Plain Layout
3118 \begin_inset space ~
3121 stores the values for row-spacing and column-spacing in the variables
3122 \begin_inset Newline newline
3138 So one can add the following macro to the preamble (
3140 Layout\SpecialChar menuseparator
3141 Document\SpecialChar menuseparator
3148 \begin_layout LyX-Code
3156 \begin_layout LyX-Code
3161 xymatrixrowsep@{#1}}
3164 \begin_layout Standard
3171 can be defined correspondingly by replacing
3184 Now, a figure can be scaled by entering
3186 xyR{ into the formula before the
3190 \begin_layout Plain Layout
3200 Place the cursor inside the matrix, just before the first entry.
3218 Don't forget the backslashes and remember, that the closing brace is automatica
3219 lly supplied by \SpecialChar LyX
3221 Inside the braces enter the dimensions.
3222 \begin_inset Newline newline
3226 \begin_inset Note Greyedout
3229 \begin_layout Plain Layout
3234 these commands affect all following
3238 \begin_layout Plain Layout
3248 Therefore don't forget to reset the values to default after the usage of
3261 \begin_inset Newline newline
3269 Here you see a diagram which is squashed vertically and stretched horizontally
3279 \begin_inset Formula
3281 \xyR{.5pc}\xyC{9pc}\xymatrix{A\ar[r]\ar[d] & B\\
3282 C\ar@{}[ur]|{\text{{horizontal stretch}}}
3289 \begin_inset Formula $\xyR{2pc}\xyC{2pc}$
3293 \begin_inset Note Note
3296 \begin_layout Plain Layout
3306 \begin_layout Subsection
3310 \begin_layout Standard
3315 \begin_layout Plain Layout
3324 -command allows the correct positioning of labels along the shaft of arrows.
3325 This feature is sometimes necessary, when the default position of a label
3326 would otherwise clutter the picture, or would even coincide with other
3327 items, such as the intersection of the arrows in the figure below.
3328 In order to shift a label position alongside the shaft of an arrow,
3332 \begin_layout Plain Layout
3342 \begin_inset space ~
3345 allows to prefix the label by a decimal number in parentheses, specifying
3346 the fraction of distance alongside the arrow where the label is to be placed.
3347 For instance, the code
3355 , will place the label on the shaft, but only about one third of the way.
3359 \begin_layout Standard
3360 Doing the same with labels above or below arrows as
3376 , does not work from inside \SpecialChar LyX
3378 Instead, one has to replace the hat-symbol ^, resp.
3379 the underscore _ , by the macros
3413 It is, in fact, possible to enter several labels this way and those labels
3414 are placed correctly, even if the arrow bends.
3415 In the following figure, the bending arrow with its four labels has been
3439 \begin_layout Standard
3440 \begin_inset Formula
3442 \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}}\\
3443 \circ\ar[ur]\sb(0.3)\phi & \bullet
3452 \begin_layout Subsection
3453 Invisible stretched arrows
3456 \begin_layout Standard
3457 A more general trick uses invisible arrows to place any object almost anywhere
3459 Produce an invisible arrow, shorten (or prolong) it past its goal by adding
3460 a decimal stretching ratio, e.
3461 \begin_inset space \thinspace{}
3465 \begin_inset space \space{}
3477 Attach a label to this invisible arrow.
3481 \begin_layout Standard
3482 Thus, the down pointing arrow with its label
3483 \begin_inset Formula $\varphi$
3486 at (0.3) of its way along the shaft might as well have been produced by
3487 adding to the regular arrow
3494 \begin_inset Formula $\varphi$
3505 , reaching only 0.6 of the way.
3506 Its label will now appear at 0.3 of the way of the original visible arrow.
3510 \begin_layout Standard
3511 This workaround has two minor drawbacks: First, it does not work with bending
3513 Secondly, prolonging an invisible arrow beyond the normal dimension of
3514 the figure will invisibly extend the figure box, and thereby cause too
3515 much vertical space between the figure and the preceding or the following
3520 \begin_layout Standard
3521 Nevertheless, invisible arrows are an important tool, since they can, in
3522 principle, be used to place information at any chosen place in a diagram.
3523 In the above figure, for instance, we have used an invisible arrow to carry
3530 as label and at the earlier figure we had used an invisible arrow to carry
3532 \begin_inset Quotes eld
3540 \begin_inset Quotes erd
3543 into the center of the figure.
3546 \begin_layout Subsection
3554 \begin_layout Standard
3555 Here we have focused only on the
3561 command, which is just one of the features available in Kris Rose's amazing
3567 \begin_layout Plain Layout
3585 \begin_layout Plain Layout
3597 \begin_inset CommandInset citation
3604 demonstrates many of the advanced possibilities of that package.
3605 Beware, that its style is rather terse and you will likely need a lot of
3606 experimenting and modifying the many worked examples.
3608 \begin_inset CommandInset citation
3619 \begin_layout Plain Layout
3628 -pic to make braids, cobordism, string diagrams, and much more.
3629 You might want to look on
3633 example shipped with \SpecialChar LyX
3634 , which demonstrates how to use more advanced
3638 \begin_layout Plain Layout
3651 \begin_inset space ~
3663 \begin_layout Standard
3664 \begin_inset Newpage newpage
3670 \begin_layout Bibliography
3671 \begin_inset CommandInset bibitem
3672 LatexCommand bibitem
3683 \begin_layout Plain Layout
3697 \begin_inset Newline newline
3701 \begin_inset Flex URL
3704 \begin_layout Plain Layout
3706 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyguide.pdf
3714 \begin_layout Bibliography
3715 \begin_inset CommandInset bibitem
3716 LatexCommand bibitem
3717 key "xypic reference"
3723 Rose and Ross Moore:
3727 \begin_layout Plain Layout
3738 -pic Reference Manual
3741 \begin_inset Newline newline
3745 \begin_inset Flex URL
3748 \begin_layout Plain Layout
3750 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyrefer.pdf
3758 \begin_layout Bibliography
3759 \begin_inset CommandInset bibitem
3760 LatexCommand bibitem
3766 Homepage of the package
3770 \begin_layout Plain Layout
3784 \begin_inset Flex URL
3787 \begin_layout Plain Layout
3789 http://www.ctan.org/pkg/xypic
3797 \begin_layout Bibliography
3798 \begin_inset CommandInset bibitem
3799 LatexCommand bibitem
3800 key "instant-preview"
3805 Homepage of preview-latex:
3806 \begin_inset Newline newline
3810 \begin_inset Flex URL
3813 \begin_layout Plain Layout
3815 http://www.gnu.org/software/auctex/preview-latex.html
3823 \begin_layout Bibliography
3824 \begin_inset CommandInset bibitem
3825 LatexCommand bibitem
3831 Homepage of AUC\SpecialChar TeX
3833 \begin_inset Flex URL
3836 \begin_layout Plain Layout
3838 http://www.gnu.org/software/auctex/
3846 \begin_layout Bibliography
3847 \begin_inset CommandInset bibitem
3848 LatexCommand bibitem
3858 \begin_layout Plain Layout
3873 tutorial with an archive of examples
3876 \begin_inset Newline newline
3880 \begin_inset Flex URL
3883 \begin_layout Plain Layout
3885 https://www.ctan.org/tex-archive/macros/generic/diagrams/xypic/doc/xyguide.pdf