Intro | First attempt | Text | References | Figures | Maths | Source Code | Theorems

Your first LaTeX article

A simple example

A very short paper in LaTeX would look something like this:


  \title{\LaTeX{} test file}
  \author{HG Schaathun}



    This article is a test to see that I am able to make
    a LaTeX document at all.


    It feels a bit stupid to make an outline,
    as the test file is so sure.

    \LaTeX{} is a powerful typesetting tools, and it is very
    easy to produce professional-looking output.
    For maths there is no serious alternative.


Most of the structure is probably self-explanatory, and you can probably use LaTeX without understanding the rest. However, the reference below will be useful as you proceed to more advanced uses of the system.

Before I explain the file, I suggest that you test it. Put the code in a file called test.tex, and run pdflatex test (in a Unix shell) to compile. This creates test.pdf which you can view in kpdf, evince, or acrobat reader. It also creates an auxiliary file and a log file. Sometimes latex will tell you that you need to rerun it to get cross-references right; in this case the auxiliary file will be read as well as the tex file to make the crossreferences.

All commands in LaTeX start with a backslash (\). Parameters are given in curly braces after the command name, and optional parameters are given in brackets. So \usepackage[UKenglish]{babel} is a command, where \usepackage takes one mandatory (babel) and one optinal parameter (UKenglish).

  1. \documentclass{scrartcl} specifies the class (or layout style) of the document. The scrartcl gives a more European-looking article than the article class, which have very heavy headers and titles. Many journals and conferences provide there own class files, and you can easily change the layout by replacing the class name. If you make a dissertation, you can use the cssurrey class.
  2. \usepackage loads additional packages to give extra features or modify existing ones. The three packages in the example should be included if you write multi-lingual documents and your system uses UTF-8. You may omit them, if you write pure 7-bit ASCII. You can also change the language specification (UKenglish), or add more languages.
  3. \title and \author define the obvious meta-data, which is used by the \maketitle
  4. \begin{document} and \end{document} brackets the contents of the document.
  5. \maketitle makes a header including title, author, and date.
  6. \section and \subsection (as well as \subsubsection, \paragraph, and \subparagraph) creates section headers at different levels. If you make reports/books (e.g. the scrbook or cssurrey classes), there will also be a \chapter command.
  7. \LaTeX sets the LaTeX logo. The empty braces is not really an argument, it is an empty token which ensures that the following whitespace is output and not swallowed by the command.

The rest of the text is output as it is. The segment before \begin{document} is known as the preamble.