TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Please consider the following multipage MWE, which contains page number restarting; made to compile with pdflatex test.tex:



% \usepackage{titlesec}
% \titleformat{\section}{\centering\normalsize}{\thesection}{1em}{}
% \titleformat{\subsection}{\centering\small}{\thesubsection}{1em}{}

  {\typeout{^^J*******\string\drawpage fixed*******^^J}}%
  {\typeout{^^J*******\string\drawpage not fixed*******^^J}}




  \pagestyle{empty} % no page numbers on next few pages

% pg 1
    \begin{tikzpicture}[overlay,remember picture,yscale=-1, inner sep=0pt, outer sep=0pt,anchor=north west]

      \path (current page.center) node[anchor=center] (textX) {%

        Physical page 1 / Title




% pg 2
  Physical page 2 / Empty


% pg 3
  Physical page 3 / TOC



% pg 4
  %Physical page 4 / Empty
  \ \\


  \pagenumbering{arabic} % restart page numbering from 1
  \pagestyle{plain} % show page numbers

% pg 5
  Physical page 5

  \section*{Section One}
  \addcontentsline{toc}{section}{Section One}

  \subsection*{Subsection One}
  \addcontentsline{toc}{subsection}{Subsection One}



% pg 6
  Physical page 6

  \subsection*{Subsection Two}
  \addcontentsline{toc}{subsection}{Subsection Two}



% pg 7
  Physical page 7

  \section*{Section Two}
  \addcontentsline{toc}{section}{Section Two}



% pg 8
  Physical page 8

  \subsection*{Subsection Two}
  \addcontentsline{toc}{subsection}{Subsection Two}




When this is compiled (twice), there is absolutely no problems in the PDF - table of contents clickable links in PDF work as expected; note that for this correct case, we have test.toc:

\contentsline {section}{Section One}{1}{section*.2}
\contentsline {subsection}{Subsection One}{1}{section*.3}
\contentsline {subsection}{Subsection Two}{2}{section*.4}
\contentsline {section}{Section Two}{3}{section*.5}
\contentsline {subsection}{Subsection Two}{4}{section*.6}

and test.out:

\BOOKMARK [1][-]{section*.2}{Section One}{}% 1
\BOOKMARK [2][-]{section*.3}{Subsection One}{section*.2}% 2
\BOOKMARK [2][-]{section*.4}{Subsection Two}{section*.2}% 3
\BOOKMARK [1][-]{section*.5}{Section Two}{}% 4
\BOOKMARK [2][-]{section*.6}{Subsection Two}{section*.5}% 5


Now, uncomment the three lines around \usepackage{titlesec}, and recompile (deleting *.{out,toc,aux} previously if so desired). Eventually you can see pdflatex spitting:

Package hyperref Warning: The anchor of a bookmark and its parent's must not
(hyperref)                be the same. Added a new anchor on input line 72.

pdfTeX warning (ext4): destination with the same identifier (name{page.1}) has 
been already used, duplicate ignored

Now, basically the first link in the TOC (to "Section One") points to physical page 1 (start of document) - instead of physical page 5 (logical page 1, after restart), where it should be! In this case, test.toc is:

\contentsline {section}{Section One}{1}{Doc-Start}
\contentsline {subsection}{Subsection One}{1}{section*.1}
\contentsline {subsection}{Subsection Two}{2}{section*.1}
\contentsline {section}{Section Two}{3}{section*.1}
\contentsline {subsection}{Subsection Two}{4}{section*.2}

... and test.out is:

\BOOKMARK [1][-]{Doc-Start}{Section One}{}% 1
\BOOKMARK [2][-]{section*.1}{Subsection One}{Doc-Start}% 2
\BOOKMARK [2][-]{section*.1}{Subsection Two}{Doc-Start}% 3
\BOOKMARK [1][-]{section*.1}{Section Two}{}% 4
\BOOKMARK [2][-]{section*.2}{Subsection Two}{section*.1}% 5


My question is - can I somehow use the titlesec package in the above example, and yet still get correct hyperlinks for the table of contents in the PDF?

Many thanks in advance for any answers,

share|improve this question
up vote 5 down vote accepted

EDIT: What worked for me is to avoid titlesec, and do Changing the Section Headings the old way - by wrapping the recommended \renewcommand in \makeatletter/\makeatother in the preamble as so:

{section}%                   % the name
{1}%                         % the level
{\z@}%                       % the indent / 0mm
{-\baselineskip}%            % the before skip / -3.5ex \@plus -1ex \@minus -.2ex
{0.5\baselineskip}%          % the after skip / 2.3ex \@plus .2ex
{\centering\normalsize}} % the style

Ah well, turns out it's a known thing, apparently:


  "nameref" supports titlesec, but hyperref does not
  (unsolved is the anchor setting, missing with unnumbered
  section, perhaps problems with page breaks with numbered ones).

Well, if anyone knows a workaround, would be great to hear it :)


share|improve this answer

Your setup seems to suggest that you're not interested in numbering your sectional units. So, continue to use \section and \subsection but add


to your document preamble. Subsequently, using titlesec provides correct hyperlinks to sectional units from the ToC, despite some compiler warnings.

Here is your preamble:





  {\typeout{^^J*******\string\drawpage fixed*******^^J}}%
  {\typeout{^^J*******\string\drawpage not fixed*******^^J}}


share|improve this answer
Many thanks for that, @Werner - indeed, I do not need numbering here; however, I'm trying to recompile with this preamble, and I still get the same warnings and problems as in the question. I've tried to redefine \section the old way (as described in the edit of my post), and that seems to work OK so far. Many thanks again - cheers! – sdaau May 16 '12 at 6:10

I solved it differently: I used titletoc package to configure the table of contents (in a way that was quite similar to the one that latex defaults to) and I ended up being able to use hyperref and titlesec together.

Here is a snippet of my code:



% Section heading format/spacing    

% Table of contents line format
    {\bfseries\Large\titlerule*{ }\contentspage}
    {\bfseries\titlerule*{ }\contentspage}



\part{Part One}
\chapter{Chapter One}
\section{Section One}
\section{Section Two}

\chapter{Chapter Two}


Sorry if this post is discontinued, but I found an alternate solution which I found to be more confortable and thought I'd leave it here just in case someone else ends up here.

share|improve this answer

Your Answer


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.