3

I would like to have a short toc with no page numbers at the beginning of my document, but a long toc with page numbers at the end.

My example :

\documentclass[french,a4paper,12pt,twoside]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[tight]{shorttoc} 
\addtocontents{toc}{\protect\thispagestyle{empty}}
\usepackage{color}
\usepackage[bookmarks,colorlinks=true]{hyperref}

\begin{document}
\chapter{Thanks !}
\shorttableofcontents{Sommaire.}{0}
\part{Concepts.}
\chapter{Characters}
\section{Cars.}
\subsection{Quick}
\section{Trucks.}
\subsection{Slow}
\part{Virtuality.}
\chapter{Food}
\section{Bananas.}
\subsection{Quickly}
\section{Orange.}
\subsection{Slowly}
\newpage
\tableofcontents
\end{document}

Is there any solution to remove page numbers in the short toc ?

1 Answer 1

3

Locally redefine \contentsline to ignore its third argument (the page number).

\documentclass[french,a4paper,12pt,twoside]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[tight]{shorttoc}
\addtocontents{toc}{\protect\thispagestyle{empty}}

\newcommand{\npshorttableofcontents}[2]{%
  \begingroup
  \let\aslsavedcontentsline\contentsline
  \renewcommand{\contentsline}[3]{%
    \aslsavedcontentsline{##1}{##2}{}%
  }%
  \shorttableofcontents{#1}{#2}
  \endgroup
}

\usepackage{color}
\usepackage[bookmarks,colorlinks=true]{hyperref}

\begin{document}
\chapter{Thanks !}
\npshorttableofcontents{Sommaire.}{0}
\part{Concepts.}
\chapter{Characters}
\section{Cars.}
\subsection{Quick}
\section{Trucks.}
\subsection{Slow}
\part{Virtuality.}
\chapter{Food}
\section{Bananas.}
\subsection{Quickly}
\section{Orange.}
\subsection{Slowly}
\newpage
\tableofcontents
\end{document}
1
  • This is precisely what I was looking for; many thanks!
    – asl
    Commented Oct 25, 2014 at 16:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .