Getting Started in LaTeX

MikTeX Installation

If you're starting from scratch then this is a three step process.

Step 1. Download a small wizard program called "setup.exe". This program is available from CTAN at:

www.ctan.org/tex-archive/systems/win32/miktex/setup

Do not go to sourceforge.net (some links will try to direct you there) to download the large file named "basic-miktex-*****.exe". It's better (in my opinion) to let the wizard manage the large download from one of the many CTAN mirror sites.

Download the setup program to a convenient location (e.g. in a folder called "latex setup" on the Desktop).

Step 2. Run "setup.exe". The first screen gives you a choice between "Download" and "Install". We want to download the MikTeX packages to a local package repository. You can choose between the "Basic" and "Complete" installations. If you use the basic installation then it's easy to add packages later from the internet using the MikTeX Update Wizard (a part of the program installation).

When you run the program it will ask you to select one of the many mirror sites. When I did the download I kept getting file download errors. Keep running the setup wizard and you will eventually get the entire set of files.

If you plan to keep the package repository on your hard drive, move it to a logical location (e.g. "C:\MikTeX Packages" instead of on your Desktop). Then after you've installed MikTeX you can point it to that directory using the MikTeX Package Manager program.

Step 3. Run "setup.exe" again to install MikTeX from the local package repository. The installer will ask you several questions.

  • Basic or Complete Package? I chose the "basic", since MikTeX will install additional packages as you need them.
  • All Users or Local User. Your choice. This affects whether the software is visible to other users who may have an account on your machine.
  • Installation Folder. By default MikTeX will try to install itself in a subdirectory of "C:\Program Files", which is a change from previous versions. I have read elasewhere, however, that some high end functions such as tex4ht (used to convert LaTeX files to html) do not like spaces in paths. So to be safe I always change to a pathless directory, say "C:\ProgramFiles\texmf" (without the space). A spaceless ProgramFiles directory can also be used later for other installations such as PHP, Python, mySQL and so on.
  • Change to Letter Paper, unless of course you live in Europe, or the Middle East, or wherever.

The program installation will take a few minutes. When it's finished, check that it has added (prepended, in fact) the directory "C:\ProgramFiles\texmf\mixtex\bin" to your PATH variable. To check this, open a command prompt and type "PATH" followed by a return. If "C:\texmf\mixtex\bin" is not in your path, then go to Control Panel-System-Advanced (in Windows XP), click on the Environment Variables tab, and then edit the PATH. You must close and reopen the cmd prompt to see the change.

Create A Local TEXMF Tree. This is where you will store add-on's which are not a part of MikTeX. You might want to create, for example, a personal style file "mystyles.sty" which you can place here

  • Create a directory called "C:\ProgramFiles\localtexmf" whose contents and directory structure mimic that of MikTeX. Our style file, for example, would be placed in "C:\ProgramFiles\localtexmf\tex\latex".
  • Run the program MikTeX 2.6-Settings.
  • Select the tab called "Roots".
     

     

  • Click on "Add" and browse to the directory you created. Then click on "Apply" to refresh the file names database.

Any time that you want to add a resource (such as a personal style file or a logo), place it in this directory and then refresh the FNDB (under the "General" tab).

GhostScript and GSView

Next we must install Ghostscript and GSView. Ghostscript is an interpreter for converting postscript to various other formats. This includes printing on a pcl printer (i.e. the usual kind) and saving as pdf. GSView is the associated viewer.

You can visit the Ghostscript home page to read about it, but to get the program you'll end up eventually at the University of Wisconsin mirror. So go directly to http://pages.cs.wisc.edu/~ghost/ and download the latest version for Win32. The file name will be something similar to gs***w32.exe, a self extracting installer for Windows.

Obtain GSView from the same site. The file to download is called gsv**w32.exe.

Both installations are straightforward. For both of these I also removed the space from "Program Files" (i.e. C:\ProgramFiles\gs and C:\ProgramFiles\Ghostgum)

Install Ghostscript first, followed by GSView. When primpted, you definitely must download the Ghostscript fonts. These are a collection of Adobe Type 1 outline fonts, including the Type 1 versions of the LaTeX "computer modern" fonts.

WinShell

Be sure that you install WinShell after the other steps above.

You can get the most recent version from the author's site here or from CTAN here. The file you want is called WinShell**.exe and it is another self extracting installer. Download and run this file to install the program (the defaults work fine). When the install is finished you can run the program.

There is one very important change which you should make to the default installation. Go to Options-Program Calls, and scroll to the entry for DVI->PS. Where it says cmd line, change the -D600 to -Ppdf, so the entire line should read

-Ppdf "%s.dvi"

This change tells dvips to use the Adobe Type 1 fonts mentioned above, rather than the default bitmapped "pk" fonts. Using the pk fonts results in awful looking, blurry pdf's.

(update: I've been told this feature has been fixed, so this may not be necessary. It will be obvious if it's wrong.)

Testing the Installation

Open a new document in WinShell, and type the following:

\documentclass{article}
\begin{document}
Hello world
\end{document}

Save the document (by default the extension should be *.tex, which is what you want). Now press the buttons for

  • LaTeX - to create a dvi file
  • DVIView - to view the dvi file (the actual program is called "yap"). We will rarely use this.
  • DVIPS - converts the dvi file to postscript
  • GSView - to view the postscript file
  • pdfTeX - takes the LaTeX file straight to pdf
  • PDF - should open Adobe Reader. You might decide to change this to use GSView instead, in order to keep the file open while performing successive edits with pdfLaTeX. I highly recommend this.

When you make changes to your document you don't have to press all these buttons! In particular, you don't have to run LaTeX and pdfLaTeX on the same document. Usually it's either one or the other, depending on any graphics which you have included. Furthermore, once you have opened GSView, you can keep the program open and the viewer will automatically update as the postscript (or pdf) file is changed.

Try changing the file to this:

\documentclass{article}
\begin{document}
Hello world. Here is some math:
$$
\int\frac{1}{x}\,dx = \ln|x|+C
$$
\end{document} 

Press the "DVIPS" button, and WinShell will automatically save the tex file, run LaTeX and then DVIPS. Maximize GSView (assuming the program is still running) and look at the result. Don't worry if you don't understand what all these LaTeX commands do. For the moment we're just trying to verify that LaTeX and WinShell are running correctly.

Testing the Package Manager

Add a package to your file to see what happens. If the package is not already installed then you will be prompted by MikTeX to install it automatically:

\documentclass{article}
\usepackage{booktabs.sty}
\usepackage{color.sty}

\begin{document}
Hello world. Here is some math:
$$
\int\frac{1}{x}\,dx = \ln|x|+C
$$
\end{document} 

Testing the Local TEXMF Directory

If you're not using the installation CD, then download my file wise.sty and place it in the path "C:\localtexmf\tex\latex". This file is used by several of the samples on this site, and installing it gives us a chance to check that the localtexmf directory is functioning properly. Don't forget to update the file names database.

Now change the file again to read:

\documentclass{article}
\usepackage{wise}
\begin{document}
Hello world. Here is some more math:
$$
\dom f = \{ x\in\R \mid x \ne 3 \}
$$
\end{document} 

Re-TeX the file to make sure MikTeX found the style file. Note that "\dom" and "\R" are both aliases from wise.sty, so without that file this code would not compile.

Congratulations! You have successfully installed LaTeX.