+\begin_layout Section
+Diagrams
+\end_layout
+
+\begin_layout Standard
+LyX supports two types of commutative diagrams:
+\series bold
+amscd
+\series default
+ and
+\series bold
+xymatrix
+\series default
+ that are explained in the following.
+\end_layout
+
+\begin_layout Subsection
+Amscd Diagrams
+\begin_inset Index idx
+status collapsed
+
+\begin_layout Plain Layout
+Diagrams ! amscd
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Diagrams of this type visualize relations by vertical and horizontal lines
+ or arrows:
+\begin_inset Formula
+\[
+\begin{CD}A@>>>B@>>>C\\
+@AAA@.@VVV\\
+F@<<<E@<<<D
+\end{CD}
+\]
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+To get them, the command
+\series bold
+
+\backslash
+CD
+\begin_inset Index idx
+status collapsed
+
+\begin_layout Plain Layout
+Commands ! C !
+\backslash
+CD
+\end_layout
+
+\end_inset
+
+
+\series default
+ is inserted to a formula.
+ A blue box appears with two dashed lines where further commands can be
+ inserted.
+ With
+\begin_inset Info
+type "shortcut"
+arg "newline-insert newline"
+\end_inset
+
+ a new line is created.
+ Horizontal relations are inserted in odd, vertical in even formula lines.
+\end_layout
+
+\begin_layout Standard
+To create the relations there are the following commands:
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+@<<<
+\series default
+ creates a left arrow,
+\series bold
+@>>>
+\series default
+ a right arrow and
+\series bold
+@=
+\series default
+ a long equal sign
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+@AAA
+\series default
+ creates an up arrow,
+\series bold
+@VVV
+\series default
+ an down arrow and
+\series bold
+@|
+\series default
+ a vertical equal sign
+\end_layout
+
+\begin_layout Itemize
+
+\series bold
+@.
+
+\series default
+ is a placeholder for non-existent relations
+\end_layout
+
+\begin_layout Standard
+All arrows can be labeled as follows:
+\end_layout
+
+\begin_layout Itemize
+Is text inserted between the first and second < or >, resp., it is placed
+ above the arrow.
+ When it is inserted between the second and third one, it appears under
+ the arrow.
+\end_layout
+
+\begin_layout Itemize
+When text for vertical arrows is inserted between the first and second A
+ or V, resp., it is placed left beside the arrow.
+ When it is inserted between the second and third one, it appears right
+ beside the arrow.
+ If the text contains an A or V, these letters must be set into a TeX-brace.
+\end_layout
+
+\begin_layout Standard
+As example a diagram with all possible relations:
+\end_layout
+
+\begin_layout Standard
+\begin_inset Formula
+\[
+\begin{CD}A@>j>>B@>>k>C@=F\\
+@AmAA@.@VV{V}V@|\\
+D@<<j<E@>k>>F@=C
+\end{CD}
+\]
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+The command for this is:
+\begin_inset Newline newline
+\end_inset
+
+
+\series bold
+
+\backslash
+CD
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+spce
+\end_layout
+
+\end_inset
+
+A@>j>>B@>>k>C@=F Ctrl+Return
+\begin_inset Newline newline
+\end_inset
+
+
+\begin_inset Phantom HPhantom
+status open
+
+\begin_layout Plain Layout
+
+\series bold
+
+\backslash
+CD
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+spce
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+@AmAA@.@VV
+\backslash
+{V
+\series default
+
+\begin_inset Formula $\to$
+\end_inset
+
+
+\series bold
+V@| Ctrl+Return
+\begin_inset Newline newline
+\end_inset
+
+
+\begin_inset Phantom HPhantom
+status open
+
+\begin_layout Plain Layout
+
+\series bold
+
+\backslash
+CD
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+spce
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+D@<<j<E@>k>>F@=C
+\end_layout
+
+\begin_layout Subsection
+Xymatrix Diagrams
+\begin_inset Index idx
+status collapsed
+
+\begin_layout Plain Layout
+Diagrams ! xymatrix
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+To be able to use xymatrices, the LaTeX-package
+\series bold
+xypic
+\series default
+ must be installed.
+ A xymatrix is created by inserting the command
+\series bold
+
+\backslash
+xymatrix
+\series default
+ in a formula.
+ Then you are able to add new matrix columns and rows like for normal matrices,
+ see
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "sec:Matrices"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Standard
+In contrary to amscd diagrams, xymatrices supports diagonal and curved arrows,
+ and much more.
+ All possibilities to create commutative diagrams and decorations are explained
+ in detail in the
+\emph on
+XY-pic manual
+\emph default
+ that you find in the menu
+\family sans
+Help\SpecialChar \menuseparator
+Specific
+\begin_inset space ~
+\end_inset
+
+Manuals
+\family default
+.
+\end_layout
+
+\begin_layout Subsection
+
+\noun on
+Feynman
+\noun default
+ Diagrams
+\begin_inset Index idx
+status collapsed
+
+\begin_layout Plain Layout
+Diagrams ! Feynman
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+To be able to use
+\noun on
+Feynman
+\noun default
+-diagrams, the LaTeX-package
+\series bold
+feyn
+\series default
+ must be installed.
+ A
+\noun on
+Feynman
+\noun default
+-diagram is created by inserting the command
+\series bold
+
+\backslash
+Diagram
+\series default
+ in a formula.
+ Then you are able to add new matrix columns and rows like for normal matrices,
+ see
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "sec:Matrices"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Standard
+Examples how to create
+\noun on
+Feynman-
+\noun default
+diagrams in LyX is given in the
+\emph on
+Feynman-diagram manual
+\emph default
+ that you find in the menu
+\family sans
+Help\SpecialChar \menuseparator
+Specific
+\begin_inset space ~
+\end_inset
+
+Manuals
+\family default
+.
+\end_layout
+
+\begin_layout Section
+User-defined Commands
+\begin_inset Index idx
+status collapsed
+
+\begin_layout Plain Layout
+User-defined commands
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Note Greyedout
+status open
+
+\begin_layout Plain Layout
+
+\series bold
+Note:
+\series default
+ The names of user-defined commands and macros may only consist of Latin
+ letters.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+The Command
+\backslash
+newcommand
+\begin_inset CommandInset label
+LatexCommand label
+name "sub:The-Command-newcommand"
+
+\end_inset
+
+
+\begin_inset Index idx
+status collapsed
+
+\begin_layout Plain Layout
+User-defined commands !
+\backslash
+newcommand
+\end_layout
+
+\end_inset
+
+
+\begin_inset Index idx
+status collapsed
+
+\begin_layout Plain Layout
+Commands ! N !
+\backslash
+newcommand
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+Many LaTeX-commands are too long to be used frequently.
+ But it is possible to define with the command
+\series bold
+
+\backslash
+newcommand
+\series default
+ new shorter commands.
+\end_layout
+
+\begin_layout Standard
+The command scheme of
+\series bold
+
+\backslash
+newcommand
+\series default
+ is:
+\end_layout
+
+\begin_layout Standard
+
+\series bold
+
+\backslash
+newcommand{new command name}[number of arguments][optional
+\series default
+
+\series bold
+value]
+\begin_inset Newline newline
+\end_inset
+
+
+\begin_inset Phantom HPhantom
+status open
+
+\begin_layout Plain Layout
+
+\series bold
+
+\backslash
+newcommand
+\end_layout
+
+\end_inset
+
+{command definition}
+\end_layout
+
+\begin_layout Standard
+\begin_inset Note Greyedout
+status open
+
+\begin_layout Plain Layout
+
+\series bold
+Note:
+\series default
+ Assure that the name of the new command is not already used in your document
+ or by LaTeX-packages that you use.
+ When you for example define the command
+\series bold
+
+\backslash
+le
+\series default
+ for
+\series bold
+
+\backslash
+Leftarrow
+\series default
+, you get an error message because
+\series bold
+
+\backslash
+le
+\series default
+ is already defined as command for
+\begin_inset Quotes eld
+\end_inset
+
+
+\begin_inset Formula $\le$
+\end_inset
+
+
+\begin_inset Quotes erd
+\end_inset
+
+.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+The number of arguments is an integer in the range 0
+\begin_inset space \thinspace{}
+\end_inset
+
+-
+\begin_inset space \thinspace{}
+\end_inset
+
+9 and specifies how many arguments the new command should have.
+ With the optional value a value for an optional argument can be predefined.
+ When this is done, the
+\emph on
+first
+\emph default
+
+\emph on
+a
+\emph default
+rgument of the new command is automatically an optional one.
+\end_layout
+
+\begin_layout Standard
+Here are some examples:
+\end_layout
+
+\begin_layout Itemize
+To define the command
+\series bold
+
+\backslash
+gr
+\series default
+ for
+\series bold
+
+\backslash
+Longrightarrow
+\series default
+, the LaTeX-preamble line is:
+\begin_inset VSpace medskip
+\end_inset
+
+
+\begin_inset Newline newline
+\end_inset
+
+
+\series bold
+
+\backslash
+newcommand{
+\backslash
+gr}{
+\backslash
+Longrightarrow}
+\end_layout
+
+\begin_layout Itemize
+To define the command
+\series bold
+
+\backslash
+us
+\series default
+ for
+\series bold
+
+\backslash
+underline
+\series default
+, the argument (that should be underlined) must be taken into account.
+ For this the preamble line is:
+\begin_inset VSpace medskip
+\end_inset
+
+
+\begin_inset Newline newline
+\end_inset
+
+
+\series bold
+
+\backslash
+newcommand{
+\backslash
+us}[1]{
+\backslash
+underline{#1}}
+\series default
+
+\begin_inset VSpace medskip
+\end_inset
+
+
+\begin_inset Newline newline
+\end_inset
+
+The character
+\series bold
+#
+\series default
+ acts as argument placeholder, the
+\series bold
+1
+\series default
+ behind it denotes that it is the placeholder for the first argument.
+\end_layout
+
+\begin_layout Itemize
+For
+\series bold
+
+\backslash
+framebox
+\series default
+ one can e.
+\begin_inset space \thinspace{}
+\end_inset
+
+g.
+\begin_inset space \space{}
+\end_inset
+
+define the command
+\series bold
+
+\backslash
+fb
+\series default
+:
+\begin_inset VSpace medskip
+\end_inset
+
+
+\begin_inset Newline newline
+\end_inset
+
+
+\series bold
+
+\backslash
+newcommand{
+\backslash
+fb}[3]{
+\backslash
+framebox#1#2{$#3$}}
+\series default
+
+\begin_inset VSpace medskip
+\end_inset
+
+
+\begin_inset Newline newline
+\end_inset
+
+The two Dollar signs creates the extra formula needed for
+\series bold
+
+\backslash
+framebox
+\series default
+, see
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "sub:Boxes-with-Frame"
+
+\end_inset
+
+.
+\end_layout
+
+\begin_layout Itemize
+To create a new command for
+\series bold
+
+\backslash
+fcolorbox
+\series default
+ where the color for the box needn't to be specified, the argument for the
+ color is defined optional:
+\begin_inset VSpace medskip
+\end_inset
+
+
+\begin_inset Newline newline
+\end_inset
+
+
+\series bold
+
+\backslash
+newcommand{
+\backslash
+cb}[3][white]{
+\backslash
+fcolorbox{#2}{#1}{$#3$}}
+\series default
+
+\begin_inset VSpace medskip
+\end_inset
+
+
+\begin_inset Newline newline
+\end_inset
+
+When the color is not specified when using
+\series bold
+
+\backslash
+cb
+\series default
+, the predefined color
+\series bold
+white
+\series default
+ will be used.
+\end_layout
+
+\begin_layout Standard
+A test of the new defined commands:
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Tabular
+<lyxtabular version="3" rows="6" columns="2">
+<features tabularvalignment="middle">
+<column alignment="center" valignment="top" width="0">
+<column alignment="center" valignment="top" width="0">
+<row>
+<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+Command
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+Result
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Plain Layout
+
+\series bold
+
+\backslash
+raisebox
+\series default
+ is only used as spacer.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+A
+\backslash
+gr
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+spce
+\end_layout
+
+\end_inset
+
+B
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+\begin_inset Formula $A\gr B$
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\backslash
+us{ABcd
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+\begin_inset Formula $\raisebox{4.5mm}{}\us{ABcd}\raisebox{-2mm}{}$
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\backslash
+fb{[2cm]
+\begin_inset Formula $\to$
+\end_inset
+
+
+\backslash
+{
+\begin_inset Formula $\to$
+\end_inset
+
+
+\backslash
+{
+\backslash
+int
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+spce
+\end_layout
+
+\end_inset
+
+A=B
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+\begin_inset Formula $\raisebox{6mm}{}\fb{[2cm]}{}{\int A=B}\raisebox{-4mm}{}$
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\backslash
+cb{red
+\begin_inset Formula $\to$
+\end_inset
+
+
+\backslash
+{
+\backslash
+int
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+spce
+\end_layout
+
+\end_inset
+
+A=B
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+\begin_inset Formula $\raisebox{6mm}{}\cb{red}{\int A=B}\raisebox{-4mm}{}$
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
+<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\backslash
+cb[green]
+\backslash
+{red
+\begin_inset Formula $\to$
+\end_inset
+
+
+\backslash
+{
+\backslash
+int
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+
+\backslash
+spce
+\end_layout
+
+\end_inset
+
+A=B
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+\begin_inset Formula $\raisebox{6mm}{}\cb[green]{red}{\int A=B}\raisebox{-4mm}{}$
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Math Macros
+\begin_inset Index idx
+status collapsed
+
+\begin_layout Plain Layout
+User-defined commands! Math macros
+\end_layout
+
+\end_inset
+
+
+\begin_inset Index idx
+status collapsed
+
+\begin_layout Plain Layout
+Macros
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+User-defined commands are especially convenient for complex expressions.
+ When you are for example dealing in a document with quadratic equations,
+ the same solution type occurs several times.
+ The general form of a quadratic equation is
+\begin_inset Formula
+\[
+0=\lambda^{2}+p\lambda+q
+\]
+
+\end_inset
+
+The general form of the solution is
+\begin_inset Formula
+\[
+\lambda_{1,2}=-\frac{p}{2}\pm\sqrt{\frac{p²}{4}-q}
+\]
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+To define a command for the solution formula where only the three parameters
+
+\begin_inset Formula $\lambda$
+\end_inset
+
+,
+\begin_inset Formula $p$
+\end_inset
+
+ and
+\begin_inset Formula $q$
+\end_inset
+
+ need to be specified and the index of
+\begin_inset Formula $\lambda$
+\end_inset
+
+ can be given optionally, the LaTeX-preamble line is
+\begin_inset Newline newline
+\end_inset
+
+
+\series bold
+
+\backslash
+newcommand{
+\backslash
+qG}[4][1,
+\backslash
+,2]{#2_{#1}=-
+\backslash
+frac{#3}{2}
+\backslash
+pm
+\begin_inset Newline newline
+\end_inset
+
+
+\begin_inset Phantom HPhantom
+status open
+
+\begin_layout Plain Layout
+
+\series bold
+
+\backslash
+newcommand
+\end_layout
+
+\end_inset
+
+
+\backslash
+sqrt{
+\backslash
+frac{#3^{2}}{4}-#4}}
+\end_layout
+
+\begin_layout Standard
+To create with this the solution formula, the command
+\begin_inset Newline newline
+\end_inset
+
+
+\series bold
+
+\backslash
+qG{
+\backslash
+lambda
+\begin_inset Formula $\to$
+\end_inset
+
+
+\backslash
+{p
+\begin_inset Formula $\to$
+\end_inset
+
+
+\backslash
+{q
+\series default
+ is inserted to a formula
+\series bold
+.
+\end_layout
+
+\begin_layout Standard
+The definition of the new command is unintuitive because one has to know
+ the schemes of all used LaTeX commands, e.
+\begin_inset space \thinspace{}
+\end_inset
+
+g.
+\begin_inset space \space{}
+\end_inset
+
+that a fraction is inserted in LaTeX as
+\series bold
+
+\backslash
+frac{numerator}{denominator}
+\series default
+.
+ Furthermore one can easily forget a brace in the definition and cannot
+ see in LyX what the new command is doing.
+ To avoid these problems LyX offers the possibility to use math macros instead
+ of the command
+\series bold
+
+\backslash
+newcommand
+\series default
+.
+\end_layout
+
+\begin_layout Standard
+A math macro is created by using the menu
+\family sans
+Insert\SpecialChar \menuseparator
+Math\SpecialChar \menuseparator
+Macro
+\family default
+ or the toolbar button
+\begin_inset Graphics
+ filename ../images/math-macro_newmacroname_newcommand.png
+ scale 85
+
+\end_inset
+
+.
+ The math macro toolbar appears together with the following box where the
+ macro is defined:
+\begin_inset Newline newline
+\end_inset
+
+
+\begin_inset space \hspace*{\fill}
+\end_inset
+
+
+\begin_inset Graphics
+ filename clipart/macrobox.png
+
+\end_inset
+
+
+\begin_inset space \hspace*{\fill}
+\end_inset
+
+
+\begin_inset Newline newline
+\end_inset
+
+
+\begin_inset FormulaMacro
+\newcommand{\qG}[4][1,\,2]{#2_{#1}=-\frac{#3}{2}\pm\sqrt{\frac{#3^{2}}{4}-#4}}
+\end_inset
+
+
+\backslash
+newmacroname is the default name of the macro that should be changed to
+ something sensible.
+ The wanted formula is inserted in the first blue box.
+ An argument placeholder is inserted with the command
+\series bold
+
+\backslash
+#argumentnumber
+\series default
+, e.
+\begin_inset space \thinspace{}
+\end_inset
+
+g
+\begin_inset space \space{}
+\end_inset
+
+
+\series bold
+
+\backslash
+#1
+\series default
+ or by using the macro toolbar button
+\begin_inset Graphics
+ filename ../images/math-macro-add-param.png
+ scale 85
+
+\end_inset
+
+.
+ Argument placeholders are displayed red.
+ Maximum 9 arguments are possible.
+ Optional arguments are created with the toolbar button
+\begin_inset Graphics
+ filename ../images/math-macro-add-optional-param.png
+ scale 85
+
+\end_inset
+
+.