23. Formatting chapter sections

A note about file structure

If a document consists of multiple chapters, then it is good practice to create one .tex filer per chapter. For example:

Then you define the title and other information at the top of each chapter using specific commands. Furthermore, the document’s TOC (Table of Contents) are built using the chapter title and each chapter’s section headings. You can also add index entries for the chapter.

Defining a chapter title

Each chapter begins with the following elements:

1
2
3
\chapter{Overview}  % Chapter title
\label{sec:Overview} % Used for cross-referencing
\index{overview} % Used for indexing

For example:

1
2
3
4
5
6
7
8
9
10
11
12
\typeout{}
\typeout{=====================================================================}
\typeout{==== Installing Software}
\typeout{====}
\typeout{==== installing.tex}
\typeout{=====================================================================}
\typeout{}
% The above lines are printed out in a terminal to indicate this file is being processed.


\chapter{Installing Software}
\label{sec:Preparing to Install Software}

Section headings

Creating a section headings is quite easy - use the section command. Second and third level headings are just as easy. These levels use subsection and subsubsection commands. For example:

1
2
3
4
5
\section{heading text}

\subsection{heading text}

\subsubsection{heading text}

Note: Three levels of headings are best. Any more and you may need to rewrite sections so they are at most third level deep. If you must, then just use a bolded paragraph for a fourth level heading.

Paragraphs

Paragraphs are entered without markup tags. Adding a new paragraph simply requires a blank line between paragraphs.

1
2
3
This is the first paragraph about Road Runners.

This is the second paragraph about Road Runners.

Comments

You can add comments to a .tex file as required using the % character.

1
% Add a comment using this character and LaTeX will ignore the rest of the current line.

Paragraph line breaks

You can add a line break into text by adding a backslash {\} or using the \newline command. However, these two commands are not entirely identical. The backslash provides two optional parameters.

The following command tells LaTeX to start a new line.

1
\ 

The following command tells LaTeX not to start a new page after the line by issuing a \nobreak.

1
\* 

The following command specifies the vertical space <len> to be inserted before the next line. This value can also be negative.

1
\[<len>] 

Note: The above two can also be mixed. That is, using both a starred + optional argument combination \*[<len>].

The following command is similar to the backslash.

1
\newline 

Indenting paragraphs in lists

You can define the indentation value of paragraphs within lists in the stylesheet then apply the command where needed.

1
2
3
4
\newenvironment{myindentpar}\[1\]\[1\]%
{\begin{list}{}%
  {\setlength{\leftmargin}{#1}}% \item[]% }
  {\end{list}}

Then Use myindentpar in the document flow to indent a paragraph based on the settings.

1
\begin{myindentpar}{1cm} % text text text... % \end{myindentpar}

Note that you can adjust the indent in this command as required.

Click to continue.