LaTeX Lessons

This area contains a collection of lessons containing sample files (which can be downloaded) and is intended for use in combination with the Graduate/Staff Guide to LaTeX.

Lesson One: Introduction

To download a LaTeX file in this lesson either copy and paste the latex code that follows into your editor of choice, or alternatively you can copy the latex file into your directory by right-clicking the download link below, and then select "Save Target As", followed by clicking on OK. If you like you can create a folder in your H: drive to save this file e.g. H:\latex-lesson1\

\documentclass[12pt]{article}
\begin{document}
In here goes different styles of text, tables, arrays, pictures, etc. etc.
\end{document}

Download: latsam1.tex

Editing your LaTeX file

LaTeX files are plaintext files, so any text editor should be suitable for editing. Windows comes with a simple text editor called WordPad, but you can also use WinEdt, Tinn-r, TeXnicCenter, etc. Notepad, which also comes with Windows, can also be used but is not recommended if editing files created on a Unix/Linux system because of carriage-return differences.

Processing your LaTeX file

As you now have a LaTeX file in your directory, one still has to process it. Open a console (command prompt) by:

  1. Click Start Menu
  2. Click the "Run" icon on the bottom right of the menu (see Figure 1.1).
  3. In the box that pops up, type "cmd" without the quotes, and click "OK" (see Figure 1.2).
  4. Navigate to where you saved the lasam1.tex file with the following commands, pressing the enter key after each command:
h:
cd latex-lesson1

Note:all commands will be typed in the same console window (See Figure 1.3).

To compile the document, enter the command:

latex latsam1.tex

> latex latsam1.tex
Figure 1.3 - Console

Start -> Run
Figure 1.1 - Start Menu

cmd
Figure 1.2 - Run dialog

Processing information will appear on the window. Unless an error message appears, you can in general just ignore it. If there are errors, you will need to correct your document and re-run the latex command. If there are labeled items in your document (e.g. figures, table or equations), then you will need to run the latex command a second time.

Next the resulting .dvi file needs to be converted into a postscript .ps file with the command:

dvips latsam1

More processing information will appear which you can again ignore. Create a PDF from the LaTeX document by typing:

ps2pdf latsam1.ps

You can now view the PDF with the command:

start latsam1.pdf

A new window will appear which will show you the visual output of your LaTeX file which can be sent to the printers.

The steps to remember are:

  1. latex the file:

    latex file_name.tex
  2. dvips the file:

    dvips file_name
  3. ps2pdf the file:

    ps2pdf file_name.ps

Notes:

  • Spaces are ignored by LaTeX, see later lesson as to how to add spaces.
  • Single carriage returns are ignored in LaTeX, double carriage returns are regarded as being a new paragraph, to create a new line use either \\ or \newline.
  • Latex documents that include PDF images need to be compiled with the command pdflatex instead of the latex command.

This concludes your first lesson on using LaTeX.


Next >>