|
26 September 2003 Industrial-Strength Type Setting Made Easy Sheldon, Often an amateur scientist has the need to prepare a very professional paper, or research report. Scientific papers have requirements that the ordinary writer never needs such as nicely formated equations, graphs, tables, and having these objects numbered sequentially for ready reference in the text. Because most of these requirements are extraordinary, word processors, especially WYSIWYG editors like MSWord, have no means to make such objects except through cutting and pasting objects from other programs. The result is a scientific report that, indeed, looks like a person has pasted it up from multiple sources. During the past summer I wrote several drafts of my book, Experiments and Studies, using a LaTeX-like typesetting system for the Windows 9x/2000 environment. The package is named MiKTeX, and is available from www.miktex.org. It is a shareware package, and registration is only $13. I found it to work beyond satisfactory. It is, quite simply, the finest formatting system I have ever used. To obtain MiKTeX you will need to download the MiKTeX distribution from "www.miktex.org". Since this download involves some 540Mbytes of files you should do the download on a frame relay or a T-1 line connection. Alternatively, you can purchase a CD-ROM from miktex.org. The download includes a "setup.exe" file to set up the package, and unpack its various cabinets. You may do a custom set-up, but I advise using one of three pre-programmed set-up configurations. So far, I have found that the "medium" configuration does everything I could wish for. This saves about 400mbytes of space over the "full" installation. Two other pieces of shareware that are needed for a complete system are GhostScript, which is a program for PostScript documents, and GSView, which uses GhostScript to view PS documents on your computer. GSview is a graphical interface for Ghostscript under MS-Windows, OS/2 and Unix. Ghostscript is an interpreter for the PostScript page description language used by laser printers. For documents following the Adobe PostScript Document Structuring Conventions, GSview allows selected pages to be viewed or printed. GSview requires Ghostscript 7.04 - 8.99 so be certain to download versions that work together. All of these programs setup very quickly and easily. I advise always using the default setup. Get GhostScript at http://www.cs.wisc.edu/~ghost/, and GSView at http://www.cs.wisc.edu/~ghost/gsview/get44.htm. The Latex Processor MiKTeX is just a program that follows Leslie Lamport's LaTeX language specification, which in turn is a high level language that implements Donald Knuth's TeX type setting standard. The LaTeX process seems cumbersome at first, but it is actually very flexible, and allows a person incredible control over formatting a document and building portable files. The user puts all of their text, including the LaTeX formatting commands into a text file (TEX). The program "latex" reads this file and produces a device independent file, a DVI file, with a file extension of "dvi." MiKTeX includes a DVI viewer which allows you to view or print the resulting file. This is the end of the story if all a person needs is to print a clean copy of a report. However, since most people do not have a DVI viewer, it is more sensible to make a PDF file for portable reading, or make a PS file for portable printing. MiKTeX includes a program named "pdflatex" to turn the TEX file into a PDF, or the program "dvips" to turn the TEX file into a PostScript file. All of these programs are run from the MSCommand prompt (available from your "Start" menu, this produces an MS-DOS enviroment in one window.). One word of caution here is that including photographs and drawings is badly described in the books on LaTeX. The only way I have found to include photographs in a LaTeX document is to include them as encapsulated postscript files (EPS). The DVI and PDF documents will not display the eps graphics on my computer screen because of some display driver deficiency, and some of the SAS users may encounter this same problem. However, the postscript file made with "dvips" will have the images in it correctly and they will print properly on a postscript printer or view properly through the GSViewer. I actually built my book using the Adobe Distiller and had it turn the postscript file into a PDF. Most people needn't go this route. LaTeX as a markup language MikTex is unlike the editors that most SAS members probably deal with. For instance, It does not include a text editor. The user makes use of his or her own text editor.This should be an editor that does not put embedded editing characters into the files, but is rather produces a straight ASCII file. I use WORDPAD and save all of my documents as "text only." One annoying thing about WORDPAD is that it names your text file with a "txt" extension the first time you save the file, and you'll need to rename it with a "tex" extension, "tex" files are what MiKTeX expects as input by default. All editing commands are typed as text into the TEX file. You precede each command with a backslash character (\) to escape to command mode, followed with a command, followed by the command argument enclosed in french brackets. In other words LaTeX is a markup language, something like HTML, except that HTML uses the <> braces for its escape character and argument delimiter. LaTeX also resembles a programming language like 'C' in that it allows you to block an environment, such as an equation environment, a list environment, or one of many others. Just like HTML, each TEX file begins with a preamble and then encloses the document within a "document" environment. The preamble defines the class of the document of which LaTeX has about four; letters, articles, reports, and books. The body of the document is enclosed in an environment as \begin{document} All your text and commands go here... \end{document} For example, to make a footnote, and footnotes are embedded in the text right where you expect to find them in the final document, use the command \footnote{This example footnote}. Likewise to emphasize a bit of text, say a latin phrase, do so with \emph{ipso facto}. Label sections with \section{Section heading}, and put subsections under a section with \subsection{subheading} and so forth. Formulae are very easy to do. In fact, formulae are so common in scientific work that LaTeX has a math mode which you enter with either a "$" character (inline math} or a math environment command. Blocked environments have to have an end as well as a beginning. For example, the inline command $int_{-\infty}^{+\infty}\delta(x)dx=1$ will produce a beautifully formated integral from minus infinity to plus infinity of the delta function evaluated at x equals 1 that fits right in line with the rest of the text. The two "$" characters switch the inline math mode first on then off. The tabular environment enables a person to build very sophisticated tables within the text. For instance, I can build a 2x2 table of risk factors and outcomes with the tabular environment like this, \begin{table}[h] \begin{center} \begin{tabular}{|l|c|c|} \hline Factor/Outcome& Got ill& Did not \\\hline Consumed Oil& 18& 16 \\\hline Did not& 11& 48 \\\hline \end{tabular} \end{center} \caption{Toxic Oil Syndrome in a Madrid hospital} \end{table} The '&' character produces tabs in this environment. The command {|l|c|c|} defines three columns which are left justified, centered, and centered, respectively. Conclusion I don't wish to teach people how to use LaTeX in this document. It takes some practice. I found it easy to learn. My book was a large project, as it involved 479 pages in 29 separate TEX files, title pages, a table of contents, an index, formulas, some complicated tweaking of page headings, about 100 tables some of which were very complex, many graphs, most of which I made from an ASCII data file using a LaTeX package like "PicTeX," and others I made by including photographs and drawings as encapsulated PostScript objects ("eps"). I learned the entire system, from a previous knowledge level of zero, in about three weeks while I was converting all of my MSWord manuscript to TEX files. Most of time spent learning LaTeX itself involved obscure use of the graphics package PiCTeX and embedding EPS objects, neither of which is explained well in any book. The remaining learning took about 3 days. Someone can learn LaTeX by reading the book "LaTeX: a document preparation system" by Leslie Lamport or its companion books, the LaTeX Companion, and the LaTeX Graphics Companion. But I think this is the hard way to learn it. These are much better as reference books after a person knows a little about the system. I think it is nearly impossible to learn using these books from scratch. Instead, I suggest learning by the monkey-see-monkey-do method, which is to get a good TEX file example, which I have included, and the PDF file it produces, which I have also included, and see how someone does things by example. Best Wishes, Kevin Kilty Encl: TEX file of this letter, PDF file produced with pdflatex |