How to create a fake ToC on a title page?

I wrote a large book of 2000 pages, so I have to split it into 4 or 5 volumes of about 500 pages (250 paper sheets), for printing and paper binding issues. Each volume would have its own front title page, designed from the code below. It would be usefull to add a Partial Table of Content on it (the true and complete ToC is inside the first volume of the book). Of course, each page number would be added by hand to these "fake ToC", since the title pages are done separately from the main document. I would list only the chapters in these fake partial ToC, since they'll be shown on a single page.

So how would you suggest to build such "partial fake ToC", with the code below, in place of the dumb text part?

\documentclass[letterpaper]{book}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{libertine}
\renewcommand*\familydefault{\sfdefault}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{anysize}
\marginsize{1.5in}{1in}{0.5in}{0.5in}
\usepackage[x11names]{xcolor}
\definecolor{backgroundcolor}{RGB}{150, 170, 170}
\definecolor{andcolor}{RGB}{230, 255, 255}
\definecolor{subtitle}{RGB}{230, 255, 255}
\usepackage{graphicx}
\usepackage{afterpage}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand*{\maintitle}{\begingroup

\pagecolor{backgroundcolor}

\raggedright
{\hspace{-4pt}\fontsize{52}{0}\selectfont{Title 1}}

\vspace*{2\baselineskip}

\raggedleft
{\textcolor{subtitle}{\fontsize{45}{0}\selectfont {Part 1 of 5}}}

\vspace*{3\baselineskip}

\raggedleft
{\huge Author}
\vfill

\endgroup}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{titlepage}

\begin{tikzpicture}[remember picture, overlay]
\draw[line width = 1in,color = white] ($(current page.north west) + (0.25in,0.25in)$) rectangle ($(current page.south east) + (0.25in,-0.25in)$);
\draw[line width = 0.25pt,color = black] ($(current page.north west) + (0.75in,-0.25in)$) rectangle ($(current page.south east) + (-0.25in,0.25in)$);
\draw[line width = 1pt,color = white] ($(current page.north west) + (1in,-0.5in)$) rectangle ($(current page.south east) + (-0.5in,0.5in)$);
\end{tikzpicture}

\maintitle

Dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text.

\end{titlepage}

\end{document}


Preview of what this code is doing, and the fake ToC emplacement shown in red:

• Why not just take the <filename>.toc file generated by your document, chop it up appropriately, and paste it in? This seems to be a good time to actually call \contentsline by hand instead of leaving it in the background. Mar 24 '21 at 18:25
• @WillieWong, how would you implement your idea? Can you offer an answer, from the code above?
– Cham
Mar 24 '21 at 18:47
• Say you want to include chapters 5, 6, 7, 8, 9 in this volume. Open up <filename>.toc, copy the lines that read \contentsline{chapter}{....} for those chapters, and paste them into where "dumb text" is. Mar 24 '21 at 18:56
• @Cham: (1) Once you're done compiling (possibly via multiple passes), you must have a .toc. Sure, it's overwritten each time you compile, but it should be there once you're done, otherwise you won't have a ToC at all. (2) Do you compile each volume separately, or as a whole?
– Werner
Mar 24 '21 at 19:18
• @cham: "my compilation app"... care to enlighten us on which one it is? In any case, if you drop to a command line and just run pdflatex, you should be able to bypass whatever cleanup action your compilation app is using. (In fact, if the .aux files are kept, you should be able to just recover the .toc file with one pass.) Mar 24 '21 at 19:27

This solution is based on the package etoc, with a two-step workflow.

I prepared a mock-up of a book with almost 2000 numbered pages to get a significant TOC. The book has four parts with three chapters each.

I have defined the command \fakeTOC that adds an entry in the table of contents as it were a part. This is needed to later produce the partial TOC by etoc.

The page with the fake TOC is produced with your design using the command \fakeTOC{<part name>} and includes a partial TOC of the part of the full book, as requested.

These added pages will not increase the page counter of the original content! In this way the partial TOCs will have the same page numbers for chapters as in the original document.

