# Getting Started: Creating a Basic LaTeX Document

Step-by-Step Guide

Here are some easy instructions for creating your first LaTeX document.

1. Opening a New Document

Open TeXnicCenter and click on File > New. This will load a blank document. Select File > Save As and give your file a suitable name. I will use ‘test’.

You’ll see that this file is a .tex file (test.tex). The TEX file is the one you use to write and edit your document.

2. Preamble

Document Class

Before you can start writing, you need to specify exactly what type of document you want to create. This is done in the preamble.

LaTeX supports several different document types, such as article, report, book, beamer, etc. These are called document classes.

All LaTeX commands begin with a backslash ‘\‘ and are followed by special characters or letters. So to specify your type of document, the command is:

\documentclass[options]{class}

See section 1.4 of The Not So Short Introduction to LaTeX for basic information and section 1.6.1 for detailed information about all the options.

Packages

As I’ve mentioned in a previous post, add-on features for the LaTeX system are known as packages. If, for example, you want to use the semtrans package to display special transliteration characters in your document, you need to state that in the preamble.

The general command for specifying the package you want to use is:

\usepackage[options]{package}

Sometimes, there won’t be any options to specify (like with semtrans). You can also include a whole list of packages you want to use in the preamble, but you have to use a new command each time. For example:

\documentclass{report}
\usepackage{babel}
\usepackage{url}

3. Body Text

Now to begin the text you want to write, you start with the command:

\begin{document}

and end with the command:

\end{document}

This \end{document} command should be the very last thing in your document.  Anything that comes after it will be ignored by LaTeX.

4. Example Document

You are now ready to write your first document. Type the following into your test.tex file in TeXnicCenter (I have specified an article of 10pt type on A4 paper):

\documentclass[10pt,a4paper]{article}

\begin{document}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque ut ante pulvinar mauris interdum euismod. Aliquam dui tellus, blandit at, tincidunt ac, feugiat id, nibh.

Phasellus id metus. Aliquam erat volutpat. Donec fringilla. Donec euismod, velit quis adipiscing hendrerit, enim eros tempor mi, a hendrerit ipsum eros eget leo.
\end{document}

Save the document. Note that to start a new paragraph, you just need to leave an empty line in the text.

5. Generating a PDF

Step 1: On the toolbar, you’ll see a drop-down option. Select LaTeX => PDF. See the picture on the right.

Step 2: Click on Build > Current File > Build. The shortcut is ctrl+F7 and there is also an icon on the toolbar.

You’ll see the document compiling if you have the output bar open. If not, click on View > Output Bar. If there are any errors in your document, you will see them listed in the output bar.

Step 3: To view your PDF, click on Build > View Output. The shortcut is F5 and there is also an icon on the toolbar.

If you want to combine steps 2 and 3, you can just click on Build > Build and View. The shortcut is ctrl+shift+F5 and there is an icon on the toolbar.

N.B. If you add more text to your document, save it, and want to generate the PDF again, you must close the test.pdf file first. Otherwise it won’t work.

An alternative to using PDFs is viewing your output as a DVI file. To do this, start at step 1 again, but select LaTeX => DVI, then steps 2 and 3 are the same.

The advantage of using a DVI file during the draft stage is that you don’t have to keep closing it before generating a new version again.

Here is the output PDF of the document: test.pdf

6. A Note on File Types

If you now have a look at the folder where you saved test.tex, you’ll see test.pdf there as well.

But there are a whole lot of other files too, such as:

test.aux
test.bbl
test.blg
test.log

Just ignore these.

If you want to edit your text, click on the TEX file, test.tex. If you want to re-open the PDF or DVI files, click on test.pdf or test.dvi.