Intro | First attempt | Text | References | Figures | Maths | Source Code | Theorems
A very short paper in LaTeX would look something like this:
\documentclass{scrartcl} \usepackage[UKenglish]{babel} \usepackage[T1]{fontenc} \usepackage[utf8x]{inputenc} \title{\LaTeX{} test file} \author{HG Schaathun} \begin{document} \maketitle \section{Introduction} This article is a test to see that I am able to make a LaTeX document at all. \subsection{Outline} It feels a bit stupid to make an outline, as the test file is so sure. \section{Background} \LaTeX{} is a powerful typesetting tools, and it is very easy to produce professional-looking output. For maths there is no serious alternative. \end{document}
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
).
\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.
\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.
\title
and \author
define the obvious meta-data, which is used by the
\maketitle
\begin{document}
and \end{document}
brackets the contents of the document.
\maketitle
makes a header including title, author,
and date.
\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.
\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.