LyXhyperref messes up bookmarks in PDF file

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
MarcAurel
Posts: 20
Joined: Tue Jul 07, 2009 1:33 pm

hyperref messes up bookmarks in PDF file

Post by MarcAurel »

I'm using Lys 2.0.5.

I don't know why, but LyX does set wrong bookmarks in the PDF file. Let's say the structure of the LyX file is as follows:

- part 0
- part 1
-- chapter 1.1
-- chapter 1.2
- part 2
- part 3
-- chapter 3.1
-- chapter 3.2

However, if I want to navigate the resulting PDF document via the automatically generated bookmarks, then clicking on part 1 sends me to part 0, and the part 2 bookmark leads to chapter 1.2.

I did some research. In LaTeX, people recommend loading hyperref at the very end of the header because otherwise its settings could be overwritten by other modules. In LyX, however, this isn't an option. I tried shuffling around the order in which modules are called in the source file, but this had no effect.

Does anyone of you have any idea of how to fix it --- apart from telling me to switch to LaTeX? ;)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

Re: hyperref messes up bookmarks in PDF file

Post by Stefan Kottwitz »

Perhaps post such a (minimal) LyX example here as attachment which shows the undesired behavior. When would see it, I'm sure we could fix it.

Stefan
LaTeX.org admin
MarcAurel
Posts: 20
Joined: Tue Jul 07, 2009 1:33 pm

Re: hyperref messes up bookmarks in PDF file

Post by MarcAurel »

Thanks for the quick reply!

I've attached a bare-bones LyX example. Just generate a PDF, and click on "Part 1". It will take you to "Introduction".
Attachments
Error.lyx
(3.47 KiB) Downloaded 496 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

hyperref messes up bookmarks in PDF file

Post by Stefan Kottwitz »

Now I can see the reason: you switched off the automatic numbering and wrote Ch. 1, Ch. 2, Part I, Part II, etc. manually. That's very uncommon, because LyX and LaTeX does numbering and referencing for you. If you would keep making it manually, you would have to check and to adjust all numbers manually in case you would insert or remove a section.

I strongly recommend to activate the numbering. The current setting in your document is:
lyx-numbering.png
lyx-numbering.png (31.12 KiB) Viewed 7588 times
Drag the slider to the right.

Numbering is required for hyperlinking, since an anchor is needed. You can manually add an anchor though, by breaking the page and inserting \phantomsection as a TeX command:
lyx-part-bookmark.png
lyx-part-bookmark.png (6.53 KiB) Viewed 7588 times
Stefan
LaTeX.org admin
MarcAurel
Posts: 20
Joined: Tue Jul 07, 2009 1:33 pm

Re: hyperref messes up bookmarks in PDF file

Post by MarcAurel »

Thank you very much for your help! I've now experimented with the setting you recommended. True, if I activate numbering, then the anchoring works. However, I then have numbers in the text, which I want to avoid. With the setting you suggested, it would read, "Chapter X, [chapter title]", whereas I'd prefer to only list the chapter title.

This means that there are two bad choices: numbers in the text, or misleading bookmarks. It seems there is no way to fix this, but as a workaround, I figured out that it is possible to edit the generated PDF file and simply change the link. It's not an elegant solution, though.
Post Reply