Page LayoutTable of Contents enhanced ? First the chapters listing

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
centguy
Posts: 18
Joined: Tue Jan 06, 2009 5:42 am

Table of Contents enhanced ? First the chapters listing

Post by centguy »

I wonder if it is possible to have a more advanced table of content listing. Right now, what I have is Contents followed by
chapter 1, followed by all sections in chapter 1.
After that Chapter 2, followed by all sections in chapter2 , and
so on.

Since I like to use hyperref to help me to navigate through the book, so I think if I can have a listing of all chapters, WITHOUT the sections, and then when I click on a link to particular chapter, I will get to the place where all sections under that chapter are listed. This way, I could very quickly get to a section very quickly without skipping all irrelevant chapters and those accompanied sections.

This is a very nice feature, can we enable it ?

Thanks !

Recommended reading 2024:

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

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

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Table of Contents enhanced ? First the chapters listing

Post by localghost »

Take a look at the titletoc manual (Section 7.3 - Partial ToCs). Pay special attention to the examples in the appendix. For the main ToC set the tocdepth counter to Zero in order to show only chapters.


Best regards
Thorsten
centguy
Posts: 18
Joined: Tue Jan 06, 2009 5:42 am

Table of Contents enhanced ? First the chapters listing

Post by centguy »

found it extremely hard to understand the manual.
\usepackage{titlesec}
\usepackage{titletoc}
\include{common-places}
\include{abbrev}
\begin{document}

\startcontents[chapters]
\printcontents[chapters]
\stopcontents[chapters]
%\startcontents[parts]
%\printcontents[parts]
%\stopcontents[parts]
\tableofcontents
I got some gibberish CChapter1,Chapter2,Chapter3,...

in one try, but then later on I got error messages.
! Missing \endcsname inserted.
<to be read again>
\let
l.2 \contentsline {chapter}
{\numberline {1}Some very basic graphics topics}{
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Table of Contents enhanced ? First the chapters listing

Post by localghost »

Please always post full examples instead of useless code snippets. See the code below for a first basic approach.

Code: Select all

\documentclass[11pt,a4paper,english]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[raggedright]{titlesec}
\usepackage{titletoc}
\usepackage[math]{blindtext}
\usepackage[linktocpage]{hyperref}

\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
[\vspace*{2pc} \normalfont\normalsize \startcontents \printcontents{l}{1}{}]

\begin{document}
  \addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
  \addtocontents{ptc}{\protect\setcounter{tocdepth}{2}}
  \tableofcontents

  \chapter{First Chapter}\label{chp:one}
    \blindtext

    \section{First Section}\label{sec:oneone}
      \blindtext

    \section{Second Section}\label{sec:onetwo}
      \blindtext

  \chapter{Second Chapter}\label{chp:two}
    \blindtext

    \section{First Section}\label{sec:twoone}
      \blindtext

    \section{Second Section}\label{sec:twotwo}
      \blindtext

  \chapter{Third Chapter}\label{chp:three}
    \blindtext

    \section{First Section}\label{sec:threeone}
      \blindtext

    \section{Second Section}\label{sec:threetwo}
      \blindtext
\end{document}
centguy
Posts: 18
Joined: Tue Jan 06, 2009 5:42 am

Re: Table of Contents enhanced ? First the chapters listing

Post by centguy »

Serious I am so happy that one of the questions that always pops into my head is answered by your example file above. I really appreciate your help ! Million thanks! I save some time in nagivating between pages of my research notes because of you!
centguy
Posts: 18
Joined: Tue Jan 06, 2009 5:42 am

Re: Table of Contents enhanced ? First the chapters listing

Post by centguy »

Is it possible to enable the words in the table of content to be
underlined so that when I click on it, it will go to correct page?
Right now, I have to click on the page numbers at the right end of each entry to go a particular page.
I am hoping that I can click on any words within a line to nagivate, i.e., I have more "areas" to choose. Thanks.

The same issue happens in the main TOC and the toc for each individual chapter.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Table of Contents enhanced ? First the chapters listing

Post by gmedina »

Hi,

remove the option linktocpage from the list of options for the hyperref package; i.e., instead of

Code: Select all

\usepackage[linktocpage]{hyperref}
use something like

Code: Select all

\usepackage{hyperref}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Table of Contents enhanced ? First the chapters listing

Post by localghost »

For good measure you should enable line breaks for list entries (ToC, LoF, LoT) that occupy more than one line.

Code: Select all

\usepackage[breaklinks=true]{hyperref}

Best regards
Thorsten
centguy
Posts: 18
Joined: Tue Jan 06, 2009 5:42 am

Re: Table of Contents enhanced ? First the chapters listing

Post by centguy »

What a lucky day for me. It works. Thanks Thorsten and gmedina!!
Post Reply