TeX and MS Windows

By Niall McMahon
November 2002

(Minor editing March 2006 and June 2011)

Introduction

According to Donald Knuth, the inventor of TeX, the system is "intended for the creation of beautiful books - and especially for books that contain a lot of mathematics".

Getting Started

My initial problem was that I didn't understand how TeX worked. The original TeX system built by Donald Knuth turns marked up documents (TeX files) into a formatted DVI (Device Independent format) file for viewing or conversion to another format. This is analogous to the relationship between HTML documents and web browsers.

TeX itself can be quite a challenge to use and is a relatively low-level language. It is, however, expandable and common TeX actions can be combined into macros. The most successful set of such macros is called LaTeX, pronounced Lay-Tech, and was designed by Leslie Lamport [1][2].

LaTeX seems to be the macro system of choice for TeX users.

So how do you use implement a TeX system running on MS Windows? Well first of all you need LaTex. There are many implementations of the LaTeX TeX macros. Most of these are for Unix/Linux based systems, but there are quite a few MS Windows based LaTeX binaries. This is unsurprising given that Knuth generously distributed TeX for nothing.

The best option is MIKTeX. The software is recommended by most LaTeX sites and version 2.5 is due in June 2006.

MIKTeX will take plain text files containing marked up information (again similar to HTML files) and transform the file into a DVI output. The input text files should be saved with a Ď.texí extension.

MIKTeX is not pretty to deal with for those used to MS graphical interfaces. Communication is through the command prompt and it can take some time to get the hang of it. And at the end of the process you realise a DVI file that may not be so portable (though you can view it with YAP, the DVI viewer bundled with MIKTeX).

So in practice you will require at least two other pieces of software:

The first piece of software is a LaTeX shell that acts as a graphical front end for MIKTeX. This is a text editor that communicates with the MIKTeX program. It may also highlight TeX keywords and provide other useful functions. It removes the need to interface with MIKTeX through the command prompt.

I use WinShell 2.2.1 as my MIKTeX front end. WinEdt is a bit better but it comes at a cost. Both these software packages seem to be rated highly.

Iíll go with WinShell for the moment.

The other piece of software you will need is a good document viewer. MIKTeX is bundled with a DVI to PostScript (ps) converter, but no ps viewer (the YAP viewer bundled with MIKTeX can only display DVI files). This is where you might need a ps/PDF viewer.

For this, get Ghostscript and GSView. The second program provides a front-end for Ghostscript in much the same way that Winshell is MIKTeXís front-end.

Winshell can be set-up to call GSView when displaying ps files (through Options | Program Calls).

It is also possible to configure Winshell to convert ps files to Adobeís Portable Document Format (PDF). The MIKTeX package contains several PDF generators located at c:\texmf\miktex\bin\. However the easiest way to create PDFs is to install a copy of Adobe Acrobat.

And thatís about it : all thatís left to do is to install MIKTeX, WinShell, and GSView/Ghostscript and then configure WinShell to use MIKTeX and GSView:

Start Winshell and proceed as follows:

  1. In the Options menu select Program Calls. Here you have to assign executable programs to the various WinShell functions.So, in the case of MIKTeX and GSView/Ghostscript, the program calls will be set-up as follows:
  2. Then select the User Defined tab and set Tool 1as follows:

And that's it.

Conclusion:

There is no such thing as a fully integrated graphical TeX system for MS Windows. Instead there is the text-based MIKTeX system that requires a shell system (such as WinShell) to interact graphically with the user, and one or more viewers to display the output.

Bibliography

The Inventors

Donald Knuth, Leslie Lamport.

Introductions and Manuals

What is TeX?Tex Users Group.

Micro introduction into LaTex, Math Department, Harvard.

Text Processing using LaTeX, Department of Engineering, Cambridge.

The Not So Short Introduction to LaTeX 2e: if you want to learn how to write your documents with LaTeX, this introduction is for you.

CTAN, the Comprehensive TeX Archive Network: the Comprehensive TeX Archive Network is the authoritative collection of materials related to the TeX typesetting system.

LaTex Setup Instructions

Introduction to the wonderful world of LaTeX

Downloads you will need:

  1. MIKTeX
  2. A LaTeX shell:
  3. Ghostscript/GSView

Additional Material

TeXing Your Thesis

How to implement an Umlaut with TeX

LaTeX Commands for Selected Special Symbols

Instructions on implementing accents with LaTex and other mark-up languages

Taper les accents sur les stations Sun

