GeneralHyperref Warnings during compilation

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Hyperref Warnings during compilation

Post by Cham »

While compiling a very large LaTeX document, I'm getting lots of warnings from hyperref, and I don't understand what is happening. Yet, the document compiles fine, and the PDF output appears to be okay (all hyperref links are fully functional).

Here's an example of the warning messages which puzzles me :
Package hyperref Warning: Difference (2) between bookmark levels is greater
(hyperref) than one, level fixed on input line 2048
I isolated some parts of the code which triggers the messages, and I created a MWE to show the "problem" in action (I'm not even sure this is actually a problem).

Typically, it appears to be related to subsubsections and the ToC, that I customized :

Code: Select all

\documentclass[12pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{upgreek}
\usepackage{stmaryrd}
\usepackage[nottoc,notlof]{tocbibind}
\usepackage{tocloft}
	\makeatletter
	\renewcommand{\@pnumwidth}{2.3em}
	\makeatother
	\setcounter{tocdepth}{3}
	\renewcommand{\cftchappresnum}{\chaptername\ }
	\renewcommand{\cftchapaftersnumb}{\newline}	
	\renewcommand{\cftsecpresnum}{\hfill}
	\renewcommand{\cftsecaftersnum}{\hspace*{8pt}}
	\addtolength{\cftsecnumwidth}{8pt}
	\renewcommand{\cftsubsecpresnum}{\hfill}  %
	\renewcommand{\cftsubsecaftersnum}{\hspace*{8pt}}
	\addtolength{\cftsubsecnumwidth}{8pt}

	\setlength{\cftchapnumwidth}{0pt}
	\setlength{\cftsecindent}{12pt}
	\setlength{\cftsubsecindent}{54pt}
	\setlength{\cftsubsubsecindent}{114pt}
	\renewcommand{\cftsubsubsecfont}{\normalfont\sffamily\footnotesize}
	\renewcommand{\cftdotsep}{2}
\usepackage[unicode,colorlinks]{hyperref}

\begin{document}

\tableofcontents

\chapter{Test}
\section{section title}
\subsubsection{a sub-sub-section}

Font substitution here : $\boldsymbol{\upomega}$
\end{document}
So what is the problem here ? Why the warnings ? Should I worry about them ?

EDIT : Hmm, I just discovered that the warnings are triggered when there's a subsubsection inside a section without any subsection.

However, I need those subsubsections, independently of the subsection, and I want them to be shown in the ToC. The subsubsection aren't numeroted.

Probably there's a better way of creating a subsubsection-like part inside a text ?

Since LaTeX fixes the level (the ToC is all fine in the PDF output), should I care about those warning messages ?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Re: Hyperref Warnings during compilation

Post by Stefan Kottwitz »

Yes, I guessed skipping a section level caused it. If it works for you, you can leave it this way.

Nevertheless, it's not good to leave out a section level. Numbering would show subsubsections like 2.0.1 and 2.0.2 with a 0 for the subsection number. Hiding this issue by suppressing numbering is not really solving it.

Perhaps you don't need a logical subsubsection but like to have a small heading which you could typeset yourself. Or you would like to change the subsection appearance to be smaller. Anyway, it's not consistent. I would do it if I would find a good book which does skip levels occasionally. Try to find one, I guess editors would take care that the structure of a book is logically consistent.

Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Hyperref Warnings during compilation

Post by Cham »

Stefan,

my subsubsections don't have a number on purpose ; they don't need one.

I usually don't use subsubsections at all, except to show some examples, some comments, some special cases, etc, that aren't large enough to fill a subsection.

I would normaly skip all the subsections in the ToC (just chapters, sections and subsections), but I added them to the ToC to facilitate navigation in such a large book (now at 1600 pages, and still rising !).

Instead of using subsubsections, what would you do if you had to give a title to some examples, small demonstrations, comments on special cases, etc, and show them in the ToC ?
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Hyperref Warnings during compilation

Post by Cham »

I spoted another hyperref warning that I don't understand :
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 16.
Here are the code lines 16 and 17 :

Code: Select all

\addcontentsline{toc}{subsection}{\small{\textsf{Remerciements}}}
\subsubsection*{\textsf{Remerciements}}
What is wrong here ?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Hyperref Warnings during compilation

Post by Stefan Kottwitz »

It seems that hyperref warns but fixes the error for you. The reason is, that you implicitly add a bookmark by \addcontentsline, but it would refer to the previously defined anchor, such as the previous section start. \phantomsection generates a new anchor, so you could call it directly before \subsubsection*.

Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Hyperref Warnings during compilation

Post by Cham »

Stefan_K wrote:It seems that hyperref warns but fixes the error for you. The reason is, that you implicitly add a bookmark by \addcontentsline, but it would refer to the previously defined anchor, such as the previous section start. \phantomsection generates a new anchor, so you could call it directly before \subsubsection*.
Now that is really mysterious to me ! :oops:

I try your suggestion right away...
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Hyperref Warnings during compilation

Post by Cham »

Nope ! Using this code generates the same warning message at the same line 16 :

Code: Select all

\addcontentsline{toc}{subsection}{\small{\textsf{Remerciements}}}
\phantomsection
\subsubsection*{\textsf{Remerciements}}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Hyperref Warnings during compilation

Post by Stefan Kottwitz »

Actually it should go directly before \addcontentsline, since that's the place with the issue.

Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: Hyperref Warnings during compilation

Post by Cham »

Ah ! Sorry. Yep it's working now. Warning message squashed ! :)
Post Reply