# Writing a Simple LATEX Document

Let's examine the contents of a simple LaTeX file which has been used as a first example in this tutorial. First we must take a quick look at LaTeX syntax.

LaTeX files usually have a .tex extension. They consist of plain text interspersed with some LaTeX commands. The word command may sound scary. But don't worry. When you are beginning to write a LaTeX document, you really do not need to learn a new programming language or hundreds of commands. Basically you begin so that you get a simple template like the sample file below. Then start writing your own text inside the sections. The body text of paragraphs is simply plain text. Eventually you will need to write some commands but those you can usually copy and paste from other documents or templates.

When you want something special to happen, you must write a LaTeX command. The commands begin with a backslash and most of them want also parameters, which are enclosed in curly braces after the command. For example, write \section{My First Heading} to begin a new section of text with heading "My First Heading".

The names of the commands are quite intuitive. For example, if you look at the sample file below, you can easily guess that \title is the title of the document, \begin{abstract} starts the abstract text, and so on.

A comment line begins with a percent symbol (%) and continues to the end of the line.

That's all you need to know about the syntax now.

## LaTeX Source of Example 1

Note: Here we just want to analyse the commands and structure of a LaTeX file. That's why we have removed most of the text content of the paragraphs. You can get the same file with more text here.

\documentclass{article}
\usepackage{graphicx}

\begin{document}

\title{Introduction to \LaTeX{}}
\author{Author's Name}

\maketitle

\begin{abstract}
The abstract text goes here.
\end{abstract}

\section{Introduction}
Here is the text of your introduction.

$$\label{simple_equation} \alpha = \sqrt{ \beta }$$

\begin{figure}
\centering
\includegraphics[width=3.0in]{myfigure}
\caption{Simulation Results}
\label{simulationfigure}
\end{figure}

\section{Conclusion}

\end{document}


If you have installed MiKTeX and WinEdt or TeXnicCenter (see help for installation), the LaTeX processing of the above document is very simple. Open the .tex file in your editor. Then depending on the editor do the following:

• In WinEdt click "PDF TeXify" .
• In TeXnicCenter choose "LaTeX => PDF" from the list of Output Profiles: . Then click the "Build and view current file" button. 1

You will get a PDF document with all formatting and layout applied.

## Changing the Formatting

One of the main advantages of LaTeX is that it takes care of formatting the document. The user can concentrate on creating the information content of the document and he doesn't need to bother about fonts, page breaks, placing of figures, etc.

The so called document class defines the formatting of the document. LaTeX provides many standard document classes but you can also use other styles. For example, conferences often provide their own document classes that you can download. Changing the formatting of your document is very easy. You just change one line of text that specifies the document class to be used. For example, a standard article style is selected using the line \documentclass{article}. Here are some examples of different styles and the result as a pdf:

 \documentclass{article} A basic article style. \documentclass{report} A basic report style. \documentclass[journal]{IEEEtran} IEEE's style for submitting journal manuscripts. \documentclass{ActaOulu} University of Oulu PhD thesis style. \documentclass[global,twocolumn]{svjour} Springer (formerly Kluwer) journal style.

If you are looking for the LaTeX style files we have used in these examples, you can find links to them on our Getting Help page.

## Detailed Analysis of the Sample File

If you are interested in the details of the sample file, here you go:

\documentclass{article}
Specifies that we want to format our paper using a basic article style.
\usepackage{graphicx}
This is needed if we want to include figures. Packages are extensions of a basic LaTeX system and provide additional functionality. Packages are loaded using the \usepackage command.
\begin{document} ... \end{document}
The whole document is enclosed between these.
\title{Introduction to \LaTeX{}}
Here you write the title of the document. (The \LaTeX{} command prints the fancy logo.)
\author{Author's Name}
Name of the author.
\maketitle
Tell LaTeX to print the title, author name, etc. here.
\begin{abstract} ... \end{abstract}
Write the abstract between these commands.
Every section begins with this command. Write the heading of the section between the curly braces. Then after this command you can write the text of the section. When you want to start a new paragraph of text, write an empty line in the LaTeX source file.

\label{simple_equation}
\alpha = \sqrt{ \beta }
These commands insert an equation. Greek symbols are simply called with their name by inserting a backslash in front of them. \sqrt creates a square root function. The \label command gives a logical name for the equation. It can be used when creating cross references.