# Table of Contents from multiple files

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.

Heres 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}


Id 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 havent 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.

• Why are you doing it this way? Use the report class instead of article and make each paper a \chapter{} instead of hand formatting the titles. Then they will appear in the TOC automatically. You can use titlesec to format the chapter titles the way you want. – Alan Munn Jan 11 '16 at 16:50
• fair enough, that works fine - I guess I can get rid of "Chapter 1" in each title. However, the problem with the numbering still persists - Chaptr 2 is now not Chapter 2, but Chapter A. The reason why I was not using chapter for the titles was that I want a line break within each title itself, e.g. Paper 1 Title of paper 1 – latexQ Jan 11 '16 at 16:55
• @latexQ: Most likely you have some \renewcommand{\thechapter} somewhere that uses A instead of a number – user31729 Jan 11 '16 at 16:58
• @latexQ: By the way, I answered a question recently about including external toc from other documents: tex.stackexchange.com/questions/262977/… – user31729 Jan 11 '16 at 16:59

## 1 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}
`

• Ok, now I understand where the problem was - thank you, it works just as expected! – latexQ Jan 12 '16 at 8:28