[NTG-context] Formatting Indexed Words Within the Text

Alan BRASLAU alan.braslau at cea.fr
Fri Mar 23 14:04:53 CET 2012


On Fri, 23 Mar 2012 21:57:04 +1100
Malte Stien <malte at stien.de> wrote:

> Hi all,
> 
> Is it possible to format indexed words in a particular style within
> the text more or less automatically. For example, if I write
> 
>   There are some \index[ducks] in the zoo.
> 
> ...I would like the term "ducks" to appear in small-capitals to
> indicate the that term can be found in the index. Ideally, I'd like
> to do that without explicit manual formatting. Is that possible?
> 
> Thank you,
> Malte.

Your example above would not print the word "ducks" at all.


I commonly use:
\def\Index#1{\index{#1}#1}

There are some \Index{ducks} in the zoo.


In ConTeXt, text to be typeset typically appears within {}.
Of course, you can then modify the definition to format the text as you
wish:
\def\Index#1{\index{#1}\sc #1}

I'm sure that there is a more clever way.

Note that the \index{} command appears *before* the word, not after.
Otherwise, the word might get placed at the end of a page and the index
point to the following page. I believe that the \index{} command takes
care to avoid the opposite case.

Alan


More information about the ntg-context mailing list