3 Text in LaTeX

3.1 Lines and Paragraphs

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.

3.2 Lengths

The \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.

Exercise 2

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.

3.3 Chapters and Sections

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.

The complete list of section-related commands is:

In fact you can also define even smaller sections using \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


Exercise 3

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.


Previous page Next page