# Multiples TOC for overlapping content

I have a book typesetted in latex with about 30 stories. The stories conform 3 books with stories overlapping, this means story1 appears in book1 and book2, for example.

How can I generate a latex document containing 3 TOCs? each one pointing to the tales corresponding to each "sub book"?

I suspect that the solution should include a way to tell for each story (chapter) to which "sub book"(s) it belongs.

Since no example is given, I'll try to provide an answer based on assumptions and minitoc package.

This uses \part as 'subbook' and \parttoc as macro to instruct minitoc to generate a local toc. The local toc title can be changed to by redefinition of the \ptctitle macro.

Note: The minitoc package is about 6 years old, as of writing just now and somehow unmaintained. An alternative might be the usage of etoc package.

\documentclass{book}

\usepackage{minitoc}
\usepackage{filecontents}
\usepackage{blindtext}%

\usepackage[hypertexnames=false]{hyperref}

\makeatletter
\makeatother

\let\standardptctitle\ptctitle%

\doparttoc

\renewcommand{\partname}{Book}

\begin{filecontents}{story1.tex}
\chapter{Story 1}%
\end{filecontents}

\begin{filecontents}{story2.tex}
\chapter{Story 2}%
\end{filecontents}

\begin{filecontents}{story3.tex}
\chapter{Story 3}%
\end{filecontents}

\begin{document}

\part{Some Stories}
\tableofcontents
\renewcommand{\ptctitle}{\standardptctitle~of \partname~\thepart}
\parttoc

\input{story1}
\input{story2}

\part{More Stories}
\parttoc
\input{story2}
\input{story3}

\part{Even More Stories}
\parttoc

\input{story3}
\input{story1}

\end{document}


## Version with etoc package

The etoc package provides an easy access to \localtableofcontents and is maintained. See etoc for more information.

\documentclass{book}

\usepackage{etoc}%
\usepackage{filecontents}
\usepackage{blindtext}%

\usepackage[hypertexnames=false]{hyperref}

\makeatletter
\makeatother

\let\StandardContentsName\contentsname

\renewcommand{\partname}{Book}

\begin{filecontents}{story1.tex}
\chapter{Story 1}%
\end{filecontents}

\begin{filecontents}{story2.tex}
\chapter{Story 2}%
\end{filecontents}

\begin{filecontents}{story3.tex}
\chapter{Story 3}%
\end{filecontents}

\begin{document}
\tableofcontents% The whole document contents
\renewcommand{\contentsname}{\StandardContentsName~of \partname~\thepart}

\part{Some Stories}
\localtableofcontents

\input{story1}
\input{story2}

\part{More Stories}
\localtableofcontents
\input{story2}
\input{story3}

\part{Even More Stories}
\localtableofcontents

\input{story3}
\input{story1}

\end{document}

• Thanks. The problem I see with this solution is that stories are repeated inside the whole book. I don't want that. I want them to appear only once. Can this be achieve? – Juanjo Conti Oct 21 '14 at 22:44
• @JuanjoConti: * 3 books with stories overlapping, this means story1 appears in book1 and book2, for example.* This could be interpreted as a multiple appearance of the same story. Your question is somewhat not clear and there is no example given – user31729 Oct 22 '14 at 4:41
• @JuanjoConti I think I interpreted your question (which wasn't that clear:-) the way you intended "overlapping" to be understood. Let me know if not:-) – David Carlisle Oct 22 '14 at 14:19
• @DavidCarlisle: Yes, it was probably meant that way you did it, but for me it was not clear initially. – user31729 Oct 22 '14 at 14:29
• I want the stories to be printed only once. Is that clear? :) Thanks a lot. Excuse my english. – Juanjo Conti Oct 27 '14 at 23:11

\documentclass{article}

\makeatletter
\let\old@starttoc\@starttoc
\def\@toc{toc}
\def\@alltoc{tocabc}
\def\@starttoc#1{%
\def\tmp{#1}%
\ifx\tmp\@toc\let\tmp\currenttoc\fi
\old@starttoc\tmp}
\def\tmp{#1}%
\ifx\tmp\@toc
\ifx\currenttoc\@alltoc
\else
\fi
\else
\fi}
\makeatother

\begin{document}

\def\currenttoc{toca}\def\contentsname{story 1 contents}\tableofcontents
\def\currenttoc{tocb}\def\contentsname{story 2 contents}\tableofcontents
\def\currenttoc{tocc}\def\contentsname{story 3 contents}\tableofcontents

\def\currenttoc{tocabc}
\section{book, the first}

\def\currenttoc{toca}
\subsection{start}
red red blue yellow red red blue yellow
red red blue yellow red red blue yellow

\def\currenttoc{tocb}
\subsection{new start}
one two three four five one two three four five
one two three four five one two three four five

\def\currenttoc{tocabc}
\section{book, the second}

\def\currenttoc{tocb}
\subsection{more numbers}
one two three four five one two three four five
one two three four five one two three four five

\def\currenttoc{tocc}
rome paris london
rome paris london
rome paris london

\def\currenttoc{toca}
black blue green black blue green black blue green
black blue green black blue green black blue green

\def\currenttoc{tocabc}
\section{book, the third}

\def\currenttoc{tocb}
\subsection{numbers again}
one two three four five one two three four five
one two three four five one two three four five

\end{document}