TeXnicCenter: ToolsCenter.org is the home of the world-famous open-source LaTeX shell.

http://eclipse-latex.sourceforge.net/: LaPsE is a LaTeX-Editor for the Eclipse IDE.

Inserting an Image into LaTex Documents

Although LaTex can import virtually any graphics format, providing the graphic as Encapsulated Postscript (EPS) makes things relatively easy [1].

How to convert an image file (.bmp, .jpg, .gif and so forth) into EPS

The solution that I came across, and that has worked well to date, is a free program called wmf2eps [2], a Windows Metafile (wmf) Converter for Windows. I'm sure there are other solutions available.

I was trying to include a landscaped graph that was generated in MS Excel. The steps I took to go from MS Excel to EPS were:

How to include the converted (EPS) images in the main LaTex document (documentname.tex):

The LaTex code in the main document will look like:

\begin{figure}
\centering
\includegraphics{graph}
\caption{Graph}
\end{figure}

Where the EPS graphic in this instance is called "graph.eps". The EPS file(s) must be located in the same directory as the LaTex document.

How to compile to PDF:

The recommended method is to:

  1. Convert EPS files to PDF using eps2pdf.exe
  2. Compile main document to PS by using laTex.exe, dvips.exe
  3. Compile main document to PDF using pdflaTex.exe

These programs are all bundled with MikTex. The important point to note about this procedure is that step 2 requires that the graphics are saved as EPS files while step 3 requires the graphics to be saved as PDF files. When LaTex is compiling the sample code above, it looks for "graph.eps" in step 2 and "graph.pdf" in step 3. "graph.pdf" is of course generated at step 1.

However, there's a problem:

eps2pdf.exe rotates the graph through 90 degrees into a portrait. Using the pdflatex.exe tool at step 3 displays this rotated graph, not the original landscape graph.

The first solution that I came across was to complete steps 1 and 2, and then to use GhostView (see main article) to convert the resulting PS (documentname.ps) to PDF. This displays the landscape graph correctly.

Unfortunately this solution yields a poor quality PDF with slightly fuzzy text. The PDF prints perfectly but is hard to look at on screen for any length of time.

The second and best solution (that I came across) was to complete steps 1 and 2, and then to use MikTex's dvipdfm.exe package to convert documentname.ps to documentname.pdf. This results in a very good quality PDF. It is, however, important to specify the size of the paper. Otherwise the text and images will be centred incorrectly in documentname.pdf . A4 is specified with the command line [3]:

C:\>dvipdfm -p a4 documentname.dvi

I ran this program through Windows 2000's MS-DOS prompt emulator and from the MIKTex "BIN" folder. In order to save time (in the short term) I copied the necessary files:

to the BIN folder.

There may be better ways around the portrait/landscape problem, but the steps outlined seem to work well.

To conclude: I strongly recommend that anybody importing graphics into LaTex for the first time read "Using imported graphics in LaTex 2e" [1]. Aside from the technical difficulties outlined above, you will also need to learn how to locate and size your graphics.

References

[1] "Using imported graphics in LaTex 2e"

This document is available in PostScript form as CTAN/info/epslatex.ps or in pdf form as CTAN/info/epslatex.pdf, where CTAN can be replaced by any of the following ctan (Comprehensive T E X Archive Network) sites and mirrors

England
ftp://ftp.tex.ac.uk/tex≠archive/

Deutschland

ftp://ftp.dante.de/tex≠archive/

Eastern U.S.

ftp://tug2.cs.umb.edu/tex≠archive/

Western U.S.

ftp://ftp.cdrom.com/pub/tex/ctan/

Australia

ftp://unsw.edu.au/tex≠archive/

Japan

ftp://ftp.riken.go.jp/pub/tex≠archive/

[2] WMF2EPS: A Windows Metafile Converter for Windows 95/98/ME, Windows NT4.0, 2000, XP

Author: Wolfgang Schulter EMail: wmf2eps@gmx.de Homepage: http://www.wmf2eps.de.vu (registration, infos, downloads, FAQ)

[3] See dvipdfm.pdf documentation at : "C:/TEXMF/doc/dvipdfm/dvipdfm.pdf" where C: is the drive you've saved MikTex to.

© Niall McMahon, Modelling and Scientific Computing Group, School of Computing, Dublin City University, 2002 - 2011.

Most material © Niall McMahon. See legals and disambiguation for more detail. Don't forget that opinions expressed here are not necessarily shared by others, including my employers.