[OS X TeX] Boldface
Maarten Sneep
maarten.sneep at xs4all.nl
Sun Feb 13 22:59:51 CET 2005
On 13 feb 2005, at 22:28, Alain Schremmer wrote:
> It can matter—a bit: Say you were writing about three "occurrences" of
> something and that you wanted to index "occurence".
> But this is really a shortcoming of NewTerm.
> I think that there are a couple of occurences of this in my book but I
> will change the wording around it as I come across them (in one of my
> many rereads).
Use an optional parameter:
\usepackage{ifthen}
\newcommand{\NewTerm}[2][SameInIndex]{\ifthenelse{\equal{#1}{SameInIndex
}}{%
\textbf{#2}\index{#2}}{%
\textbf{#2}\index{#1}}%
}
Without the optional parameter, the text and the index are the same, if
you add an optional parameter, it will be used for the index.
> What I am curious about is what the difference is between (.+?) and
> [^}]* (I assume that this is to allow the reference \1.)
Different way of preventing that too much is replaced. {.+?} will
select everything within braces, but the question mark makes it
non-greedy, it will match as little as possible. The second form
{[^}]*} will select a brace, everything that is not a brace, and then a
brace again. I find the first easier to read. The parentheses are there
to store the results that are found in a numbered variable for later
reuse (either in the search pattern, or in the replacement pattern).
You could use {([^}]*)}, but I guess this just shows why I prefer the
first option.
With the above alternate command: try the following:
Search:
\\textbf{(.+?)}\\index{\01}
Replace:
\\NewTerm{\01}
Search:
\\textbf{(.+?)}\\index{(.+?)}
Replace:
\\NewTerm[\02]{\01}
Maarten
--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
& FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>
More information about the macostex-archives
mailing list