LaTeX forum ⇒ Generalhyperref - how to use \addcontentsline different bookmark

LaTeX specific issues not fitting into one of the other forums of this category.
elzzup2010au
Posts: 2
Joined: Tue Nov 16, 2010 3:56 am

hyperref - how to use \addcontentsline different bookmark

Postby elzzup2010au » Tue Nov 16, 2010 4:12 am

Hi

I need a solution to the following:
-------------------------------------
I want to add an entry to the table of contents using
  1. \addcontentsline{toc}{subsection}{name}

But I do not want the "name" used to be automatically added to the pdf bookmark.
Instead I want to use a different shorter name.
( Using: pdflatex & miktex 2.8 )
-------------------------------------
Is this possible?
If so how?

Thanks in advance :)

Minimal example code:

  1. \documentclass[a4paper]{report}
  2. \usepackage[colorlinks=true,pdfborder={0 0 0},pdfpagelabels]{hyperref}
  3. \begin{document}
  4. %------------------------------
  5. \pagestyle{plain}
  6. \tableofcontents
  7. \cleardoublepage
  8. %------------------------------
  9. \chapter{one}
  10. test
  11. \newpage
  12. test2
  13. %------------------------------
  14. % I want to add an entry to the table of contents
  15. % But I want a different entry name in the PDF - bookmarks!
  16. \phantomsection
  17. \addcontentsline{toc}{subsection}{Really long name that looks good in table of contents but is annoying in the bookmark section!}
  18. %------------------------------
  19. \end{document}

Tags:

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Postby frabjous » Tue Nov 16, 2010 4:27 am

You could use hyperref's \texorpdfstring command. (See the hyperref documentation.)

  1. \addcontentsline{toc}{subsection}{\texorpdfstring{Really long name that looks good in table of contents but is annoying in the bookmark section!}{Short entry for bookmark}}

elzzup2010au
Posts: 2
Joined: Tue Nov 16, 2010 3:56 am

Postby elzzup2010au » Tue Nov 16, 2010 4:40 am

@ frabjous

Wow!
Thank you!
Your solution works 100%

As we say here in Australia.
"You little beauty!"

Cheers Mate - I really really appreciate your effort!

User avatar
localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Wed Nov 17, 2010 6:49 pm

Now that the problem is solved, please be so kind and mark the topic accordingly as clearly written in Section 3 of the Board Rules (to be read before posting). Please keep that in mind for the future so that further reminders will not be necessary.


Best regards and welcome to the board
Thorsten
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1


Return to “General”

Who is online

Users browsing this forum: No registered users and 5 guests