Verified, it does not have the answer in the linked post.
I would like to create table of contents based on chapters. When I insert command \tableofcontents almost at the top -- after opening document and making few definitions, as the result I get empty TOC (not desirable).
When I move it right before new chapter (as an experiment) and I get nothing -- i.e. no TOC at all (empty TOC has at least heading "Table of contents").
For example:
\tableofcontents
\begin{verse}
some quote
\end{verse}
\def\enddoc{}
\def\input#1{}
\include{intro1}
\include{intro2}
\chapter{Program}
intro1 and intro2 are chapters written as separate files. This gives me empty TOC, when I move TOC before chapter "Program" TOC is not created.
I added usepackage with \usepackage{tocloft,calc} and \usepackage{titletoc}. No change at all?
What do I do wrong way?
Update
I found the culprit, but I don't know how to fix it. My entire document consists of several chapter (with bibliography), each chapter is written as separate file. The preamble is also saved as separate file.
What's important currently I can create each chapter as separate pdf (on its own) -- because each chapter includes preamble, not only the main .tex file.
In the main .tex file I have such line:
\def\input#1{}
I don't know what it does (my mistake, I should I added explanation in comment), but it allowed me to build entire document so far.
When I tested it on the stripped sample .tex, removing it allows TOC to be created correctly, but when I comment it in my main document (not just sample) the compilation fails right from the beginning. First separate chapter file includes preamble (so the inclusion is from the middle of .tex file really) and I get error:
Can be used only in preamble. \documentclass
So, is it possible to build TOC nevertheless, or should I drop this separation if I want to create TOC?
.tocfile and the second pass reads in and processes the.tocfile.) if you run latex only once with a\tableofcontentscommand, you will get just the heading (as you did). and you don't want to delete the.tocfile, as that is what contains the entries to be listed in the output. – barbara beeton Aug 09 '13 at 15:26tocloftandtitletocdo nothing if you only add them to the preamble. They provide some useful commands to manipulate the TOC, but one has to use them :-) Moreovercalcdoes not fit here at all here because it helps LaTeX to do arithmetics. Finally\usepackage{tocloft,calc}and\usepackage{titletoc}is equivalent to\usepackage{tocloft,calc,titletoc}. – Ruben Aug 09 '13 at 15:47