Your support for our advertisers helps cover the cost of hosting, research, and maintenance of this document

Formatting Information — An introduction to typesetting with LATEX

### Chapter 2: Basic structures

After the Document Class Declaration, the text of your document is enclosed between the two commands we saw in § 1.4. These identify the beginning and end of the actual document (so in the example below, you would put your text where the dots are):

\documentclass[11pt,a4paper,oneside]{report}

\begin{document}
...
\end{document}


The reason for marking the beginning of your document text is that LATEX allows you to insert extra setup specifications before it (where the blank line is in the example above: we’ll be using this soon). The reason for marking the end of your document text is to provide a place for LATEX to be programmed to do extra stuff automatically at the end of the document, like making an index.

A useful side-effect of marking the end of the document text is that you can store comments or temporary text underneath the \end{document} in the knowledge that LATEX will never see them and never try to typeset them (they don’t even need to be preceded by the % comment character), but they will remain in your document for you to see in your editor, or maybe to copy and paste in a later edit.

...
\end{document}
Don't forget to get the extra chapter from Jim!


This \begin ...\end pair of commands is an example of a common LATEX structure called an environment. Environments enclose text which is to be handled in a particular way. All environments start with \begin{...} and end with \end{...} (putting the name of the environment in the curly braces each time).

If you’re familiar with HTML, SGML, or XML you’ll recognise this technique: it’s just like start-tags and end-tags.

### Exercise 2: Add the document environment

2. If you are using XƎLATEX (not if you are using PDFLATEX)…

In between the Document Class Declaration and the \begin{document}, add the line we saw in the listitem ‘If you are using XƎLATEX (with …’ which allows the use of UTF-8 in XƎLATEX:

\usepackage{fontspec}

3. If you are using PDFLATEX (not if you are using XƎLATEX)…

In between the Document Class Declaration and the \begin{document}, add the two lines we saw in the penultimate listitem ‘If you are using PDFLATEX (with …’ which allow the use of UTF-8 in PDFLATEX:

\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}

4. In the document environment, type the phrase Hello, World!:

...
\begin{document}
Hello, world!
\end{document}

5. Save the file and typeset it; you should get some output like this: