Generalhyperref - how to use \addcontentsline different bookmark

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

hyperref - how to use \addcontentsline different bookmark

Post by elzzup2010au »

Hi

I need a solution to the following:
-------------------------------------
I want to add an entry to the table of contents using

Code: Select all

\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:

Code: Select all

\documentclass[a4paper]{report}
\usepackage[colorlinks=true,pdfborder={0 0 0},pdfpagelabels]{hyperref}
\begin{document}
%------------------------------
\pagestyle{plain} 
\tableofcontents
\cleardoublepage 
%------------------------------
\chapter{one}
test
\newpage
test2
%------------------------------
% 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}

Recommended reading 2024:

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

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

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

hyperref - how to use \addcontentsline different bookmark

Post by frabjous »

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

Code: Select all

\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

Re: hyperref - how to use \addcontentsline different bookmar

Post by elzzup2010au »

@ 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: 9202
Joined: Fri Feb 02, 2007 12:06 pm

hyperref - how to use \addcontentsline different bookmark

Post by localghost »

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
Post Reply