1 #This file was created by <larsbj> Sun Dec 5 17:47:02 1999
2 #LyX 1.0 (C) 1995-1999 Matthias Ettrich and the LyX Team
15 \paperorientation portrait
18 \paragraph_separation indent
20 \quotes_language english
24 \paperpagestyle default
28 User defined macros in math mode
31 Alejandro Aguilar Sierra
40 LyX version 0.12 allows the user to define macros.
41 An user defined macro in math mode is not a red colored name that LyX didn't
42 know how to draw (formerly known as macro mode, now simply TeX mode).
43 A macro definition box appears on screen as a grayed button with the name
44 of the macro in blue (math color).
45 But if you click on it, it will appear as a normal math box to allow you
48 \begin_inset FormulaMacro
49 \newcommand{\macro}{a+b}
56 Now, to use this macro in other math boxes just type the name in TeX mode,
63 , and it will be automatically expanded:
64 \begin_inset Formula \( c=\macro \)
68 As you can verify, the cursor can't go inside the macro, the whole macro
69 is like a single character, and the TeX generated code of this expression
77 However the cursor could go inside of some kind of macros, those that have
83 In a macro definition box an argument looks like a
87 followed by the argument number:
88 \begin_inset FormulaMacro
89 \newcommand{\macrowarg}[1]{2+\sqrt{#1 }}
96 Once expanded, this macro includes the usual empty rectangle to indicate
97 that you can insert there whatever you want:
102 \begin_inset Formula \( \macrowarg{} \)
109 \begin_inset Formula \( b=\macrowarg{x-2} \)
116 When exported to LaTeX, a macro definition will produce the command
123 Directions on using macros
129 To create a macro definition box use this syntax in the minibuffer:
134 math-macro <macro name> [number of arguments]
144 \begin_inset Quotes eld
152 \begin_inset Quotes erd
162 \begin_inset Quotes eld
167 math-macro macrowarg 1
170 \begin_inset Quotes erd
176 To insert an argument mark (only inside a macro definition box) use this:
181 math-macro-arg <number>
191 \begin_inset Quotes eld
199 \begin_inset Quotes erd
205 You can use no more than 9 arguments, numbered from 1 to 9.
206 An argument can be repeated inside the macro definition box, but of course
207 can be edited only once.
208 A number can't be greater than the number of arguments originally allowed
222 keys: Opening a macro form the left side will put the cursor in the first
223 argument, to move to the second argument use the TAB key.
224 Remember that pressing the Space bar will get the cursor out and at the
225 right side of the macro.
232 mouse: As usual, click on the desired argument box.
233 Sometimes this fails if the box is empty or too small.
236 Currently the user can only define command macros, but internally it's possible
237 to define also environment macros.
240 There are several predefined macros, mainly to allow AMS-LaTeX users to
241 use AMS macros in a WYSIWYM way, like
262 are currently disabled because after some simplification and improving
263 of the macro stuff, the only valid arguments are subparagraphs (neither
265 Perhaps they will be again included before 0.12