## LaTeX forum ⇒ General ⇒ hyperref - 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

Hi

I need a solution to the following:
-------------------------------------
\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?

Minimal example code:

\documentclass[a4paper]{report}\usepackage[colorlinks=true,pdfborder={0 0 0},pdfpagelabels]{hyperref}\begin{document}%------------------------------\pagestyle{plain} \tableofcontents\cleardoublepage %------------------------------\chapter{one}test\newpagetest2%------------------------------% I want to add an entry to the table of contents % But I want a different entry name in the PDF - bookmarks!\phantomsection\addcontentsline{toc}{subsection}{Really long name that looks good in table of contents but is annoying in the bookmark section!}%------------------------------\end{document}

Tags:

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am
You could use hyperref's \texorpdfstring command. (See the hyperref documentation.)

\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
@ 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!

localghost
Site Moderator
Posts: 9204
Joined: Fri Feb 02, 2007 12:06 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

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