3
The Document
3.1 The Document Class
It is time to describe how an entire document with chapters and sections and other additional content
can be produced with LaTeX. We have seen previously, that all LaTeX files should begin by specifying
the
\documentclass{...}
.
We’ve
also
noted
that
for
a
short
article
\documentclass{article}
,
and
for
books,
we
write \documentclass{book}
.
There
are,
of
course,
other
report
and letter
.
All
of
them
share
some
common
features
and
there
are
features
specific
to
each.
In
addition
to
specifying
the
type
of
document,
Therefore
the
actual
syntax
of
the \documentclass
command
is:
Note
that
options
are
given
in
square
brackets
and
not
braces.
Options
are
specified
within
square
brackets ([...]
),
after
which
mandatory
arguments
are
given
within
braces ({...}
).
3.1.1 Font Size
We
can
select
the
size
of
the
font
for
the
normal
text
in
the
Therefore, if we wanted to have a document with size 11pt, we write:
The
default
is 10pt
and
so
this
is
the
size
we
get,
if
we
do
NOT
specify
any
font-size
option.
3.1.2 Paper Size
We
know
that
LaTeX has
its
own
method
of
breaking
lines
to
make
paragraphs,
which
we
looked
previously.
It
also
has
methods
to
make
vertical
breaks
to
produce
different
pages
of
output.
For
these
breaks
to
work
properly,
it
must
know
the
width
and
height
of
the
paper
used.
The
various
options
for
selecting
the
paper
size
are
given
below:
Document | Dimensions (in) | Document | Dimensions (in) |
---|---|---|---|
letterpaper
|
11 × 8.5 | a4paper
|
11 × 8.5 |
legalpaper
|
14 × 8.5 | a5paper
|
11 × 8.5 |
executivepaper
|
10.5 × 7.25 | b5paper
|
11 × 8.5 |
Normally, the longer dimension is the vertical one-that is, the height of the page. The default is letterpaper
.
The default option abides by the American standards. To use a European standard, you need to declare a4paper
in the documentclass
options such as:
\documentclass[]{a4paper}
3.1.3 Page Formats
There
are
options
for
setting
the
contents
of
each
page
in
a
single
column
or
in
two
and
the
default
is onecolumn
.
There is also an option to specify whether the document will be finally printed on just one side of each paper or on both sides. The names of the options are:
One
of
the
differences
is,
with
the twoside
option,
page
numbers
are
printed
on
the
right
on
odd-numbered
pages
and
on
the
left
on
even
numbered
pages,
so
when
these
printed
back
to
back,
the
numbers
are
always
on
the
outside,
for
better
visibility
and
conform
to
typographical
traditions.
LaTeX has no control over the actual printing. It only makes the format for printing.
The default is oneside
for article, report and letter and twoside for book.
In the report
and book
class there is a provision to specify the different chapters. Chapters always begin on a
new page, leaving blank space in the previous page, if necessary. With the book class there is the additional
restriction that chapters begin only on odd-numbered pages, leaving an entire page blank, if need be.
Such behaviour is controlled by the options,
The default is openany
for reportclass
so that chapters begin on “any” new page and openright
for the book class so that chapters begin only on new right, that is, odd numbered, page.
There is also a provision in LaTeX for formatting the “title” (the name of the document, author(s) and so on) of a document
with special typographic consideration. In the article class, this part of the document is printed along with the text
following on the first page, while for report and book, a
As noted above, the default is notitlepage
for article and titlepage for report and book. As with the other options,
the default behaviour can be overruled by explicitly specifying an option with the document class command.
3.2 Page Style
Having decided on the overall appearance of the document through the \documentclass
command with its various options, we
next see how we can set the style for the individual pages. In LaTeX, each page has a
where the mandatory argument can be any one of the following
The behaviour pertaining to each option is as follows:
- plain
-
The page head is empty and the foot contains just the page number, centred with respect to the width of the text. This is the default for the article class if no
\pagestyle
is specified in the preamble. - empty
-
Both the head and foot are empty. In particular, no page numbers are printed.
- headings
-
This is the default for the book class. The foot is empty and the head contains the page number and names of the chapter section or subsection, depending on the document class and its options as given below:
- myheadings
-
The same as headings, except that the
section information in the head are NOT predetermined, but to be given explicitly using the commands\markright
or\markboth
as described below.
Moreover, we can customise the style for the
where
\thispagestyle{empty}
. Note that only the
3.2.1 Heading Declarations
As mentioned previously, in the page style myheadings
, we have to specify the text to appear on the head of every page. It is done with one of the commands
where left head
is the text to appear in the head on left-hand pages and
\markboth
command is used with the twoside
option with even numbered pages considered to be on the left and odd numbered pages on
the right. With oneside
option, all pages are considered to be right-handed and so in this case, the command \markright
can be used.
These commands can also be used to override the default head set by the headings style.
These give only a limited control over the head and foot, since the general format, including the font used and the placement of the page number, is fixed by LaTeX. Better customisation of the head and foot are offered by the package fancyhdr , which is included in most LaTeX distributions.
3.3 Page Numbering
The style of page numbers can be specified by the command:
The possible arguments to this command and the resulting style of the numbers are given below:
Command | Description |
---|---|
arabic
|
Indo-Arabic numerals |
roman
|
lowercase Roman numerals |
Roman
|
upper-case Roman numerals |
alph
|
lowercase English letters |
Alph
|
uppercase English Letters |
The default value is arabic.
This
command
resets
the
page
\pagenumbering{roman}
at
the
beginning
of
the
Preface
and
issue
the
command \pagestyle{arabic}
immediately
after
the
first \chapter
command.
We can make the pages start with any number we want by the command
where
3.4 Formatting Lengths
Each page that LaTeX produces consists not only of a head and foot as discussed above but also a body containing the actual text. In formatting a page, LaTeX uses the width and heights of these parts of the page and various other lengths such as the left and right margins. The values of these lengths are set by the paper size options and the page format and style commands.
For example, the page layout with values of these lengths for an odd page and even in this book are
separately shown below. These lengths can all be changed with the command \setlength
. For example,
makes the width of text 15 cm. The package geometry gives easier interfaces to customise page format.
3.5 Parts of a Document
We
now
turn
our
attention
to
the
contents
of
the
document
itself.
Documents
are
divided
into
chapters,
sections
and
so
on.
There
may
be
a
title
part
3.5.1 The Title
The “title” part of a document usually consists of the name of the document, the name of author(s) and sometimes a date. To produce a title, we make use of the commands:
Note that after specifying the arguments of \title
, \author
and \date
, we must issue the command \maketitle
for this part to be
typeset. By default, all entries produced by these commands are centred on the lines in which they appear. If a title text is too
long to fit in one line, it will be broken automatically. However, we can choose the break points with the \\
command.
If there are several authors and their names are separated by the \and
command, then the names appear side by side. Therefore we can do the following:
If instead of \and
, we use (plain old) \\
, the names are printed one below another. We may leave
some of these arguments empty; for example, the command \date{ }
prints no date. Note, however,
that if you simply omit the \date
command itself, the current date will be printed. The command
can
be
given
at
any
point
within
the \title
, \author
or \date
.
It
puts
a
marker
at
this
point
and
places
the
footnote
text
as
a
footnote.
(The
general
method
of
producing
a
footnote
is
to
type \footnote{footnote text}
at
the
point
we
want
to
refer
to.)
As
mentioned
earlier,
the
“title”
is
printed
in
a
separate
page
for
the
document
classes
book
and
report
and
in
the
first
page
of
the
document
for
the
article
class.
titlepage
or notitlepage
.
3.5.2 Abstract
In the document classes article
and report
, an abstract of the document in special format can be produced by the commands
Note that we have to type the abstract ourselves. In the report class this appears on the separate title page and in the article class it appears below the title information on the first page.
This command is NOT available in the book class.
3.5.3 Dividing the Document
A book is usually divided into chapters and, chapters are divided into sections, sections into subsections and so on. LaTeX provides the following hierarchy of sectioning commands in the book and report class:
Except for \chapter
all these are available in article class also. For example, the heading at the beginning of this chapter was produced by
and the heading of this section was produced by
To see the other commands in action, suppose at this point of text let’s type:
\subsection{Example} In this example, we show how subsections and subsubsections are produced (there are no subsubsubsections). Note how the subsections are numbered. \subsubsection{Subexample} Did you note that subsubsections are not numbered? This is so in the \texttt{book} and \texttt{report} classes. In the \texttt{article} class they too have numbers. (Can you figure out why?) \paragraph{Note} Paragraphs and subparagraphs do not have numbers. And they have \textit{run-in} headings. Though named paragraph we can have several paragraphs of text within this. \subparagraph{Subnote} Subparagraphs have an additional indentation too.
which gives us the following output:
3.5.4 Example
In this example, we show how subsections and subsubsections are produced (there are no subsubsubsections). Note how the subsections are numbered.
Subexample
Did you note that subsubsections are not numbered? This is so in the book and report classes. In the article class they too have numbers. (Can you figure out why?)
Note
Paragraphs and subparagraphs do not have numbers. And they have
3.5.5 Additional Information
In
the book
and
the report
classes,
the \chapter
command
shifts
to
the
beginning
of
a
new
page
and
prints
the
word
\section
command
produces
two
It does not produce any text like “Section”.
Subsections have three
the chapter, section and subsection.
\subsubsections
and
commands
below
it
in
the
hierarchy
do
NOT
have
any
numbers.
In
the
article
class, \section
is
highest
in
the
hierarchy
and
produces
single
number
like \chapter
in
book.
Each
sectioning
command
also
has
a
“starred”
version
which
does
not
produce
numbers.
Thus \section*{name}
has
the
same
effect
as \section{name}
,
but
produces
no
number
for
this
section.
Some
books
and
longish
documents
are
divided
into
parts
also.
LaTeX also
has
a \part
command
for
such
documents.
In
such
cases, \part
is
the
highest
in
the
hierarchy,
but
it
does
not
affect
the
numbering
of
the
lesser
sectioning
commands.
You
may
have
noted
that
LaTeX has
a
specific
format
for
typesetting
the
section
headings,
such
as
the
font
used,
the
positioning,
the
vertical
space
before
and
after
the
heading
and
so
on.
All
these
can
be
customised
but
require
knowledge
on
LaTeX.