Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

\index in \footnote with LaTeX problem

146 views
Skip to first unread message

Martin Timann

unread,
Oct 15, 1991, 3:45:17 AM10/15/91
to
Hi (La)TeX-Users,

I have the following problem with LaTeX 2.09 (last modification Jan 1990).
I am often using \index commands in \footnote environments. This would not
be harmfull, but if the argument of the \index command contains any special
characters like an umlaut (\"a, \"u, \"o or in connection with german.sty
"a, "o, "u ) or a tilde (for example in abreviations to prevent linebreaking
like in Nr.~5) I have to protect these special items with the \protect
command to avoid crazy output in the \jobname.idx file. But in this case
there occurs an ugly spacing in \jobname.idx. For examlple:

\footnote{.... \index{Johanna d.\protect~Wahnsinnige} ...}
puts in my .idx file
\indexentry{Johanna d.~ Wahnsinnige}{<pagenummber>}
^
which produces an etra space between "d.~" and "Wahnsinnige".

So I took a look at the latex.tex file and found the following code
at line 6241:

\def\makeindex{\if@filesw \newwrite\@indexfile
\immediate\openout\@indexfile=\jobname.idx
\def\index{\@bsphack\begingroup
\def\protect####1{\string####1\space}\@sanitize
\@wrindex}\typeout ^^^^^^
{Writing index file \jobname.idx }\fi}

The problem is now that I cannot remove the \space command from the
definition of the \protect command and recompose the formt file cause it's
necessary if I use a command like \dag:

\footnote{.... \index{Mister X (\dag 1976)} ...}

In this case I would get

\indexentry{Mister X (\dag1976)}{<pagenumber>}

which is certainly not what I want.

Of course I could take an editor and strip the extra space from the .idx
file before going on with indexprocessing, but it would be nice to avoid
the problem if one could determine with an "if clause" in the latex.tex
file whether to strip the space or to hold it but how can I distinguish
between a command????? and a commandsequence? (I don't know the terminus
technicus, but I know there is one, I'm only a LaTeX User not a (La)TeX
programmer).

Hapy (La)TeXing
Martin
--
+----------------------------------------+-----------------------------------+
| NOTE: PLEASE USE MAIL ADDRESS BELOW RATHER THAN ADDRESSES GIVEN IN HEADER! |
+----------------------------------------+-----------------------------------+
| Martin Timann | Phone: (+49) 5251 846589 |
| Siemens Nixdorf Informationssysteme AG | Email: |
| Abt. STO-NC 312 | DOMAIN timan...@sni.de (EU)|
| Pontanusstrasse 55 | timan...@sni-usa.com (US)|
| W-4790 Paderborn | BANG unido!nixpbe!timann.pad(EU)|
| Germany | linus!nixbur!timann.pad(US)|
| | OTHER timan...@nixpbe.uucp |
+----------------------------------------+-----------------------------------+

Bernd Raichle

unread,
Oct 15, 1991, 7:36:27 AM10/15/91
to
In <timann.687512717@peun46> timan...@sni.de (Martin Timann) writes:
> \footnote{.... \index{Johanna d.\protect~Wahnsinnige} ...}
> puts in my .idx file
> \indexentry{Johanna d.~ Wahnsinnige}{<pagenummber>}
> ^
> which produces an etra space between "d.~" and "Wahnsinnige".

1.)
\index tries to write its argument without expansion to the idx-file.
To do this it reassigns the categories codes of most special
characters. If you are using \index inside the argument of another
macro, the reassignment is too late (because the category codes of
the characters are fixed).

[It's obvious when using \verb, e.g.
\footnote{.... \verb+~\%+ ...}
because you get an error in most cases. But \index has a similar
behaviour.
]

2.)
\protect is defined to protect command sequences, not active
characters.


Possible solutions:
-- rewrite \index, use the \meaning trick (see one of the TUGboat
articles which appreaded this year for more) instead of \@sanitize

-- Quick&Dirty:
write your own active character \protect, e.g.
\def\indexprotect#1{\string#1}
and use this inside \index.


-bernd
__________________________________________________________________________
Bernd Raichle, Student der Universit"at Stuttgart | "Le langage est source
privat: Stettener Str. 73, D-W-7300 Esslingen | de malentendus"
email: rai...@azu.informatik.uni-stuttgart.de | (A. de Saint-Exupery)

0 new messages