[OS X TeX] hyperref and endnotes/bibliography

Bruno Voisin bvoisin at mac.com
Fri Apr 28 07:07:20 EDT 2006


Le 28 avr. 06 à 11:51, Wolfgang Schmidle a écrit :

> I have made a minimal example now. With "\addcontentsline" at  
> position A, the toc entry is correct, but hyperref refers to the  
> wrong page. At position B, hyperref works correctly, but the page  
> in the toc entry is wrong.

Sorry, I had missed your original post. I think the solution to your  
problem is using the (undocumented) \phantomsection command from the  
hyperref package (at the very end of hyperref.sty). It does not  
insert any text, but an anchor at the current point in the PDF  
output. Thus you should write, possibly:

\phantomsection
\addcontentsline{toc}{chapter}{\numberline{}Bibliography} % position A

For example, the following code in pdfmark.def (for dvips) or  
hpdftex.def (for pdfTeX) tells the hyperref packages redefines the  
command \@ssect (invoked by \section*, \subsection* etc.) by simply  
adding a \phantomsection immediately after the section title:

\let\H at old@ssect\@ssect
\def\@ssect#1#2#3#4#5{%
   \H at old@ssect{#1}{#2}{#3}{#4}{#5}%
   \phantomsection
}

The effect that an anchor is created there, allowing the table of  
contents to navigate to that section, in particular.

Below is a quotation from a message I had written to the XeTeX  
mailing list last November, together with Ross Moore's comment.

Hope this helps,

Bruno Voisin


> De : Ross Moore
> Date : 26 novembre 2005 02:46:03 HNEC
> À : Bruno Voisin
> Cc : Unicode-based TeX for Mac OS X
> Objet : Rép : xunicode expansion problem (was Re: [XeTeX]  
> Hyphenation of "--" with tex-text mapping on)
>
> On 25/11/2005, at 2:35 AM, Bruno Voisin wrote:
>
>> [...]
>>
>> Then the subsidairy question is: why do I always have to  
>> confronted with bugs or features, as soon as I'm starting to use  
>> software seriously ;-(
>>
>> For example earlier today I had problems getting correct bookmarks  
>> in a hyperref document where I had defined subsubsections to be  
>> unnumbered but to appear in the toc and bookmarks using:
>>
>> \setcounter{secnumdepth}{2}
>> \setcounter{tocdepth}{3}
>>
>> This turned out to be linked with cryptic error messages such as:
>>
>> Package hyperref Warning: The anchor of a bookmark and its  
>> parent's must not
>> (hyperref)                be the same. Added a new anchor on input  
>> line 748.
>
> I always have trouble with bookmarks, in documents which
> have a structure that differs from the simple LaTeX classes.
> It's invariably connected with getting certain counters to
> have the right value at a critical place within the processing.
>
> Examine the .out file to determine *what* you want.
> Then do a bit of strategic \tracingall  to locate *where* the
> incorrect value comes from. Then devise a way to fix it.
>
>> Eventually, after many unsuccessful attempts, I ended up searching  
>> comp.text.tex in Google groups to find a post from December 2000  
>> <http://groups.google.com/group/comp.text.tex/browse_thread/thread/ 
>> 5f5632c9cdd5f2a2/9689fc0b4365dc53?q=Package+hyperref+Warning%3A+The 
>> +anchor+of+a+bookmark+and+its 
>> +parent's&rnum=1&auth=DQAAAGQAAABbYvlv0bjyVsORMqk5DWQJPUIgz6rUiAmaexf 
>> ov1qCaq9n7yLl9gZeBVehQSfpYehFUFk-aOmzdEWN_-mDS6- 
>> wfaKXa60w1HS0XHL6N4IgKpAKs7V9LRYHRcgBzAk_Wqr7HhMw1x3GqWcim_Jgs9Yh>, m 
>> entioning the hyperref command \phantomsection which fixed the  
>> problem but seems to be mentioned nowhere except inside the source  
>> code hyperref.sty itself.
>
> I remember conversing with Heiko at about this time.
> He created some other commands:
>
> \newcommand{\currentpdfbookmark}{%
> \newcommand{\subpdfbookmark}{%
> \newcommand{\belowpdfbookmark}[2]{%
>
>  ... none of which are documented either.

------------------------- 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 MacOSX-TeX mailing list