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