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