5.3 Chapters, Sections, Subsections ...
Chapters, sections, subsections etc can be inserted using the commands:
\part
[<short title>]{<title>}
\chapter
[<short title>]{<title>}
\section
[<short title>]{<title>}
\subsection
[<short title>]{<title>}
\subsubsection
[<short title>]{<title>}
\paragraph
[<short title>]{<title>}
\subparagraph
[<short title>]{<title>}
All these commands have a moving
argument, so fragile commands will need to
be protected using \protect
. [How to create a
\subsubsubsection
]The final two commands in the
above list, \paragraph
and \subparagraph
, represent
subsubsubsections and subsubsubsubsections, although most
class files typeset their arguments as unnumbered running titles.
Note that the availability of these commands depends on the
class file you are using. For example, the scrartcl class
file that we have been using is designed for articles, so the
\chapter
command is not defined in that class, whereas it is
defined in the scrreprt and scrbook class files.
Each of the commands above has a mandatory argument <title> and an optional argument <short title>. The mandatory argument <title> is simply the title of the chapter/section/subsection etc. For example:
If you are using the scrartcl class file, the output will look like:
If you are using a class file that contains chapters as
well as sections, the section number will depend on the chapter. So,
for example, the current section is the 3rd section
of chapter 5, so the section number is 5.3.
[Why are my sections numbered 0.1 ...?](Note that if
you are using a class file where the section number depends on the
chapter number, you must have a \chapter
command before your
first \section
command, otherwise your section numbers will
come out as 0.1, 0.2 etc.)
Unnumbered chapters/sections etc are produced by placing an asterisk * after the command name. For example:
You can switch to appendices using the command
then continue using \chapter
, \section
etc[Appendixes]. For example (using the scrreprt class file):
Note:
The KOMA-Script classes have another type of sectioning command:
This provides an unnumbered heading not associated with any of the structuring levels. For example, the above was produce using:
The next note below was produced using:
Important Note:
If you want to change the font style used by headings, do not use font declarations in the sectioning command arguments. Don't do, for example:
The KOMA-Script classes provide the command:
where <element> is the name of a structuring element (no backslash) and <commands> is the list of font changing declarations (see Table 4.6) to apply to that element style. For example, the PDF version of this document uses the commands:
Exercise 10: Creating Chapters, Sections etc
Let's try editing our document so that it now has chapters, sections and an appendix. Since the scrartcl class file doesn't have chapters, let's change to the scrreprt class. Changes from our previous document are shown like this.
\documentclass
[12pt]{scrreprt}
\usepackage
{datetime}
\title
{A Simple Document}\author
{Me}
\begin
{document}\maketitle
\begin
{abstract}
A brief document to illustrate how to use\LaTeX
.\end
{abstract}
\chapter
{Introduction}
\section
{The First Section}
This is a simple\LaTeX
\␣document.
Here is the first paragraph.
\section
{The Next Section}
Here is the second paragraph\footnote
{with a footnote}.
As you can see it's a rather short paragraph, but not
as short as the previous one. This document was
created on:\today
\␣at\currenttime
.
\chapter
{Another Chapter}
Heres another very interesting chapter.
Were going to put a picture here later.
\chapter
*{Acknowledgements}
I would like to acknowledge all those
very helpful people who have assisted me in my work.
\appendix
\chapter
{Tables}
We will turn this tabular environment into a table later.
\begin
{tabular}{lrr}
&\multicolumn
{2}{c}{\bfseries
Expenditure}\\
&\multicolumn
{1}{c}{Year1} &\multicolumn
{1}{c}{Year2}\\\bfseries
Travel & 100,000 & 110,000\\\bfseries
Equipment & 50,000 & 60,000\end
{tabular}
\end
{document}
(You can download a copy of this file if you like, but I recommend that you try editing the file yourself to give you practice.)
This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-00-5).