# How to specify bookmark and TOC title separately

I customize a dash symbol

\newcommand{\shortdash}{\rule[.7ex]{0.5em}{0.5pt}}


to minimize the space around when typesetting in non-english situation. When I used it in \section, it works in text and TOC(table of content), but it leaves the arguments [.7ex]{0.5em}{0.5pt} in bookmark.

I try to specify an alternative title like \section[alternative]{real title}, but the TOC also changes.

What I want is to specify a title for text and TOC, but another title for bookmark alone. How to realize that? Or how to reduce the failure title-handling of hyperref?

• lease help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
– user31729
Dec 27 '14 at 6:35
• @ChristianHupfer sorry, I'll do that next time. Dec 27 '14 at 6:48

The command \texorpdfstring will decide which feature is to be used either in normal 'text' (like in the TOC) and a text with pdf features such as the bookmarks.

The command \rule is fragile, so it should be used in conjunction with a \protect

\documentclass{article}

\usepackage{hyperref}

\newcommand{\shortdash}{\texorpdfstring{\protect\rule[.7ex]{0.5em}{0.5pt}}{--}}

\begin{document}

\tableofcontents

\section{First\shortdash of two}
\section{Second}

\end{document}

• Owesome! I just get the idea of \texorpdfstring, but have not yet considered this definition. Dec 27 '14 at 6:40