Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ToC bug : conflict between hyperref & titletoc ?

344 views
Skip to first unread message

Benjamin Renaud

unread,
May 11, 2010, 10:21:57 AM5/11/10
to
dear all,

I want to use ‘hyperref’ together with the ‘titlesec/titletoc’
package. When I want, e.g., chapter titles to be uppercased (or
lowercased) in the ToC, hyperref causes a crash if I use
\MakeUppercase (the same with \MakeTextUppercase from the ‘textcase’
package). I think this first bug is known (and, I suppose, has in fact
little to do with ‘titletoc’), I found a related post from september
2006 in the archives, but the answer provided back then by Heiko
Oberdiek didn't seem to be working for me.

Anyway, this is fixed if I use TeX's \lowercase (resp. \uppercase)
instead of LaTeX's \MakeLowercase, and this is ok for my needs
(there's nothing but text in my titles...). Everything is now fine,
the title of the chapter has a correct link in the ToC... except if
the chapter is an appendix! In that case, when formatted by ‘titletoc’
*and* lowercased, the title of the appendix has a link that points to
nowhere (with XeTeX), or to page 1 (with pdfTeX). The behavior is
different with \uppercase instead of \lowercase, it's even messier...
So I've made one minimal example for each case (they're basically the
same), see below. However, the links in the text seem to be working
fine, and the .toc file looks okay (at least to me), so I guess the
bug is indeed in relation to both ‘hyperref’ and ‘titletoc’ (but I
didn't check what happens with ToC formatting packages other than
‘titletoc’).

If anyone can help, that would be great !

benjamin renaud


%%% FIRST EXAMPLE (LOWERCASE) %%%%

\documentclass[12pt,oneside]{book}
%\usepackage{fontspec,xltxtra,xunicode}
\usepackage[newparttoc]{titlesec} % option "newparttoc" needed to
allow \part formatting
\usepackage{titletoc}
\usepackage{color}
%\usepackage[xetex,colorlinks]{hyperref}
\usepackage[pdftex,colorlinks]{hyperref}

% [titlesec :] very basic formatting of "\part" (it influences the
ToC, with "newparttoc" option)
\titleformat{\part}[display]{\centering\large}{\partname~\thepart}{1em}
{\normalfont\Huge}

% [titletoc :] very basic formating of "part" in the Toc
\titlecontents{part}[0pt]{\large}{}{}{\hspace*{1em}\thecontentspage}

% [titletoc :] below is the problematic formatting of "chapter" in the
ToC
% — the problem disapears if the title is not lowercased (see 2 first
commented lines) ;
% — there's even a crash with \MakeLowercase instead of \lowercase
(see 2 last commented lines).
\titlecontents{chapter}
[0pt]
{}
{\MakeLowercase{\chaptername\ \thecontentslabel}
\hspace{1em}\lowercase}
% {\MakeLowercase{\chaptername\ \thecontentslabel}
% \hspace{1em}}
% {\MakeLowercase{\chaptername\ \thecontentslabel}
% \hspace{1em}\MakeLowercase}
{\lowercase}
{\hspace*{1em}\thecontentspage}

\begin{document}
\part{this is part One}
\chapter{Title of chapter One}
This is chapter One, with some text, and a reference to appendix~
\ref{app:one}, which has a correct link.
\appendix
\part*{Appendices}
\chapter{Title of first appendix}\label{app:one}
\chapter*{Title of an unnumbered appendix}
\addcontentsline{toc}{chapter}{Title of an unnumbered appendix}
\tableofcontents
\addcontentsline{toc}{chapter}{Table of Contents}
\end{document}

%%% SECOND EXAMPLE (WITH UPPERCASE) %%%

\documentclass[12pt,oneside]{book}
%\usepackage{fontspec,xltxtra,xunicode}
\usepackage[newparttoc]{titlesec}
\usepackage{titletoc}
\usepackage{color}
%\usepackage[xetex,colorlinks]{hyperref}
\usepackage[pdftex,colorlinks]{hyperref}

% [titlesec :] very basic formatting of "\part" (it influences the
ToC, with "newparttoc" option)
\titleformat{\part}[display]{\centering\large}{\partname~\thepart}{1em}
{\normalfont\Huge}

% [titletoc :] basically, the same thing as the example with
\lowercase, with even more problems...
\titlecontents{chapter}
[0pt]
{}
{\chaptername\ \thecontentslabel
\hspace{1em}\uppercase}
% \hspace{1em}}
% \hspace{1em}\MakeUppercase}
{\uppercase}
% {}
{\hspace*{20pt}\thecontentspage}

\begin{document}
\part{this is part One}
\chapter{Title of chapter One}
This is chapter One, with some text, and a reference to appendix~
\ref{app:one}, which has a correct link.
\appendix
\part*{Appendices}
\chapter{Title of first appendix}\label{app:one}
\chapter*{Title of an unnumbered appendix}
\addcontentsline{toc}{chapter}{Title of an unnumbered appendix}
\tableofcontents
\addcontentsline{toc}{chapter}{Table of Contents}
\end{document}

0 new messages