You may have noticed that, in general, LaTeX ignores white space. A paragraph in LaTeX is defined by leaving a blank line. If you just want to leave a line blank to make the text more readable in the source, then you just need to add a comment character, "%", at the start.
Sometimes you might want to end a line early, or have a blank line
to separate out the content, and you can do this with
\\
. This tells LaTeX to break the line, but it doesn't
start a new paragraph.
By default most LaTeX documents will indent the first line of the
paragraph. The amount of space it indents it by can be controlled using the \parindent
command, e.g.
\parindent 10mm
You might also want to leave a little extra vertical space between paragraphs, and to do this you use \parskip
, e.g.
\parskip 1.2in
Notice that, somewhat unusually, the arguments to these commands don't go inside curly brackets.
Both of these commands can be used before the document part
(i.e. before \begin{document}
) or in the middle of the
text. If you put it in the middle of the text it will only apply from
that point on. You can of course change it again later.
\parindent
and \parskip
commands both needed a length as an argument. You can specify lengths in points pt
, millimetres mm
, centimetres cm
or inches in
.
Add three or more paragraphs to your document, perhaps describing who you are and what you do. Have each paragraph indented by a different amount, and leave a different amount of space between each of the paragraphs.
Most documents are long enough that you might want to break them up
into different sections. For long documents (classes book
and report
) the main division of the document is into
chapters, which may then be further divided into sections and, if
necessary, subsections. The article
is designed for
shorter documents and it's "top-level" divisions are sections - it
doesn't understand chapters.
To start a new chapter you use the \chapter{}
command, where the title of the chapter goes in between the curly braces, e.g.
\chapter{Introduction}
The complete list of section-related commands is:
\part{Writing LaTeX}
defines the start of a
major part of a book. These are usually numbered (starting at 1). These aren't very useful for most of the things we want to do with LaTeX, and are only defined for the book
and report
classes.
\chapter{My LaTeX Document}
defines the start of a
new chapter. These are usually numbered (starting at 1). Chapters are
only available for the book
and report
classes - in particular they are not available in
the article
class, as these are for short papers and
treat sections as the "top-level" division.
\section{Introduction}
defines the start of a new section. These are usually numbered within a chapter, e.g. section 2.3 is the third section in the second chapter.
\subsection{Background Material}
defines the start of a subsection. These are usually numbered within a section, so subsection 2.3.1 is the first subsection of the third section of the second chapter.
\subsubsection{Fine Details}
defines the start of a new sub-subsection! Often sub-subsections won't be numbered.
\paragraph
and \subparagraph
, but
these are rarely useful for us.
By default, LaTeX will number the parts, chapters, sections and subsections in your document. If you don't want them to be numbered, put an asterisk at the end of the section name, for example
\chapter*{Introduction}
Add two sections to your document, one near or at the start and one
near the middle. Experiment with changing
the documentclass
of your LaTeX document and see what
effect it has on the way the sections are laid out. Try adding some
sub-sections and chapters to your document.
You can find a sample document here.
\parindent
and the space in between paragraphs by \parskip
\chapter
, \section
or \subsection
, and the name of the region is an optional argument
\chapter*
Previous page | Next page |