[OS X TeX] Checking my files

Ross Moore ross at ics.mq.edu.au
Sun Mar 5 20:14:17 CET 2006


Hi Florian,

On 06/03/2006, at 5:32 AM, Florian Grammel wrote:

> Thanks for your hint, Pete, but I'm afraid this is too advanced for  
> me...
> And I'd also like to ask my other -- probably very trivial --   
> question one more time:
>
>>
>> And then I also would like to check while proofreading the paper- 
>> copy, whether I have put my index-tags in the right places.  
>> Something like
>>
>> ...
>> \usepackage{index}
>> ...
>> \renewcommand{\index}{\ul{\index}}

This certainly cannot work, as it leads to an infinite recursion.

>> ...
>>
>> seemed the obvious solution, but I can't get it to work. Obviously  
>> the obvious is too obvious in this case?


To avoid recursion, you'll need something like:

   \let\realindex\index
   \renewcommand{\index}{\ul{\realindex}}

... but that in itself isn't enough, since \index takes an argument.
Maybe this is syntactically correct:

   \let\realindex\index
   \renewcommand{\index}[1]{\ul{\realindex{#1}}}

or if you make use of the optional argument  e.g. \index[option]{marker}
then it'll need to be:

   \let\realindex\index
   \renewcommand{\index}[2][]{\ul{\realindex[#1]{#2}}}

But there is also  \index*  which you might use.
If so, then the above is *not* enough.

This is a better solution:

   \def\patchedindex#1#{\patchedindexi{#1}}
   \def\patchedindexi#1#2{\realindexi#1{#2}}
   \AtBeginDocument{\let\realindex\index \let\index\patchedindex}


But just getting the syntax right isn't going to be enough for you.
Since \index doesn't put anything visible onto the page, then you
won't see anything from  \ul  (underline, from  soul , right ?).

Instead, I think you want something like:

    \indexword{<visible>}{<indexed>}

used like:

     ...in all my \indexword{documents}{document}.

instead of having your source say

      ...in all my documents\index{document}.

where the normal definition of \indexword  is:

     \newcommand{\indexword}[3][]{#2\index[#1]{#3}}

or (better, for a *-form and/or [...] ) use this:

     \def\indexword#1#{\indexwordi{#1}}
     \newcommand{\indexwordi}[3]{#2\index#1{#3}}

Now to get visible underlines, just add \ul to the bit (#2)
that actually puts the word on the page:

     \renewcommand{\indexwordi}[3]{\ul{#2}\index#1{#3}}


Of course, to make this work you need to adjust your LaTeX source
wherever you inserted  \index  directly.


It's one of the traps in using \index directly in LaTeX documents
that it's very inflexible when you need a visual marker for the
places that have been indexed.

For example, when generating an HTML version, you naturally want
each indexed word or phrase to be a hyperlink to where it appears
in the printed Index or Glossary. Thus you need a syntax such as
the \indexword above, taking 2 arguments rather than 1.
(La)TeX doesn't allow you to "look backwards" (e.g. at the last
word typeset) and add extra markup. For a Perl script like
LaTeX2HTML this *is* possible --- though there are complications
when it isn't just a word being indexed.


>>
>
> Any help would be very much appreciated!

Is the above what you wanted ?


>
> Florian.


Hope this helps,

	Ross


------------------------------------------------------------------------
Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia  2109                            fax: +61 +2 9850 8114
------------------------------------------------------------------------


------------------------- 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 Archive: http://tug.org/pipermail/macostex-archives/




More information about the macostex-archives mailing list