I want to customize the links (appearance) in the TOC. In the entire document I use 'hidelinks' in hyperref (to turn of the box), and then have some fancy own link visualization (here for MWE replaced by dotuline).

So I changed the TOC Format to include hyperlinks. I turned on the "link boxes" for debugging and the result does not look good. For the number the click area is too short, and for label it goes wrong competely.

enter image description here MWE:


    Link Customization: \hyperlink{chapter.1}{\dotuline{Jump to chapter 1}} 

Original TOC:

enter image description here



1 Answer 1


This is an attempt to mimick the titletoc specified looks. However there is a bit of guess work for what titletoc uses for the right margin.

Package titlesec is loaded for using \titlerule command.

Links with \dotuline decoration from ulem are put in the Toc via etoc package.


% Code from OP with titletoc
% \usepackage{titletoc}
% \titlecontents
%   {chapter}% section name
%   [1pc]% left margin
%   {\addvspace{2ex}\Large\filright}% above code
%   {\hyperlink{chapter.\thecontentslabel}%
%              {\dotuline{\thecontentslabel}}{1pc}}% numbered entry format
%   {\hspace*{-1pc}}% number-less entry format
%   {\titlerule*[1pc]{.}%
%    \hyperlink{chapter.\thecontentslabel}%
%              {\dotuline{\contentspage}}}% filler page format

\usepackage{titlesec}% to use \titlerule command

\makeatletter % to use \@tocrmarg and \@pnumwidth from the LaTeX book class
        {\Large\leftskip 1pc \rightskip \@tocrmarg \parfillskip -\rightskip }
         \etoclink{\dotuline{\etocthename }} % <- I leave intentional \space

% Link Customization: \hyperlink{chapter.2}{\dotuline{Jump to chapter 2}} 




enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .