0

I am preparing a teaching dossier and would like to include the table-of-contents from all my lecture notes.

Can the .toc files from these documents be read and compiled into a seperate latex file?

Here's the text from one such .toc

\contentsline {chapter}{\numberline {1}Sequences}{1}
\contentsline {chapter}{\numberline {2}Series}{6}
\contentsline {section}{\numberline {2.1}Power Series}{19}
\contentsline {subsection}{\numberline {2.1.1}Which functions may be represented as power series?}{25}
\contentsline {section}{\numberline {2.2}The Generalised Binomial Theorem}{28}
\contentsline {chapter}{\numberline {3}Differential Equations}{30}
\contentsline {section}{\numberline {3.1}Differential Equations}{30}
\contentsline {subsection}{\numberline {3.1.1}Application: Radioactive Decay}{31}
\contentsline {subsection}{\numberline {3.1.2}Separable ODE's}{33}
\contentsline {section}{\numberline {3.2}First Order Linear ODEs}{35}
\contentsline {subsection}{\numberline {3.2.1}Mixing Problems}{37}
\contentsline {section}{\numberline {3.3}The Logistic Equation}{39}
\contentsline {section}{\numberline {3.4}2nd Order Linear ODE's with constant coefficients}{41}
\contentsline {subsubsection}{Boundary Value Problems}{42}
\contentsline {subsubsection}{Initial Value Problems}{42}
\contentsline {chapter}{\numberline {4}Calculus of Several Variables}{48}
\contentsline {section}{\numberline {4.1}Functions of Two Real Variables}{48}
\contentsline {section}{\numberline {4.2}Limits and Continuity}{51}
\contentsline {section}{\numberline {4.3}Partial Derivatives}{53}
\contentsline {subsection}{\numberline {4.3.1}Higher Order Partial Derivatives}{54}
\contentsline {section}{\numberline {4.4}Linear Approximation and tangent Planes}{56}
\contentsline {section}{\numberline {4.5}The Chain Rule}{59}
\contentsline {section}{\numberline {4.6}The Gradient}{59}
\contentsline {section}{\numberline {4.7}Directional Derivatives}{60}
\contentsfinish 
2

It's possible, but it requires some caution.

toc_1.toc generated from this file:

\documentclass[10pt,a4paper]{book}
\usepackage{blindtext}
\begin{document}
\tableofcontents

\blinddocument
\end{document}

toc_2.toc is your example.

And this file is used to generate the overall ToC:

\documentclass[10pt,a4paper]{book}
\usepackage{blindtext}
\let\contentsfinish\relax
\begin{document}
\chapter*{Lecture Notes Contents}
\contentsline {part}{Lecture Notes 1}{}
\input{toc_1.toc}
\contentsline {part}{Lecture Notes 2}{}
\input{toc_2.toc}
\end{document}

You have to load packages, which leave commands in the .toc file. E.g. blindtext in the example or what ever package wrote \contentsfinish in your .toc file. You may have to disable commands written to the ToC. I did this here for \contentsfinish with

\let\contentsfinish\relax

For command with parameters this can be done with

\renewcommand{<command name>}[<number of parameters>]{}

Additionally, if you want to write the title of the lecture note before its contents, you have to use \contentsline to get the correct formatting. Here

\contentsline {part}{Lecture Notes 1}{}

was used. Of course, instead of or additionally to this you can also type normal text.

Another issue is the hyperref package. You can not mix .toc files from documents compiled with and without hyperref, because it redefines \contentsline with additional parameters.

If your lecture notes are all compiled with hyperref you have to use

\contentsline {part}{Lecture Notes 1}{}{}

to add the title. And of course, links won't work.

The result:

enter image description here

|improve this answer|||||
  • \contentsfinish comes from titletoc package. – user4686 Sep 26 '17 at 12:27

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.