# [texhax] index entries in latex/makeindex, post 2

Uwe Lück uwe.lueck at web.de
Wed Dec 17 03:24:19 CET 2008

[now to texhax as well, this is what Zbigniew Nitecki previously answered,
sorry;
I seeeems much more now that I was right -- U. L.]

At 21:10 16.12.08, Zbigniew Nitecki wrote:
>You seem to have put your finger on the problem:  when I insert a
>\usepackage{hyperref} command in my test file, I get the same error.  But
>I am rather confused about how this happened.  (1) this macro does not use
>the latex \ref macro, and (2) is there really a conflict between a macro
>name and a file name?

My repairing posting didn't suffice to make my point clear:
If nameref.sty is loaded \AtBeginDocument, it defines its own
\nameref, overwriting your definition. \nameref then expands to a
\ref, not to an \index.

It is easy to find out whether I'm right, most simple perhaps:
right after \begin{document}, type \show\nameref.
This should show the definition of \nameref on the screen.
I would like to know whether it is yours or another one.
If I'm right, you will have \protect\T at nameref on your screen.

I guess hyperref.sty is loaded by some other package
you are using anyway, maybe you use the memoir class
which contains many other packages.

Best,
Uwe.

>>At 17:14 16.12.08, Zbigniew Nitecki wrote:
>>>The following macros are among those I have to generate index entries:
>>>***********************************************************************************
>>>\newcommand{\namerefindex}[4]{\index{#2, #1 (#3-#4)}}%prints name, date
>>>in index not text
>>>\newcommand{\namerefsilent}[4]{#1\  #2\ (#3-#4)}%prints name, date in
>>>text not index
>>>\newcommand{\nameref}[4]{#1\  #2\
>>>(#3-#4)\namerefindex{#1}{#2}{#3}{#4}}%prints name, date in text
>>[...]
>>>Included in the same macro file are the following:
>>>***********************************************************
>>>\newcommand{\Descartesref}{\nameref{Ren\'e}{Descartes}{1596}{1650}}
>>>\newcommand{\Fermatref}{\nameref{Pierre de}{Fermat}{1601}{1665}}
>>>************************************************************************
>>[...]
>>>When I run the full book text as described above, I get an error
>>>messages referring to the
>>>paragraph quoted above:
>>>********************************************************************************
>>>LaTeX Warning: Reference Pierre de' on page 2 undefined on input line 52.
>>>
>>>! Missing \endcsname inserted.
>>><to be read again>
>>>                   \unhbox
>>>l.52 ...h cenury by \Fermatref{} and \Descartesref
>>
>>Look into your .log file. I'm quite sure that you see that nameref.sty
>>(coming with hyperref.sty) is loaded \AtBeginDocument, which (re)defines
>>to produce a \ref. The error you get says that the corresponding \label
>>is missing.

`