The local TOC is built by the etoc package. The layout of this local TOC is, of course, highly customizable. I only added the two horizontal lines.

The main TOC maintains the layout provided by the class.

Initial TOC: Full original document

TOC with fake TOCs: after running generateFkTOC.tex.

Extracted pages with fake TOCs: after running extractfkTOC.tex

As you don't want to have these "fake" pages in your main document, this is the two-step workflow:

(1) Generate them in the main document, adding \fakeTOC{<partnumber>} at the beginning of each part so that the local TOCs are automatically generated and updated by etoc. See generateFkTOC.tex

(2) Extract the four pages generated containing the partial TOCs from the main pdf file, running extractfkTOC.tex

This is generateFkTOC.tex

\documentclass[letterpaper,twoside]{book}

\usepackage{kantlipsum} % dummy text

\usepackage{libertine}
\usepackage{fancyhdr}
\usepackage{lastpage} % last page

\pagestyle{fancy}
\fancyhf{}
\rfoot{Page \thepage \, of \pageref{LastPage}}

%%% ************************************

\newcounter{fkpart}

\cleardoublepage

\begin{tikzpicture}[remember picture, overlay]
\draw[line width = 1in,color = white] ($(current page.north west) + (0.25in,0.25in)$) rectangle ($(current page.south east) + (0.25in,-0.25in)$);
\draw[line width = 0.25pt,color = black] ($(current page.north west) + (0.75in,-0.25in)$) rectangle ($(current page.south east) + (-0.25in,0.25in)$);
\draw[line width = 1pt,color = white] ($(current page.north west) + (1in,-0.5in)$) rectangle ($(current page.south east) + (-0.5in,0.5in)$);
\end{tikzpicture}

\begingroup
\thispagestyle{empty}
\pagecolor{backgroundcolor}
\sffamily
{\raggedright\fontsize{52}{52}\selectfont  The Full Book}

