Page LayoutWrong PDF bookmark hierarchy for unnumbered chapters

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
sebp
Posts: 2
Joined: Thu Feb 18, 2010 12:57 pm

Wrong PDF bookmark hierarchy for unnumbered chapters

Post by sebp »

Hi,

I am writing a thesis, and I am facing the following problem with the bookmarks in the PDF file: I want the last (unnumbered) chapters "Acknowledgment" and "Bibliography" to be at the root of the bookmark hierarchy (exactly as "Introduction"), but I got them as a sublevel of the last part. My code reads (in short):

Code: Select all

\documentclass{book}
\usepackage{fancyhdr}
\usepackage{hyperref}

\begin{document}

\chapter*{Introduction}
\addcontentsline{toc}{chap}{Introduction}

\part{Part I}
\chapter{Chapter 1}

\chapter*{Acknowledgment}
\addcontentsline{toc}{chap}{Acknowledgment}
\bibliography{biblio}
\addcontentsline{toc}{chap}{Bibliography}

\end{document}
and the bookmarks in the PDF file are:
  • Introduction
    Part I
    • Chapter 1
      Acknowledgment
      Bibliography
but I would like to get:
  • Introduction
    Part I
    • Chapter 1
    Acknowledgment
    Bibliography
I tried many different commands (\phantomsection, \backmatter, \setcounter, ...), but without success... One command nearly does the job

Code: Select all

\addcontentsline{toc}{part}{Acknowledgment}
but then the font of "Acknowledgment" is much too large in the table of contents.

Can somebody help me? Thanks,

Sébastien

Recommended reading 2024:

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

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

mimoviz
Posts: 3
Joined: Sun Feb 21, 2010 2:46 pm

Wrong PDF bookmark hierarchy for unnumbered chapters

Post by mimoviz »

I would like to get:
Introduction
Part I
Chapter 1
Acknowledgment
Bibliography
\hello sebp: Where is Part 2 and 3? You see, the topmost document level division is always the part. You cannot put anything at that level and expect anything other than an incredibly big font in the TOC. What I suggest you, IMHO, is that you can easily reorganize your document structure by using sublevels such as chapters and sections. For those, it is tremendously easy to change font and appearance(using titlesec) not just in the document itself but also in the TOC, so you can have a normalized appearance there and in the toc, which, of course, will be reflected in your final pdf.
but then the font of "Acknowledgment" is much too large in the table of contents.
Man, this effect is unavoidable lest you want to meddle with some deep latex/tex and redefine the Part command... but why all the trouble when you can redefine \chapter to work just as you want? ;-)

\bye
sebp
Posts: 2
Joined: Thu Feb 18, 2010 12:57 pm

Wrong PDF bookmark hierarchy for unnumbered chapters

Post by sebp »

Where is Part 2 and 3? You see, the topmost document level division is always the part. You cannot put anything at that level and expect anything other than an incredibly big font in the TOC. What I suggest you, IMHO, is that you can easily reorganize your document structure by using sublevels such as chapters and sections.
Well, my starting point is that the Introduction appears at the top level of the hierarchy, even if it is not a part but rather a chapter, and I really want to have some parts in my thesis, not only chapters and sections. I was hopping that the command \backmatter would reset all counters, such that the chapters Acknowledgment and Bibliography also appear at the root level.

However, in the mean time I have found a possible solution, but I do not like it very much because I have to reorganize the hierarchy manually. What I do is the following:

1) I compile everything (as many times as necessary);

2) I open the file *.out, which contains the data for the bookmarks, and I change the two last lines
\BOOKMARK [0][-]{section*.3}{Bibliography}{part.1}
\BOOKMARK [0][-]{section*.4}{Acknowledgment}{part.1}
by
\BOOKMARK [0][-]{section*.3}{Bibliography}{}
\BOOKMARK [0][-]{section*.4}{Acknowledgment}{}

3) Then, I add the command

Code: Select all

\let\WriteBookmarks\relax
at the beginning of my code, and I compile the file one more time. The PDF bookmarks finally appear exactly the way I want...

My problem is therefore solved, but I would be really happy if someone can give me a code to make all these steps automatic!
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Wrong PDF bookmark hierarchy for unnumbered chapters

Post by meho_r »

After reading all this I'm not sure what your problem actually is: level for those chapters that should be "part" in TOC or how big the font is in TOC? If the font is issue, try customizing it with titletoc (which is part of titlesec package) or tocloft. And command:

Code: Select all

\addcontentsline{toc}{part}{Acknowledgment}
does work.

However, your request is really strange, since Acknowledgement and Bibliography definitely shouldn't be part-level. BTW, \backmatter does take care of counters (i.e. removes them from all sectioning units inside it).

If I were you, I'd try with something like this:

Code: Select all

\documentclass{book}
\usepackage{fancyhdr}
\usepackage{hyperref}

\usepackage{titletoc}

\titlecontents{chapter}
              [1.3em]
              {\large}
              {\contentslabel{1.3em}}
              {\hspace*{-1.3em}}
              {\titlerule*[1pc]{.}\contentspage}

\titlecontents{part}
              [1.9em]
              {\bfseries\Large\vspace{1em}}
              {\contentslabel{1.3em}}
              {\hspace*{-1.3em}}
              {\titlerule*[1pc]{.}\contentspage}

\begin{document}
\tableofcontents

\frontmatter
\chapter{Introduction}
%\addcontentsline{toc}{part}{Introduction}

\mainmatter
\part{Part I}
\chapter{Chapter 1}

\backmatter
\chapter{Acknowledgment}
%\addcontentsline{toc}{part}{Acknowledgment}

\bibliography{biblio}
%\addcontentsline{toc}{part}{Bibliography}

\end{document}
Post Reply