1

This related to this question:

How to merge several tex files so that they have one table of contents/List of tables & figures

I have been trying to get the solution by Jean Mentz to work, it's nearly there but I can't seem to get the table of contents to work?

I've tried it as:

\addtocontents{toc}{Chapter One}
\input{Introduction.tex}

which gives the contents page below with overlapping entries on the first line. Note that Chapter One does not appear anywhere apart from the table of contents.

Table of Contents with overlapping entry on first line

Doing it as

\chapter{Chapter One}
\input{Introduction.tex}

Means that only abstract appears on the contents page and chapter one just appears as regular text before abstract in the document. It almost seems like the chapter command is not being recognized?

\documentclass{article}
\usepackage{fancyvrb}
\DefineVerbatimEnvironment{code}{Verbatim}{fontsize=\small}
\DefineVerbatimEnvironment{example}{Verbatim}{fontsize=\small}
\usepackage{natbib}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{bm}
\usepackage{grffile}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{longtable}
\usepackage{graphicx}
\usepackage{url}
\usepackage{graphics}
\usepackage{titlesec}
\def\UrlBreaks{\do\/\do-}
\usepackage[%
 font=small,
 labelfont=bf,
 figurewithin=section,
 tablewithin=section,
 tableposition=top
]{caption}
 \numberwithin{equation}{section}

\makeatletter
\def\env@matrix{\hskip -\arraycolsep
 \let\@ifnextchar\new@ifnextchar
 \array{*\c@MaxMatrixCols l}}
\makeatother


\begin{document}
\input{title.tex}
\tableofcontents
\clearpage
\addtocontents{toc}{Chapter One}\input{Introduction.tex}
\end{document}
9
  • 1
    Note that if I use \part{Chapter 1} it works and gives me what I want apart from the fact that Part I appears before {Chapter One} in the text. If I could make the Part I not appear in the text while keeping the Chapter 1 in the table of contents would be problem solved. Would still like to know why chapter is not working though. – Bazman Sep 19 '14 at 20:48
  • 1
    article does not have a \chapter command. If you need chapters, use report or book instead. Is there some reason for you to use article rather than report or book? article is not really appropriate for a thesis - it is intended for, well, articles. – cfr Sep 19 '14 at 20:49
  • 1
    I have seen both used. For my thesis, I used amsbook so I would probably suggest book. (I only used the AMS version because I used stuff I got from graduate students in the maths department. I would have used book otherwise.) – cfr Sep 19 '14 at 20:53
  • 1
    Do you not want the number either? – cfr Sep 19 '14 at 20:57
  • 1
    Sorry yes you are correct so I just want the Chapter 1 in the document to disappear – Bazman Sep 19 '14 at 21:10
1

Does this do what you want? You might wish to adjust the spacing and font for the chapter title but this shows you how to do that. This puts the chapter number on the same line as the title of the chapter. It also sets the value of \chaptername empty which avoids getting 'Chapter 1 ...' in headers even though the first chapter is just '1 ...' in the text.

\documentclass{book}
\usepackage{fancyvrb}
\DefineVerbatimEnvironment{code}{Verbatim}{fontsize=\small}
\DefineVerbatimEnvironment{example}{Verbatim}{fontsize=\small}
\usepackage{natbib}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{bm}
\usepackage{grffile}
\usepackage{graphicx}% loads graphics - no need for both; no need for epstopdf either; or to load graphicx again later on!
\usepackage{url}
\usepackage{titlesec}
\def\UrlBreaks{\do\/\do-}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{siunitx}
\usepackage[%
 font=small,
 labelfont=bf,
 figurewithin=section,
 tablewithin=section,
 tableposition=top
]{caption}
 \numberwithin{equation}{section}

\makeatletter
\def\env@matrix{\hskip -\arraycolsep
 \let\@ifnextchar\new@ifnextchar
 \array{*\c@MaxMatrixCols l}}
\makeatother

\titleformat{\chapter}[hang]{\LARGE\bfseries}{\thechapter}{.5em}{}
\renewcommand{\chaptername}{}

\usepackage{filecontents}% only so I can include the 'separate' chapters here for convenience (LaTeX writes new files with the given names on compilation which are then \input below)
\begin{filecontents}{title.tex}
    Great title
\end{filecontents}
\begin{filecontents}{intro.tex}
    \kant[1]
\end{filecontents}
\begin{filecontents}{ch1.tex}
    \kant[2-4]
  \end{document}
\end{filecontents}
\begin{filecontents}{ch2.tex}
    \kant[5-9]
\end{filecontents}
\usepackage{kantlipsum}% only to provide filler text for the example

\begin{document}
\input{title}
\tableofcontents
\chapter{Introduction}
\input{intro}
\chapter{Next}
\input{ch1}
\chapter{Another}
\input{ch2}
\end{document}

ToC chapter title header

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.