\documentclass[a4paper, 11pt]{article}
\title{\LaTeX{} courses\\ Course 2 : A real-world document}
\author{Isabelle HURBAIN \\ isabelle.hurbain@free.fr}
\begin{document}
\maketitle
\tableofcontents
\section{The different types of documents}

In course 1, we made a "Hello, world" document, with only a title and a "Hello, world". We will now see how to make a real document.

There are mainly three wide-used classes of documents: book, report, and article. There are two other classes, namely slides and letters, but we won't talk about them yet.

\verb+article+ is for articles in journals, short reports, programs documentation...

\verb+report+ is for reports containing several chapters or parts.

\verb+book+ is for real books.

The rule I use (it's not a general rule, just what I do ;-) ) is to use the article class below 6-8 pages, report between 8 and 50 pages, and book for more than 50 pages. Needless to say, I pratically never use book :-)

\section{Accents and linebreaks}

When I first began to use \LaTeX{}, the first things I wondered were "But why do my accents do not display?" and "How do I break a line?"

You can obtain accents by adding the line
\begin{verbatim}
\usepackage[latin1]{inputenc}
\end{verbatim}
in the preamble of your document.

And to break a line, you will have to break the line twice in your source file, like this:

\begin{verbatim}
This is a line break
that do not works.

But this one works.

Here is the proof.
\end{verbatim}

To edit a document in an another language that english, you may also want to use the babel package. Babel manages the redifinitions of titles (to get Chapitre instead of Chapter in a french document for example) and some typographical rules (like the beginning of section tabulation, existing in french but not in english).

To use the babel package, add to your preamble
\begin{verbatim}
\usepackage[language]{babel}
\end{verbatim}
where \verb+language+ is the language of your document. For example, you wille have
\begin{verbatim}
\usepackage[french]{babel}
\end{verbatim}
in french and
\begin{verbatim}
\usepackage[german]{babel}
\end{verbatim}
in german.

\section{Real-world document HOWTO}
A generic document would contain a title, a table of contents, an introduction, several sections, a conclusion, and appendixes. The parts can contain subsections.

\subsection{The title}
The title is defined for the whole document. Its parameters are given in the document's preamble (before \verb+\begin{document}+) with the commands \verb+\title+, \verb+\author+ and \verb+\date+. These commands take an unique argument (between curly braces \verb+{}+).

As you must have guessed, \verb+\title+ defines the title, \verb+\author+ defines the author (in most cases, that would be yourself), and \verb+\date+ defines the date of writing or of publishing of the document.

If \verb+\date+ is omitted, the date will be the one of the last compilation. To avoid this behaviour, you can use \verb+\date{}+ to define a void date.

Once the parameters are in the preamble, you just have to insert a \verb+\maketitle+ following \verb+\begin{document}+ to display the title.

The title will have an whole page for classes \verb+report+ and  \verb+book+, and will be in the beginning of the first page for an  \verb+article+.

\subsection{The sectionning commands}
There are 6 sectionning commands in an article (in hierarchical order):

\begin{itemize}
\item \verb+\part+
\item \verb+\section+
\item \verb+\subsection+
\item \verb+\subsubsection+
\item \verb+\paragraph+
\item \verb+\subparagraph+
\end{itemize}

Report and book also have a \verb+\chapter+ command, between part and section.

These commands take one argument, the title of the sectionning item. It can also take an optional argument (between square brackets \verb+[]+). This optional argument defines an alternative title, for example for the table of contents.

These commands manage the style of the title and its numbering. So for example, if you have a section foo before a section bar and if you decide that bar should be indeed before foo, just move your section. \LaTeX{} takes care of the numbering of your sections (and following subsections) and of the update of the table of contents. Fantastic, isn't it?

\subsection{The table of contents}
The table of contents can be obtained with \verb+\tableofcontents+. It displays, in order of apparition, a title and a page number for each sectionning command lesser than \verb+tocdepth+. \verb+tocdepth+ is an intern variable, corresponding to these values :

\begin{table}[!h]
\begin{center}
\begin{tabular}{|c|c||c|c|}
\hline
\verb+\part+ (book and report) & -1 & \verb+\part+ (article) & 0 \\
\hline
\verb+\chapter+ (book and report) & 0 & \verb+\section+ & 1 \\
\hline
\verb+\subsection+ & 2 & \verb+\subsubsection+ & 3 \\
\hline
\verb+\paragraph+ & 4 & \verb+\subparagraph+ & 5 \\
\hline
\end{tabular}
\end{center}
\end{table}

The depth of the table of contents can be changed with \verb+\setcounter{tocdepth}{n}+ where n is the level of depth you want.

To update a table of contents after you modified something in the sectioning, you'll have to run \verb+latex+ twice on you document. Why? In fact, \LaTeX{} maintains a separate file for the table of contents, the \verb+.toc+ file. At the first compilation, this file is updated, at the second, the \verb+.dvi+ document is updated.

\subsection{The starred commands}
The so-called starred commands are \verb+\chapter*+, \verb+\section*+, etc. They are sectioning commands, but special ones. They do not update the table of contents, they are not numerotated, and they do not update the chapter, section, etc. counter.

So what's their interest? They are indeed mainly used for introduction and conclusion. The introduction, for example, is rarely called "Chapter 1 - Introduction" in a book.

You might want, however, that your introduction is not numerotated (so you would use the starred command) but appears in the table of contents (so you wouldn't).

To achieve this, you may do something like this:
\begin{verbatim}
\chapter*{Introduction}
\addcontentsline{toc}{chapter}{\numberline{}Introduction}
\end{verbatim}

The \verb+\chapter*{Introduction}+ creates the title of the introduction, with no numerotation as it was desired.

The \verb+\addcontentsline{toc}{chapter}{\numberline{}Introduction}+ add a line in the table of contents to create the Introduction entry.

The same kind of trick can be used for the conclusion.

\subsection{The appendixes}

To define that you left the plain document and that you are now writing appendixes, just use the command \verb+\appendix+. This sets the sections counters to 0 and change the numbering system to alpha. It also redefines, for book and report, the title of chapters from "Chapter" to "Appendix". So if you create a chapter foo after the command \verb+\appendix+, you will have "Appendix A  foo" as a title instead of "Chapter n+1  foo".

The appendixes are also entered in the table of contents.

\section{Exercise}
Now you have all instructions to create a basic document. Try to create one, experiment all the command described here, enjoy ;-)

Do not try to modify the aspect of what you get right now. Remember, \LaTeX{} uses a content-oriented markup (a logical markup), not a form-oriented markup. If you want to do a chapter, do not put it as a part because you feel it is nicer - we will see how to modify the chapter definition if you need it. But, if the logical structure of your document requires a chapter, put a \verb+\chapter+. It will also have the advantage to make you think of your document's structure more deeply, and thus making clearer documents. And it highly simplifies the maintenance of your work.

\section{In the next course}

In the next course we will speak about tables and images and how to integrate them into a document.
\end{document}