]> git.lyx.org Git - lyx.git/blob - lib/doc/AdvancedSearch.lyx
Close #6336.
[lyx.git] / lib / doc / AdvancedSearch.lyx
1 #LyX 1.6.5svn created this file. For more info see http://www.lyx.org/
2 \lyxformat 345
3 \begin_document
4 \begin_header
5 \textclass article
6 \use_default_options false
7 \language english
8 \inputencoding auto
9 \font_roman default
10 \font_sans default
11 \font_typewriter default
12 \font_default_family default
13 \font_sc false
14 \font_osf false
15 \font_sf_scale 100
16 \font_tt_scale 100
17
18 \graphics default
19 \paperfontsize default
20 \use_hyperref false
21 \papersize default
22 \use_geometry false
23 \use_amsmath 1
24 \use_esint 1
25 \cite_engine basic
26 \use_bibtopic false
27 \paperorientation portrait
28 \secnumdepth 3
29 \tocdepth 3
30 \paragraph_separation indent
31 \defskip medskip
32 \quotes_language english
33 \papercolumns 1
34 \papersides 1
35 \paperpagestyle default
36 \tracking_changes false
37 \output_changes false
38 \author "" 
39 \author "" 
40 \end_header
41
42 \begin_body
43
44 \begin_layout Section
45 Introduction to the find advanced feature
46 \end_layout
47
48 \begin_layout Standard
49 This is an introduction to the find advanced feature of LyX, that is activated
50  through the [C-S-f] sequence (Ctrl+Shift+f) and can be closed just by hitting
51  [
52 \noun on
53 Esc
54 \noun default
55 ] unlike other panes.
56 \end_layout
57
58 \begin_layout Standard
59 First, leave the ignore format option 
60 \series bold
61 checked
62 \series default
63 .
64 \end_layout
65
66 \begin_layout Enumerate
67 Search for the word 
68 \series bold
69 about
70 \series default
71  and see how it is found both in text mode and in math mode, and both in
72  emphasized, bold or normal face, and both in section titles and in standard
73  text.
74  When finished typing the text to find in the 
75 \noun on
76 Find...
77
78 \noun default
79  box, pressing repeatidly 
80 \noun on
81 [Enter]
82 \noun default
83  will search for it forward, while pressing 
84 \noun on
85 [Shift+Enter]
86 \noun default
87  will search backwards.
88 \end_layout
89
90 \begin_layout Enumerate
91 Search for some math by typing in the 
92 \noun on
93 Find...
94
95 \noun default
96  box a 
97 \begin_inset Formula $x^{2}$
98 \end_inset
99
100  in simple math (C-m) mode (you can directly copy it from this text and
101  paste into the 
102 \noun on
103 Find...
104
105 \noun default
106  box), or also something more elaborate like 
107 \begin_inset Formula $\frac{gh}{ij}$
108 \end_inset
109
110 .
111  See how it is found both when alone and when in subformulas and nested
112  parts of subformulas.
113 \end_layout
114
115 \begin_layout Standard
116 Now, uncheck the ignore format option.
117 \end_layout
118
119 \begin_layout Enumerate
120 Search for a plain 'about' word and see how emphasized and boldface instances,
121  as well as the ones in non-standard style, are not found anymore.
122 \end_layout
123
124 \begin_layout Enumerate
125 Search for 
126 \emph on
127 emphasized about
128 \emph default
129  or 
130 \series bold
131 boldface about
132 \series default
133  and see how you can find the respective instances with same face only,
134  and within same text style only (e.g.
135  in order to find the words in this paragraph, you need to also add an enumerate
136  style).
137  Note that e.g.
138  emphasized text is found not only when alone, but also when it is in a
139  longer emphasized sentence.
140 \end_layout
141
142 \begin_layout Enumerate
143 Search for the word 'about' (again plain face) giving it a Section style
144  from the style selection dropdown menu, and see how it is found only within
145  Section titles.
146  Repeat with the word '
147 \emph on
148 advanced
149 \emph default
150 ' in emphasized face, with 
151 \noun on
152 Section
153 \noun default
154  style, and see how its corresponding instance is found.
155 \end_layout
156
157 \begin_layout Enumerate
158 Search for some math in centered line math (C-S-m) mode, like this 
159 \begin_inset Formula \[
160 x^{2}\]
161
162 \end_inset
163
164 and see how only instances of the text within the same kind of environment
165  are found.
166 \end_layout
167
168 \begin_layout Subsection
169 About using regular expressions in the Find...
170  box
171 \end_layout
172
173 \begin_layout Standard
174 Now you can try the regular expression based searching facility.
175  Users may arbitrarily insert, within text or math material, regexp-mode
176  insets that allow to enter regular subexpressions.
177  This is done either through 
178 \noun on
179 [Insert]->[Regexp]
180 \noun default
181  or by typing [C-S-r].
182  Characters entered in the 
183 \noun on
184 [Find...]
185 \noun default
186  box within regexp insets are matched according to the regular expression
187  matching rules
188 \begin_inset Foot
189 status collapsed
190
191 \begin_layout Plain Layout
192 but under the constraint that any subexpression must match a well-formed
193  LyX text segment, i.e.
194  when matching LaTeX code, no segments with unbalanced {} braces are allowed
195  to match subexpressions entered by the user.
196 \end_layout
197
198 \end_inset
199
200 , while text entered outside regexp insets is matched exactly against the
201  same text in the document.
202  Note that it is allowed to cut and paste regexp-mode insets as usual.
203  In order to try the feature, first leave the ignore format option checked.
204 \end_layout
205
206 \begin_layout Enumerate
207 Search for the fraction 
208 \begin_inset Formula $\frac{\regexp{.*}}{mn}$
209 \end_inset
210
211 , where the '.*' on the numerator is the match-everything regular expression
212  that may be added by pressing the 
213 \noun on
214 [Match...]->[Anything]
215 \noun default
216  button, or entering the regexp-mode through C-S-r and by typing '.*'.
217  See how all fractions with the specified denominator are found.
218 \end_layout
219
220 \begin_layout Enumerate
221 Now uncheck the Ignore Format option and search for '
222 \series bold
223 .*
224 \series default
225 ' in boldface, or '
226 \emph on
227 .*
228 \emph default
229 ' in emphasized face.
230  See how, respectively, all boldface and all emphasized text is found.
231 \end_layout
232
233 \begin_layout Enumerate
234 Search for a plain '.*' giving it a Section style, and navigate across section
235  titles (similarly, navigate across enumerated or bulletted lists).
236 \end_layout
237
238 \begin_layout Enumerate
239 You can use references to subexpressions as usual, enclosing parts of the
240  regex expression within round braces '()', and referring back to them through
241  
242 \backslash
243 1, 
244 \backslash
245 2, etc...
246  (within either the same or another regexp-mode inset, where a '
247 \backslash
248 ' symbol is entered by pressing twice the '
249 \backslash
250 ' key).
251  For example, try searching for '
252 \begin_inset Formula \regexp{[\^a-z]([a-z]+)}
253
254 \end_inset
255
256  
257 \begin_inset Formula \regexp{\backslash1}
258
259 \end_inset
260
261 ' in order to find word repetitions, if any.
262 \end_layout
263
264 \begin_layout Standard
265 What follows is just a set of meaningless formulas and sentences useful
266  for for testing purposes.
267 \end_layout
268
269 \begin_layout Standard
270 \begin_inset Formula $y+x+X^{2}+\frac{gh}{ij}-1+x_{j}^{i}+y_{jk}^{ip}+i$
271 \end_inset
272
273  and 
274 \begin_inset Formula $z+x_{j}^{i}.$
275 \end_inset
276
277
278 \end_layout
279
280 \begin_layout Standard
281 Hi, world ! 
282 \emph on
283 what
284 \emph default
285  about your 
286 \begin_inset Formula $X+y^{2}+\frac{x+x^{2}+\frac{gh}{ij}}{y^{x+x^{2}}+\frac{kl}{mn}}-about$
287 \end_inset
288
289  ?
290 \end_layout
291
292 \begin_layout Standard
293 \begin_inset Formula \[
294 X+y^{2}+\frac{x+x^{2}+\frac{gh}{ij}}{y^{x+x^{2}}+\frac{kl}{mn}}-about\]
295
296 \end_inset
297
298 Hi, universe ! what 
299 \emph on
300 about
301 \emph default
302  my 
303 \begin_inset Formula $c+\frac{kl}{mn}+\frac{\sqrt{\frac{gh}{ij}}}{mn}-\frac{1+\sqrt{\frac{about}{mn}}}{mn}+\textrm{about}$
304 \end_inset
305
306  ?
307 \end_layout
308
309 \begin_layout Section
310 Conclusion and future work about the find 
311 \emph on
312 advanced
313 \emph default
314  feature
315 \end_layout
316
317 \begin_layout Standard
318 This feature seems very useful to me.
319  Hope others will find it useful as well.
320  Currently, I'm not really happy with the implementation, because it has
321  at least quadratic complexity (document size multiplied by maximum paragraph
322  size, plus regexp matching complexity, if enabled, and infact it is quite
323  slow), but hopefully that will be fixable by changing the TeXOnePar() function
324  and simpleTeXOnePar() method, and possibly other TeX related methods.
325 \end_layout
326
327 \begin_layout Standard
328 Infact, a DocIterator could be used to keep track of the current position,
329  and an externally supplied functor could be called at each position providing
330  the DocIterator and LaTeX string translated so far to the external code.
331  This would allow to couple each DocIterator state with the position in
332  the output LaTeX string, allowing to recover the DocIterator positions
333  after a regexp-based find operation made (only once this time) on translated
334  LaTeX.
335 \end_layout
336
337 \begin_layout Standard
338 Again, a few meaningless sentences useful for testing purposes on about.
339 \end_layout
340
341 \begin_layout Standard
342 But 
343 \emph on
344 what about your
345 \emph default
346  health ?
347 \end_layout
348
349 \begin_layout Standard
350 But 
351 \series bold
352 what about your health
353 \series default
354  ?
355 \end_layout
356
357 \begin_layout Itemize
358 search for plain 'about'
359 \end_layout
360
361 \begin_layout Itemize
362 search for 
363 \emph on
364 emphasized about
365 \emph default
366  or 
367 \series bold
368 boldface about
369 \end_layout
370
371 \begin_layout Standard
372 \begin_inset Formula $y+x-x^{2}\cdot2$
373 \end_inset
374
375
376 \end_layout
377
378 \end_body
379 \end_document