## Creating chapters

### Objectives

By the end of the chapter you will be able to:

• reference chapters or sections in the text
• link tex documents into one main document

New chapters are created using:

\chapter{Chapter Name}

They are automatically added to the Table of Contents and the PDF bookmarks. New chapters are also put onto a new page. Remember that un-numbered chapters are created using \chapter*{Chapter Name}. These do need to manually added to the Contents and PDF bookmarks.

To split the chapters into sections and subsections we use:

\section{Section Name}\subsection{Subsection Name}

You can even use \subsubsection{Subsubsection Name}

### Example

\chapter{Physics}
\section{Quantum Mechanics}
Text on Quantum Mechanics
\subsection{Schrodingers Cat}
Text on Schrodingers Cat
\subsubsection{Entanglement}
Text on entanglement

If you put the entire content of your Thesis in one file, it will be a very large file! It is better to put each chapter in a separate tex document and then link each document to the main file. Each of these separate files need to be in the same folder as the main file (to put them in a different folder, see the advanced slide at the end of this chapter). The chapter file names cannot include spaces but they can include underscores.

To link a tex file use:

\input{filename}

Notice that I did not include .tex at the end of the filename. Here is an example, one of my chapter files is called experimental_setup. To link it to my main file I use:

\chapter{Experimental Setup}\input{experimental_setup}

The main document is then compiled to create the PDF. The chapter files themselves are never compiled.

Don't forget to save your chapter files with the .tex file extension.

## Referencing Chapters

There are times when you wish to reference one of your own chapters in another chapter. For example, 'I will discuss this in more detail in chapter 4.' To do this in LaTeX each chapter or section must have a unique label. In a large document this can become difficult. A helpful hint is to prefix your chosen label with the shorthand of the object that you are referencing as tables and figures can be referenced in the same way. For example:

\chapter{Electromagnetism}\label{chp:electro}

Where the reference is required in the text you need to place \ref{label name}. So my above example becomes, 'I will discuss this topic in more detail in Chapter \ref{chp:electro}.' This ensures that if you change the order of your chapters, the numbers will be automatically updated. Very useful!

Activity - Give each chapter and section a unique label.

When you compile the document it will need to be compiled twice for all the references to be shown correctly.

\input{./chapters/experimental_setup}