Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a way I can make hyperref exclude section/chapter/etc numbering from the link in toc/lof/lot?

I want it becase I highlight the link, and number is not really a part of the section/chapter/etc name.

I searched the manual -- but could not find an option. Perhaps the only way is to redefine some hyperref external command.

Edit:

\documentclass{book}

\usepackage{fontspec} % enagles loading of OpenType fonts
\usepackage{polyglossia} % support for languages

% fonts:
\defaultfontfeatures{Scale=MatchLowercase,Mapping=tex-text} % without this XeLaTeX won't turn "--" into dashes
\setmainfont{Arial}
\setsansfont{Arial}
\setmonofont{DejaVu Sans Mono}

\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[allcolors=blue,colorlinks]{hyperref}

\begin{document}

\tableofcontents
\chapter{foo}

Foo!

\chapter{bar}

Bar!

\chapter{baz}

Baz!

\end{document}

(supposed to be compiled with XeLaTeX).

share|improve this question
    
There is probably a cleaner solution, but I think it is possible to do this using the package titletoc and the \titlecontents command. It would be easier to answer if you could provide a minimal working example (MWE). –  Corentin Feb 21 '13 at 15:26

1 Answer 1

up vote 2 down vote accepted

A somewhat convoluted method, only for the table of contents:

\documentclass{book}
\usepackage{hyperref}
\usepackage{etoc}
\makeatletter
% store the original table of contents macros
% (they are not modified by hyperref, only \contentsline is)
  \let\latchapter\l@chapter
  \let\latsection\l@section
  \let\latsubsection\l@subsection
%
% then use the etoc package to feed the l@ macros with a filtered out data

\etocsetstyle{chapter}{}{}
{\latchapter{\numberline{\etocthenumber}\etocname}{\etocpage}}{}

\etocsetstyle{section}{}{}
{\latsection{\numberline{\etocthenumber}\etocname}{\etocpage}}{}

\etocsetstyle{subsection}{}{}
{\latsubsection{\numberline{\etocthenumber}\etocname}{\etocpage}}{}
\makeatother
% ready to go!

\begin{document}
\tableofcontents

\chapter{One}
hello
\section{This is a section}
hello
\subsection{a subsection}
hello
\subsection{another subsection}
hello
\section{Another section}
a
\chapter{Two}
b
\section{And one more section}
c
\subsection{an a subsection}
d
\end{document}
share|improve this answer
    
It works! I don't have etoc in repository, so here's a ctan link. –  Adobe Feb 21 '13 at 20:36
1  
Despite there could be some simpler solutions with e.g. titlesec -- it's nice to have this one also -- since sometimes titlesec is not an option -- for example when it conflicts with some other packages. –  Adobe Feb 21 '13 at 20:39
    
I am not sure about titlesec/titletoc. A brief look at titletoc has not given me any reason to believe it can separate the number from the name. Both are inside what it calls the label. –  user700902 Feb 22 '13 at 21:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.