]> git.lyx.org Git - lyx.git/blob - development/mathmacros/testcases_basic.lyx
Customization: correct some color names.
[lyx.git] / development / mathmacros / testcases_basic.lyx
1 #LyX 1.6svn created this file. For more info see http://www.lyx.org/
2 \lyxformat 317
3 \begin_document
4 \begin_header
5 \textclass article
6 \language english
7 \inputencoding auto
8 \font_roman default
9 \font_sans default
10 \font_typewriter default
11 \font_default_family default
12 \font_sc false
13 \font_osf false
14 \font_sf_scale 100
15 \font_tt_scale 100
16 \graphics default
17 \paperfontsize default
18 \use_hyperref false
19 \papersize default
20 \use_geometry false
21 \use_amsmath 1
22 \use_esint 1
23 \cite_engine basic
24 \use_bibtopic false
25 \paperorientation portrait
26 \secnumdepth 3
27 \tocdepth 3
28 \paragraph_separation indent
29 \defskip medskip
30 \quotes_language english
31 \papercolumns 1
32 \papersides 1
33 \paperpagestyle default
34 \tracking_changes false
35 \output_changes false
36 \author "" 
37 \author "" 
38 \end_header
39
40 \begin_body
41
42 \begin_layout Title
43 Macro Testcases
44 \end_layout
45
46 \begin_layout Enumerate
47 Simple macro definitions with position awareness: 
48 \begin_inset FormulaMacro
49 \newcommand{\bla}{42}
50 \end_inset
51
52
53 \begin_inset Formula \[
54 \bla\mbox{ should look like }42\]
55
56 \end_inset
57
58 now redined as 
59 \begin_inset FormulaMacro
60 \renewcommand{\bla}{21}
61 \end_inset
62
63 , such that
64 \begin_inset Formula \[
65 \bla\mbox{ should look like }21.\]
66
67 \end_inset
68
69
70 \end_layout
71
72 \begin_layout Enumerate
73 Redefinitions of macros appearing in the definition of another macro: 
74 \begin_inset FormulaMacro
75 \newcommand{\fooa}{x}
76 \end_inset
77
78
79 \begin_inset FormulaMacro
80 \newcommand{\foob}[1]{(#1\fooa)}
81 \end_inset
82
83
84 \begin_inset FormulaMacro
85 \renewcommand{\fooa}{y}
86 \end_inset
87
88  with the TeX code
89 \begin_inset listings
90 inline false
91 status open
92
93 \begin_layout PlainLayout
94
95 \backslash
96 newcommand{
97 \backslash
98 fooa}{x} 
99 \end_layout
100
101 \begin_layout PlainLayout
102
103 \backslash
104 newcommand{
105 \backslash
106 foob}[1]{(#1
107 \backslash
108 fooa)}
109 \end_layout
110
111 \begin_layout PlainLayout
112
113 \backslash
114 renewcommand{
115 \backslash
116 fooa}{y}
117 \end_layout
118
119 \end_inset
120
121 gives the following:
122 \begin_inset Formula \[
123 \foob{\fooa}\mbox{ should look like }(yy)\]
124
125 \end_inset
126
127
128 \end_layout
129
130 \begin_layout Enumerate
131 Arity change: 
132 \begin_inset FormulaMacro
133 \newcommand{\foo}{-}
134 \end_inset
135
136
137 \begin_inset FormulaMacro
138 \renewcommand{\foo}[2]{(#1,#2)}
139 \end_inset
140
141
142 \begin_inset Formula \[
143 \foo{abc}d\mbox{ should look like }(abc,d)\mbox{ if the second foo is there, otherwise like }-{abc}d\]
144
145 \end_inset
146
147
148 \end_layout
149
150 \begin_layout Enumerate
151 Arity change with incomplete arguments at line end: 
152 \begin_inset FormulaMacro
153 \renewcommand{\foo}{-}
154 \end_inset
155
156
157 \begin_inset FormulaMacro
158 \renewcommand{\foo}[2]{(#1,#2)}
159 \end_inset
160
161  
162 \begin_inset Formula \[
163 \frac{\foo{abc}{}}{1}\mbox{ should be }\frac{(abc,\,)}{1}\mbox{ if the second foo is defined. Otherwise }\frac{-{abc}{}}{1}\]
164
165 \end_inset
166
167
168 \end_layout
169
170 \begin_layout Enumerate
171 Recursion: 
172 \begin_inset FormulaMacro
173 \renewcommand{\foo}[1]{\foo #1{}}
174 \end_inset
175
176 .
177  The inner foo should not we resolved as TeX would give a infinite recursion.
178 \end_layout
179
180 \begin_layout Enumerate
181 Recursive usage: 
182 \begin_inset FormulaMacro
183 \renewcommand{\foo}[3]{\frac{{\displaystyle #1}\,{\displaystyle #2}}{{\displaystyle #3}}}
184 \end_inset
185
186  can be used to create tree-like structures like this one:
187 \begin_inset Formula \[
188 \foo{\foo{42}{\foo{asdf}{asdf}{asdf}}{21}}{\foo{asdf}{asdf}{asdf}}{asdf}.\]
189
190 \end_inset
191
192
193 \end_layout
194
195 \begin_layout Enumerate
196 Folding/Unfolding:
197 \begin_inset FormulaMacro
198 \renewcommand{\foo}[2]{<#1|#2>}
199 \end_inset
200
201 .
202  Start using Ctrl-+ and Ctrl-- when you are inside of the macro to fold
203  and unfold, e.g.
204  here:
205 \begin_inset Formula \[
206 \foo{\foo{42}{12}}{\foo{21}4}.\]
207
208 \end_inset
209
210
211 \end_layout
212
213 \begin_layout Enumerate
214 Scripts: 
215 \begin_inset FormulaMacro
216 \renewcommand{\foo}[3][A][B]{(#1,#2)#3}
217 \end_inset
218
219
220 \begin_inset Formula \[
221 \foo[a]{}^{4}[b]c_{1}\mbox{ should look like }(a,B)\sqcup^{4}[b]c_{1}\]
222
223 \end_inset
224
225
226 \begin_inset Formula \[
227 \foo[a]c^{3}\mbox{ should look like }(a,B)c^{3}\]
228
229 \end_inset
230
231
232 \end_layout
233
234 \begin_layout Enumerate
235 Multiple optional parameters:
236 \begin_inset FormulaMacro
237 \renewcommand{\foo}[3][a][b][c]{(#1,#2,#3)}
238 \end_inset
239
240
241 \end_layout
242
243 \begin_deeper
244 \begin_layout Enumerate
245 \begin_inset Formula $\foo[][B]123\mbox{ should be }(a,B,c)123$
246 \end_inset
247
248
249 \end_layout
250
251 \begin_layout Enumerate
252 \begin_inset Formula $\foo[][][C]123\mbox{ should be }(a,b,C)123$
253 \end_inset
254
255
256 \end_layout
257
258 \end_deeper
259 \end_body
260 \end_document