\vspace*{2\baselineskip}
\raggedleft
{ \textcolor{subtitle}{\sffamily \fontsize{45}{45}\selectfont {Part #1 of 4}}}

\vspace*{3\baselineskip}

{\sffamily \huge Author}
\vfill
\localtableofcontents
\vfill
Dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text dumb text.

\newpage\null
\thispagestyle{empty}
\pagecolor{white}
\endgroup
\cleardoublepage
}
%%% ************************************

\usepackage[x11names]{xcolor}
\definecolor{backgroundcolor}{RGB}{150, 170, 170}
\definecolor{andcolor}{RGB}{230, 255, 255}
\definecolor{subtitle}{RGB}{230, 255, 255}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\frontmatter
\tableofcontents
\newpage\null\thispagestyle{empty}

\etocsettocstyle{\noindent\rule{\linewidth}{0.5pt}\vskip0.3\baselineskip\sffamily}%
{\noindent\rule{\linewidth}{0.5pt}\vskip0.5\baselineskip} % etoc style for local TOC

\mainmatter
\fakeTOC{1}% part #1 starts
\chapter{I-One}
1.  \kant[1-5]
\chapter{I-Two}
1.  \kant[1-5]
\chapter{I-Three}
1.  \kant[1-5]

\fakeTOC{2} % part #2 starts
\chapter{II-Four}
2.  \kant[1-5]
\chapter{II-Five}
2.  \kant[1-25]
\chapter{II-Six}
2.  \kant[1-25]

\fakeTOC{3} % part #3 starts
\chapter{III-Seven}
3.  \kant[1-5]
\chapter{III-Eight}
3.  \kant[1-25]
\chapter{III-Nine}
3.  \kant[1-25]

\fakeTOC{4} % part #4 starts
\chapter{IV-Ten}
4.  \kant[1-5]
\chapter{IV-Eleven}
4.  \kant[1-25]
\chapter{IV-Twelve}
4.  \kant[1-25]

\end{document}


This is extractfkTOC.tex. Uses the package pdfpages to extract the pages with the fake TOCs to a new pdf file. The page numbers are the number of the physical pages to be extracted from generateFkTOC.tex.

 %%% extractfkTOC.tex from generateFkTOC.tex

\documentclass[letterpaper]{article}
\usepackage{pdfpages}
\begin{document}

\includepdf[pages=3]{generateFkTOC.pdf} % use page numbers of physical pages
\includepdf[pages=11]{generateFkTOC.pdf}
\includepdf[pages=31]{generateFkTOC.pdf}
\includepdf[pages=51]{generateFkTOC.pdf}

\end{document}


Perhaps something along the lines of having each volume a complete document file. Set the starting page/chapter etc numbers in the preamble of each document based on the last numbers in the preceeding volume to get continuous numbering through the group. Apart from the first volume any ToC will refer only to entries in the volume. For the first volume extend its *.toc file by the *.toc file of the subsequent volumes.

• I don't understand your answer. Each title-page is done separately, independently of the whole document (which is a single PDF of 2000 pages).
– Cham
Mar 24 '21 at 18:46
• @Cham I am suggesting that you make your single tex PDF document into multiple tex PDF documents, each of which have their own titlepage. At the end you can create a single PDF document by combing the individual PDFs. Mar 24 '21 at 19:07
• This would turn into a nightmare! The full document is huge, with a very complicated preamble. I don't want to mess with it!
– Cham
Mar 24 '21 at 19:09
• @Cham Tough --- GOM Mar 24 '21 at 19:53
• GOM? What is that?
– Cham
Mar 24 '21 at 19:55

Ok, here's a quick and dirty way of doing what I need:

    \documentclass[letterpaper]{book}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{libertine}
\renewcommand*\familydefault{\sfdefault}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{anysize}
\marginsize{1.5in}{1in}{0.5in}{0.5in}
\usepackage[x11names]{xcolor}
\definecolor{backgroundcolor}{RGB}{150, 170, 170}
\definecolor{andcolor}{RGB}{230, 255, 255}
\definecolor{subtitle}{RGB}{230, 255, 255}
\usepackage{graphicx}
\usepackage{afterpage}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand*{\maintitle}{\begingroup

\pagecolor{backgroundcolor}

\raggedright
{\hspace{-4pt}\fontsize{52}{0}\selectfont{Big Book Title}}

\vspace*{2\baselineskip}

\raggedleft
{\textcolor{subtitle}{\fontsize{45}{0}\selectfont {Part 1 of 5}}}

\vspace*{3\baselineskip}

\raggedleft
{\huge Author's name}
\vfill

\endgroup}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{titlepage}

\begin{tikzpicture}[remember picture, overlay]
\draw[line width = 1in,color = white] ($(current page.north west) + (0.25in,0.25in)$) rectangle ($(current page.south east) + (0.25in,-0.25in)$);
\draw[line width = 0.25pt,color = black] ($(current page.north west) + (0.75in,-0.25in)$) rectangle ($(current page.south east) + (-0.25in,0.25in)$);
\draw[line width = 1pt,color = white] ($(current page.north west) + (1in,-0.5in)$) rectangle ($(current page.south east) + (-0.5in,0.5in)$);
\end{tikzpicture}

\maintitle

\LARGE

\raggedright
Chapitre 1.  First chapter title \dotfill 1

\vspace*{0.5\baselineskip}

Chapitre 2.  Second chapter title \dotfill 83

\vspace*{0.5\baselineskip}

Chapitre 3.  Third chapter title \dotfill 109

\vspace*{0.5\baselineskip}

Chapitre 4.  Fourth chapter title \dotfill 179

\vspace*{0.5\baselineskip}

Chapitre 5.  Another chapter title \dotfill 269

\vspace*{0.5\baselineskip}

Chapitre 6.  Some funny chapter title \dotfill 399

\vfill

\end{titlepage}

\end{document}


It isn't ideal, since I need to put back the chapter titles and page numbers by hand, but at least it's doing the job, and it's not too cumbersome to do since I have about 20 chapters, splited into 4 or 5 volumes (so 4 title pages to create like this one). The first volume has the real title page (without a ToC on it!), and the real full ToC inside the volume.

Preview of this code:

• I added a solution with an automatic generation of the "fake" TOCs. Mar 25 '21 at 15:36