A LaTeX how-to (for windows)

There was a nice post on Good Math, Bad Math about Donald Knuth’s classic scientific typesetting software, TeX. In the comments section, a number of people asked about how to learn to use the software. I thought I’d write a little introduction on how to install and use LaTeX, with a nice sample file to play with. Since I often have to do this for my students anyway, it’ll be nice to have it all in one place.

LaTeX is, essentially, a specialized programming language that is tailored towards producing professional-quality electronic documents. A LaTeX file (.tex extension) is a text file which contains the text of the document, along with programming ‘code’ that specifies special structures, like tables, quotations, references and, of course, equations.

LaTeX is a compiled language, like C++ or Fortran. The programming file is run through a compiler which converts it into its final form. In the case of C++ or Fortran, the final form is an executable program, while in the case of LaTeX, the result is a formatted and printable document.

To use LaTeX in Windows, two tools are essential, and a third is highly recommended. All are free! You should download and install each of the tools below in the order presented:

  1. Ghostscript and GSview. The most common format for putting figures in LaTeX documents is to use Postscript or encapsulated Postscript format. Ghostscript is a piece of software used by the LaTeX compiler to convert and display these Postscript files. GSview is a viewer that allows viewing of postscript files. Both pieces of software can be found at this link. The most recent version of Ghostscript should be downloaded and installed, followed by the most recent version of GSView.
  2. MiKTeX. Now you’re ready for the main installation! Download the installer at this link; in principle you only need the basic MiKTeX installer. Personally, I prefer the complete download, which includes pretty much every ‘add-on’ you might ever need. The last time I checked, it took about 500 MB. You’ll need to run the installer twice; once to download the package, once to install it.
  3. WinShell. You can use any text-manipulating software to write your LaTeX file, but numerous nice text editors exist which make using MiKTeX easy. I personally recommend WinShell, a nice piece of freeware that I’ve been using for nearly a decade! (Even though it’s freeware, I recommend sending a little donation to the author if you find it useful.) There’s a single download and installation involved with WinShell. Once it’s set up, you should be ready to go!

To edit and compile a file, simply open a .tex file in WinShell and click the ‘LaTeX’ button twice (once to compile references, once more to number them) to compile. Then click the ‘dvi’ button to open the ‘yap’ viewer to view and print the .dvi file.

What’s that, you say? You don’t have a LaTeX file to open, and that’s why you’re here in the first place? I’ll end this article with a the text of a complete LaTeX file you can cut, paste and put into action! (I’d make it a separate download, but wordpress security restrictions make that impossible!)


% every LaTeX document should start with documentclass:
% ‘article’ uses formatting for a journal article

% here we add any nonstandard ‘style’ packages we want to use with our file
% in this case, we use the ‘graphics’ package, which allows the addition of figures

\begin{document} % start of the document, ended with the ‘end’ document!

% ‘newcommand’ can be used to make special custom commands.
% Here, we define ‘\cm’ as a centimeter unit for equations, and ‘\ii’ as a roman imaginary i
\newcommand{\cm}{\mbox{ cm}}
\newcommand{\ii}{{\rm i}}

\title{Title of your document}

\author{author(s) here!}
\date{January 13, 2008} % comment out this \date line in order to default to today’s date
\maketitle % this line required to actually generate the title, author, date

This is a simple document to be used as a playground for would-be \LaTeX users!

\section{Introduction} % sections will be automatically numbered

\label{sec:intro} % use \label to ‘tag’ sections so they can be referred to later…

This is a simple \LaTeX document to illustrate almost all of the major features and formats of the language. We can illustrate some of the following:
\item Sections
\item Equations
\item Bibliographies
\item Labels
We will start with equations, which are described in Sec.~\ref{sec:equations}!



Here is a sample equation which, incidentally, is correct:
\int_{-\infty}^\infty \frac{e^{\ii kx}}{x^2+a}dx = \pi \frac{e^{-k\sqrt{a}}}{a}.
We have assumed for this result that $k\geq 0$ and $a>0$. This is a well-known result which can be derived using complex analysis techniques. Equation (\ref{complex}) contains many of the common structures to be used in equations, namely exponents, integrals, fractions, and square roots. We can also use multiple equations in a row with a special structure:
\cos(x+\pi)&=&-\cos(x), \label{no1}\\ % && are used to align, \\ are used to start next line
\sin(x+\pi)&=&-\sin(x), \label{no2}\\
\ln (ab)&=& \ln(a)+\ln(b). \label{no3}
We can use labels on individual members of this equation array. For instance, Eq.~(\ref{no2}) refers to the sine equation in the array.

It can also be helpful to write equations without any equation numbers at all. For instance,
\left[\begin{array}{ll} 1 & 0 \\ 0 & 2 \end{array}\right]\left[\begin{array}{l} 1 \\ 1 \end{array}\right] = \left[\begin{array}{l} 1 \\ 2 \end{array}\right].

\section{Other stuff}


What else can you do? Well, there’s plenty of information in Refs.~\cite{ll:latex} and \cite{fm:companion}. Basic referencing is covered in this tex file, but the additional program BibTeX is extremely useful for building a reference database. I don’t cover graphics here, but there’s a little mention of them at the end of the \LaTeX document…


I would like to thank anyone who had the patience to read through this tex file this far!


\bibitem{ll:latex} L.\ Lamport, \emph{LaTeX User’s Guide} (Addison-Wesley, 1994, 2nd edition).

\bibitem{fm:companion} F.\ Mittelbach, M.\ Goossens, J.\ Braams, D.\ Carlisle and C.\ Rowley, \emph{The LaTeX Companion} (Addison-Wesley, 2004, 2nd edition).



incidentally, you can put anything you want after the “\end{document}” line. This is pretty useful for saving structures that you don’t want to use right away but want to remember how to implement properly!

With the ‘graphics’ package, you can use \includegraphics[scale=.8]{fig.eps} to put a figure anywhere in your document, scaled by the factor in square brackets!

This entry was posted in Mathematics, Physics and tagged . Bookmark the permalink.

7 Responses to A LaTeX how-to (for windows)

  1. Blake Stacey says:

    Excellent bit of public service!

  2. Personal Demon says:

    For Mac OS X users, I recommend TexShop. TeXShop wraps a unix-based LaTeX compiler and a TeX-aware text editor all into a really nice user interface that includes easy access to other TeX-related tools like BibTeX. TeXShop takes advantage of the Mac’s built-in support of PostScript to do nifty things like directly generate PDFs (without going through GhostScript and PDFLaTeX) and directly importing PDF images into your documents.

  3. Blake: Thanks!

    Demon: Thanks for adding that. I’m glad to have a complete description, for users of all systems, of how to install things. Oh, and thanks for not saying (too much) how Macs doing it all so much better! 🙂

    I should also mention that there is a Powerpoint add-in for LaTeX, for both Mac and PC, called TexPoint. It allows one to write LaTeX equations which are converted into bitmaps in Powerpoint. Unfortunately, this one has to be purchased ($30).

  4. Personal Demon says:

    Another neat Mac tool is a tiny free application called Latex Equation Editor that translates LaTeX code into PDF images of the equations, which you can then drag-and-drop into presentation software like Apple Keynote.

  5. Amr says:

    Is there any free program that works similar to texpoint for Powerpoint 2007.

  6. Hi Amr: I’m not sure of any free program like that, yet; then again, I haven’t made the jump to Powerpoint 2007 yet! (I like to give new MS software about a year to sort out all the problems.)

  7. Toy says:

    Thank you. This has been very helpful to me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.