[Tex/LaTex] Table of Contents from multiple files

multiple filestable of contents

I have a main document referring to four files and want to create a ToC with the titles of these four files as well as their structure.

Here`s a MWE for my main file:

\documentclass[a4paper, 12pt, english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{natbib}
\usepackage{chapterbib}

\begin{document}

\input{./title.tex}

\renewcommand{\contentsname}{Table of Contents}
\tableofcontents

\include{Introduction}
\include{Paper1}
\include{Paper2}
\include{Paper3}

\end{document}

and here is an MWE for my included files, all similar:

\begin{center}
{\bfseries Title} 
\end{center}
\section{Introduction}
\section{Conceptual Foundations}
\subsection{Topic A}

I`d like my ToC to look like:

Title file 1

Section file 1

Subsection File 1

Title file 2

….

Currently I have the problem that the titles are not shown since they have not been labeled as a section (I haven`t done that because I want them to appear as unnumbered titles and the following sections/subsections within the file to appear as section/subsection and not a level lower). The second problem is that the sections after the first file are not numbered but labelled with letters "A", "B", etc – I have an appendix in the first file, not sure whether that influences the rest.

Best Answer

Here's a sample document to get you started. I've used titlesec to format the chapter headings and the appendix package to make use of its {subappendices} environment. The reason your chapters are mislabeled is that the default \appendix command turns \chapter level headings into appendices. Since you want per chapter appendices you need to make appendices as section level elements. So you need to remove the \appendix commands from your included documents and then enclose the appendix sections in the {subappendices} environment.

\documentclass{report}
\usepackage{titlesec}
\titleformat{\chapter}[block]
  {\filcenter\Large\bfseries}%
  {}{1em}{}
\usepackage{appendix}
\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thechapter}{}
\renewcommand{\setthesection}{\Alph{section}}

\begin{document}
\tableofcontents
\chapter{Paper title one}
\section{A section}
\subsection{A subsection}
\begin{subappendices}
\section{A chapter appendix}
\section{Another chapter appendix}
\end{subappendices}
\chapter{Paper title two}
\section{A section}
\begin{subappendices}
\section{An appendix}
\end{subappendices}
\end{document}

output of code