]> git.lyx.org Git - lyx.git/blob - autotests/mathmacros/testcases_basic.lyx
da70e7e619939f361a0649b40f0ee9057dbc88ae
[lyx.git] / autotests / mathmacros / testcases_basic.lyx
1 #LyX 2.4 created this file. For more info see https://www.lyx.org/
2 \lyxformat 572
3 \begin_document
4 \begin_header
5 \save_transient_properties true
6 \origin unavailable
7 \textclass article
8 \use_default_options false
9 \maintain_unincluded_children false
10 \language english
11 \language_package default
12 \inputencoding auto
13 \fontencoding auto
14 \font_roman "default" "default"
15 \font_sans "default" "default"
16 \font_typewriter "default" "default"
17 \font_math "auto" "auto"
18 \font_default_family default
19 \use_non_tex_fonts false
20 \font_sc false
21 \font_osf false
22 \font_sf_scale 100 100
23 \font_tt_scale 100 100
24 \use_microtype false
25 \use_dash_ligatures true
26 \graphics default
27 \default_output_format default
28 \output_sync 0
29 \bibtex_command default
30 \index_command default
31 \paperfontsize default
32 \use_hyperref false
33 \papersize default
34 \use_geometry false
35 \use_package amsmath 1
36 \use_package amssymb 1
37 \use_package cancel 1
38 \use_package esint 1
39 \use_package mathdots 0
40 \use_package mathtools 1
41 \use_package mhchem 1
42 \use_package stackrel 1
43 \use_package stmaryrd 1
44 \use_package undertilde 1
45 \cite_engine basic
46 \cite_engine_type default
47 \biblio_style plain
48 \use_bibtopic false
49 \use_indices false
50 \paperorientation portrait
51 \suppress_date false
52 \justification true
53 \use_refstyle 0
54 \use_minted 0
55 \index Index
56 \shortcut idx
57 \color #008000
58 \end_index
59 \secnumdepth 3
60 \tocdepth 3
61 \paragraph_separation indent
62 \paragraph_indentation default
63 \is_math_indent 0
64 \math_numbering_side default
65 \quotes_style english
66 \dynamic_quotes 0
67 \papercolumns 1
68 \papersides 1
69 \paperpagestyle default
70 \tablestyle default
71 \tracking_changes false
72 \output_changes false
73 \html_math_output 0
74 \html_css_as_file 0
75 \html_be_strict false
76 \end_header
77
78 \begin_body
79
80 \begin_layout Title
81 Macro Testcases
82 \end_layout
83
84 \begin_layout Enumerate
85 Simple macro definitions with position awareness: 
86 \begin_inset FormulaMacro
87 \newcommand{\bla}{42}
88 \end_inset
89
90
91 \begin_inset Formula 
92 \[
93 \bla\mbox{ should look like }42
94 \]
95
96 \end_inset
97
98 now redined as 
99 \begin_inset FormulaMacro
100 \renewcommand{\bla}{21}
101 \end_inset
102
103 , such that
104 \begin_inset Formula 
105 \[
106 \bla\mbox{ should look like }21.
107 \]
108
109 \end_inset
110
111
112 \end_layout
113
114 \begin_layout Enumerate
115 Redefinitions of macros appearing in the definition of another macro: 
116 \begin_inset FormulaMacro
117 \newcommand{\fooa}{x}
118 \end_inset
119
120
121 \begin_inset FormulaMacro
122 \newcommand{\foob}[1]{(#1\fooa)}
123 \end_inset
124
125
126 \begin_inset FormulaMacro
127 \renewcommand{\fooa}{y}
128 \end_inset
129
130  with the \SpecialChar TeX
131  code
132 \begin_inset listings
133 inline false
134 status open
135
136 \begin_layout Plain Layout
137
138
139 \backslash
140 newcommand{
141 \backslash
142 fooa}{x} 
143 \end_layout
144
145 \begin_layout Plain Layout
146
147
148 \backslash
149 newcommand{
150 \backslash
151 foob}[1]{(#1
152 \backslash
153 fooa)}
154 \end_layout
155
156 \begin_layout Plain Layout
157
158
159 \backslash
160 renewcommand{
161 \backslash
162 fooa}{y}
163 \end_layout
164
165 \end_inset
166
167 gives the following:
168 \begin_inset Formula 
169 \[
170 \foob{\fooa}\mbox{ should look like }(yy)
171 \]
172
173 \end_inset
174
175
176 \end_layout
177
178 \begin_layout Enumerate
179 Arity change: 
180 \begin_inset FormulaMacro
181 \newcommand{\foo}{-}
182 \end_inset
183
184
185 \begin_inset FormulaMacro
186 \renewcommand{\foo}[2]{(#1,#2)}
187 \end_inset
188
189
190 \begin_inset Formula 
191 \[
192 \foo{abc}d\mbox{ should look like }(abc,d)\mbox{ if the second foo is there, otherwise like }-{abc}d
193 \]
194
195 \end_inset
196
197
198 \end_layout
199
200 \begin_layout Enumerate
201 Arity change with incomplete arguments at line end: 
202 \begin_inset FormulaMacro
203 \renewcommand{\foo}{-}
204 \end_inset
205
206
207 \begin_inset FormulaMacro
208 \renewcommand{\foo}[2]{(#1,#2)}
209 \end_inset
210
211  
212 \begin_inset Formula 
213 \[
214 \frac{\foo{abc}{}}{1}\mbox{ should be }\frac{(abc,\,)}{1}\mbox{ if the second foo is defined. Otherwise }\frac{-{abc}{}}{1}
215 \]
216
217 \end_inset
218
219
220 \end_layout
221
222 \begin_layout Enumerate
223 Recursion: 
224 \begin_inset FormulaMacro
225 \renewcommand{\foo}[1]{\foo{#1}{}}
226 \end_inset
227
228 .
229  The inner foo should not we resolved as \SpecialChar TeX
230  would give a infinite recursion.
231 \end_layout
232
233 \begin_layout Enumerate
234 Recursive usage: 
235 \begin_inset FormulaMacro
236 \renewcommand{\foo}[3]{\frac{{\displaystyle #1}\,{\displaystyle #2}}{{\displaystyle #3}}}
237 \end_inset
238
239  can be used to create tree-like structures like this one:
240 \begin_inset Formula 
241 \[
242 \foo{\foo{42}{\foo{asdf}{asdf}{asdf}}{21}}{\foo{asdf}{asdf}{asdf}}{asdf}.
243 \]
244
245 \end_inset
246
247
248 \end_layout
249
250 \begin_layout Enumerate
251 Folding/Unfolding:
252 \begin_inset FormulaMacro
253 \renewcommand{\foo}[2]{<#1|#2>}
254 \end_inset
255
256 .
257  Start using Ctrl-+ and Ctrl– when you are inside of the macro to fold and
258  unfold, e.g.
259  here:
260 \begin_inset Formula 
261 \[
262 \foo{\foo{42}{12}}{\foo{21}4}.
263 \]
264
265 \end_inset
266
267
268 \end_layout
269
270 \begin_layout Enumerate
271 Scripts: 
272 \begin_inset FormulaMacro
273 \renewcommand{\foo}[3][A][B]{(#1,#2)#3}
274 \end_inset
275
276
277 \begin_inset Formula 
278 \[
279 \foo[a]{}^{4}[b]c_{1}\mbox{ should look like }(a,B)\sqcup^{4}[b]c_{1}
280 \]
281
282 \end_inset
283
284
285 \begin_inset Formula 
286 \[
287 \foo[a]c^{3}\mbox{ should look like }(a,B)c^{3}
288 \]
289
290 \end_inset
291
292
293 \end_layout
294
295 \begin_layout Enumerate
296 Multiple optional parameters:
297 \begin_inset FormulaMacro
298 \renewcommand{\foo}[3][a][b][c]{(#1,#2,#3)}
299 \end_inset
300
301
302 \begin_inset Separator latexpar
303 \end_inset
304
305
306 \end_layout
307
308 \begin_deeper
309 \begin_layout Enumerate
310 \begin_inset Formula $\foo[][B]123\mbox{ should be }(a,B,c)123$
311 \end_inset
312
313
314 \end_layout
315
316 \begin_layout Enumerate
317 \begin_inset Formula $\foo[][][C]123\mbox{ should be }(a,b,C)123$
318 \end_inset
319
320
321 \end_layout
322
323 \end_deeper
324 \end_body
325 \end_document