-Arguments
-\end_layout
-
-\begin_layout Standard
-in the minibuffer at the bottom of the LyX screen.
- Name is the name of the new macro which mustn't contain numbers.
- The number of arguments can be a number in the range 1-9.
- If you want to define a macro without arguments, don't declare the number
- of arguments.
-\end_layout
-
-\begin_layout Standard
-We have three arguments and name the macro
-\begin_inset Quotes eld
-\end_inset
-
-qE
-\begin_inset Quotes erd
-\end_inset
-
-, so that the command is:
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-math-macro
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-
-
-\backslash
-spce
-\end_layout
-
-\end_inset
-
-qE
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-
-
-\backslash
-spce
-\end_layout
-
-\end_inset
-
-3
-\end_layout
-
-\begin_layout Standard
-This results in the following macro definition box:
-\begin_inset Graphics
- filename clipart/macrobox.png
-
-\end_inset
-
-
-\begin_inset FormulaMacro
-\newcommand{\qE}[3]{#1_{1,\,2}=-\frac{#2}{2}\pm\sqrt{\frac{#2^{2}}{4}-#3}}
-{\textrm{qE: }#1\textrm{ , }#2\textrm{ , }#3}
-\end_inset
-
-
-\begin_inset Note Note
-status collapsed
-
-\begin_layout Plain Layout
-The first box is an image to show the behavior in the output.
- The second one is the definition box, that doesn't appear in the output.
-\end_layout
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Standard
-The first blue box is for the definition, where you insert the formula via
- the math panel or commands.
- The placeholder for the arguments are inserted as a backslash and sharp
- followed by the argument number, e.g.
-
-\begin_inset Quotes eld
-\end_inset
-
-
-\backslash
-#1
-\begin_inset Quotes erd
-\end_inset
-
- for the first argument.
- Placeholders will be displayed in red.
- The second blue box is for the appearance in LyX.
- This is useful when you have a large structure that shouldn't be displayed
- in LyX with its full size.
- If you want to see the macro as it is defined, leave the box blank.
- In our example we insert the sequence
-\begin_inset Newline newline
-\end_inset
-
-
-\series bold
-qE:
-\backslash
-#1
-\series default
-
-\series bold
-,
-\series default
-
-\series bold
-
-\backslash
-#2
-\series default
-
-\series bold
-,
-\series default
-
-\series bold
-
-\backslash
-#3
-\begin_inset Newline newline
-\end_inset
-
-
-\series default
-The macro will then be shown as the macro name followed by the three arguments.
-\end_layout
-
-\begin_layout Standard
-To use the macro in a formula, type its name as command, in our case
-\begin_inset Quotes eld
-\end_inset
-
-
-\series bold
-
-\backslash
-qE
-\series default
-
-\begin_inset Quotes erd
-\end_inset
-
-.
- The macro is inserted with boxes for the arguments looking similar to this:
-\end_layout
-
-\begin_layout Standard
-\align center
-\begin_inset Graphics
- filename clipart/macrouse.png
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Standard
-The arguments are inserted in the blue boxes.
- If the cursor is outside the macro, the arguments are put in the macro.
- To change the arguments, put the cursor in the formula before or after
- the macro and press the right or left arrow key respectively.
- The arguments appear now again below the macro definition.
-\end_layout
-
-\begin_layout Standard
-If you change the macro definition all macros are changed automatically
- to the new definition.
- Here an example of our macro with the arguments
-\begin_inset Formula $x$
-\end_inset
-
-,
-\begin_inset Formula $\ln(x)$
-\end_inset
-
-, and
-\begin_inset Formula $B$
-\end_inset
-
-:
-\begin_inset Formula \[
-\qE x{\ln(y)}B\]
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Standard
-When the document is exported to LaTeX, the macro definition will be inserted
- as the command:
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-
-\backslash
-newcommand{
-\backslash
-qE}[3]{#1_{1,
-\backslash
-,2}=-
-\backslash
-frac{#2}{2}
-\backslash
-pm
-\begin_inset Newline newline
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-
-
-\backslash
-hphantom{
-\end_layout
-
-\end_inset
-
-
-\backslash
-newcommand
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-
-}
-\end_layout
-
-\end_inset
-
-
-\backslash
-sqrt{
-\backslash
-frac{#2^{2}}{4}-#3}}
-\end_layout
-
-\begin_layout Standard
-The command is not inserted in the document preamble.
- That means you can only use macros in formulas that are below the macro
- definition box in your document.
- There are also some other restrictions: The command
-\backslash
-newcommand supports optional arguments, which are not available in LyX's
- macros.
- You can also not change subsequently the name of the macro and the number
- of arguments.
-