21

See the min expl below. I would like to have two ToC: one giving only the rough structure of the document and a second one giving all the details down to subsubsections. The code pasted below should do just that but the second ToC is not displayed which I do not understand.

\documentclass{report}

\begin{document}

\setcounter{tocdepth}{1}          
\setcounter{secnumdepth}{3}       

\tableofcontents

\renewcommand*\contentsname{Contents (detailed)}

\setcounter{tocdepth}{3}          

\tableofcontents

\chapter{XXX}
\section{YYY}
\subsection{WER}
\subsubsection{ABC}
\subsubsection{DEF}
\subsection{ZTR}
\subsubsection{OIU}
\subsubsection{OIZ}
\subsubsection{POI}
\section{YYY}
\subsection{WER}
\subsubsection{EDC}
\subsubsection{RFV}
\subsection{TGB}
\subsubsection{ZHN}
\subsubsection{OUH}
\subsubsection{WEK}
\chapter{ZZZ}
\chapter{AAA}

\end{document} 

Just noticed there is still a problem with hyperref:

\documentclass[10pt, a4paper]{report}
\usepackage{shorttoc}
\usepackage{hyperref}
\begin{document}

\setcounter{secnumdepth}{3}      

\pdfbookmark[1]{Contents}{toc}    
\shorttoc{Contents}{1} 

\pdfbookmark[1]{Contents (detailed)}{toc}    
\shorttoc{Contents (detailed)}{3}

\tableofcontents

\chapter{XXX}
\section{YYY}
\subsection{WER}
\subsubsection{ABC}
\subsubsection{DEF}
\subsection{ZTR}
\subsubsection{OIU}
\subsubsection{OIZ}
\subsubsection{POI}
\section{YYY}
\subsection{WER}
\subsubsection{EDC}
\subsubsection{RFV}
\subsection{TGB}
\subsubsection{ZHN}
\subsubsection{OUH}
\subsubsection{WEK}
\chapter{ZZZ}
\chapter{AAA}

\end{document} 

By what does {toc} has to be replaced in the second \pdfbookmark? [Sorry, had problem with editing the above comment --> administrator please delete it!]

1
  • The Tale of two Tables "It was the best of Times, it was the worst of Times." Just ignore me. Feb 19 '15 at 10:56
18

The package you need is shorttoc:

\documentclass[10pt, a4paper]{report}
\usepackage{shorttoc}

\renewcommand*\contentsname{Contents (detailed)}

\begin{document}

\shorttoc{Contents}{1} % Only sections

\tableofcontents

The important thing is that \shorttoc comes before \tableofcontents; you can specify any depth you want with the second argument.

In case you want to use hyperref, then here's how:

\documentclass[10pt, a4paper]{report}
\usepackage{shorttoc}
\usepackage{hyperref}

\renewcommand*\contentsname{Contents (detailed)}

\begin{document}

\pdfbookmark[1]{Contents}{toc}
\shorttoc{Contents}{1}

\cleardoublepage
\pdfbookmark[1]{Contents (detailed)}{toc (detailed)}
\tableofcontents

Notice that you don't have to specify \shorttoc for the detailed contents, but only \tableofcontents.

1
  • Perfect, problem solved.
    – lpdbw
    Jul 23 '12 at 9:30
4

Here is another solution.

Replace the first \tableofcontents with

{\expandafter\def\csname @starttoc\endcsname#1{\InputIfFileExists{\jobname.#1}{}{}}%
\tableofcontents}

MWE (with hyperref)

\documentclass{report}

\usepackage{hyperref}

\begin{document}

\setcounter{tocdepth}{1}
\setcounter{secnumdepth}{3}

{\expandafter\def\csname @starttoc\endcsname#1{\InputIfFileExists{\jobname.#1}{}{}}%
\tableofcontents}

\renewcommand*\contentsname{Contents (detailed)}

\setcounter{tocdepth}{3}

\tableofcontents

\chapter{XXX}
\section{YYY}
\subsection{WER}
\subsubsection{ABC}
\subsubsection{DEF}
\subsection{ZTR}
\subsubsection{OIU}
\subsubsection{OIZ}
\subsubsection{POI}
\section{YYY}
\subsection{WER}
\subsubsection{EDC}
\subsubsection{RFV}
\subsection{TGB}
\subsubsection{ZHN}
\subsubsection{OUH}
\subsubsection{WEK}
\chapter{ZZZ}
\chapter{AAA}

\end{document} 

Output:

enter image description here

1
  • How can I change view of chapter in the fist one TOC? Mar 24 '16 at 14:24
0

You can use package etoc. No problem with hyperref.

\documentclass{report}

\usepackage{etoc}
\setcounter{tocdepth}{3}          

\usepackage{hyperref}

\begin{document}

\etocsetnexttocdepth{section}
\tableofcontents

\renewcommand*\contentsname{Contents (detailed)}
\tableofcontents

\chapter{XXX}
\section{YYY}
\subsection{WER}
\subsubsection{ABC}
\subsubsection{DEF}
\subsection{ZTR}
\subsubsection{OIU}
\subsubsection{OIZ}
\subsubsection{POI}
\section{YYY}
\subsection{WER}
\subsubsection{EDC}
\subsubsection{RFV}
\subsection{TGB}
\subsubsection{ZHN}
\subsubsection{OUH}
\subsubsection{WEK}
\chapter{ZZZ}
\chapter{AAA}

\end{document}

The first one:

enter image description here

The second one:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.