# LaTeX for Secretaries

## Desktop

by Jacek Artymiak

Life is not fair, is it? You learned how to use Microsoft Word or Corel WordPerfect, only to find yourself at a job where your boss says you must use LaTeX. What is this thing? Can it be used for anything practical, like writing letters, memos, reports, sending faxes or printing price lists? These are some of the first questions that come to mind when you start using it. Fortunately, with LaTeX, it is just as easy to typeset a 1,000-page book filled with mathematical formulae as it is to prepare a short letter or a price list. These kinds of real-world office applications are what we are going to discuss below.

Not a Word Processor

Probably the most common misconception about LaTeX is thinking of it as some kind of text editor or word processor. It is neither of those tools. Let me explain. When you start Word or WordPerfect in Microsoft Windows or on a Macintosh, it opens a window, displaying buttons, menus and a white space where what you type shows up immediately on-screen and can be edited at will. To display or print documents, word processors use an “engine” of some sort that changes simple keystrokes into nice-looking type according to your choice of font and style. LaTeX can be thought of as such an engine, reading plaintext files on one end and changing them into professional-looking documents and saving in its own format called DVI on the other end.

Although LaTeX is only a pure typesetting system (it is not a visual DTP package like Microsoft Publisher, Adobe PageMaker or QuarkXPress) and the documents you process must be created using a plaintext editor, the quality of the documents generated in LaTeX are often much superior to Word's own efforts. However, learning to typeset documents in the former might be harder at first than doing it in the latter because of the need to manually add control commands to the text, which some people find confusing. You might think of it as an unnecessary burden, but you should remember that in reality, all word processors and text editors add control commands to the text you type—they just don't make them visible to us.

The best way to learn LaTeX is by example, so log in to your system (in case you do not know what logging in means, try some beginner Linux books) and type the following command:

emacs businessletter.latex


File extensions are optional and could be just about anything you like, although using .latex or .tex is good practice, as it makes documents easier to find.

After pressing the ENTER (or RETURN) key, you should see Emacs in all its glory—two toolbars and an empty space waiting to be filled with text. The \ character marks the beginning of LaTeX commands, so remember to put it in as well, and do not get confused by a \ showing up from time to time in the rightmost column of the Emacs window—it's there to show you that a particular line of text is longer than the width of the window and has been wrapped. Let's type in the lines shown in Listing 1.

Listing 1

To save what you have just typed in, press the CTRL-X and S keys. You should see a message at the bottom of the window saying Wrote .../businessletter.latex to inform you that your document has just been saved. If you accidentally press the wrong keys and Emacs starts complaining and beeping at you, pressing CTRL-G will almost always get you out of trouble.

Basic LaTeX Commands

As you can see, the example letter is sprinkled with many strange commands and curly brackets. Besides making a document less readable, they tell LaTeX how to format it. Unfortunately, you will need to learn at least a few of them. While you read the following paragraphs, refer to Listing 1 to see how each command is used in practice.

First comes the obligatory \documentclass[...]{...} command, which is not as scary as it looks and is just an obscure way of telling LaTeX what kind of document you are trying to print. It could be one of the following: article, book, letter, report and slides. Whatever you choose, put the appropriate word between curly braces.

The square brackets surround more specific options used to set the size of paper (available sizes include a4paper, a5paper, b5paper, letterpaper, legalpaper and executivepaper).

Additional information that can go there includes page orientation (landscape, useful for printing presentation slides, or portrait), main font size (e.g., 10pt, 12pt, etc.) and many others.

The \frenchspacing command solves some of the typesetting problems related to setting the amount of space between a full stop and the next word after abbreviations like Ms. or at the end of a sentence. I suggest you always put it somewhere at the beginning of a file, perhaps just after the \documentclass[...]{...} command. Purists will surely complain about this advice, but using \frenchspacing will automatically make documents look better without causing you to worry how it happened. However, if you want to be “politically correct”, always put a ~ between an abbreviated word ending with a full stop and the next letter, number or word, e.g., Ms.~Green instead of just typing Ms. Green.

After setting those options, you will need to specify the sender's address with the \address{...} command; every line should be separated by \\--this method is used in many other commands as well. If you are using official company letterhead, you may leave this out.

LaTeX automatically puts the current date into a letter, but you can use the \date{...} command to specify a different one.

The signature text should go into the \signature{...} command.

To let the program know where your letter begins, use the \begin{document} and \begin{letter} commands. Just after the latter, insert the recipient's address in curly brackets. Then, begin the greeting with the \opening{...} command and start writing your letter. Write as much or as little as you need, separating each paragraph with a blank line (you will need to press the ENTER key twice).

At the end of your letter, use the \closing{...} command and, if needed, add the \cc{...} for “copies to:”, \encl{...} for “enclosed items:” and \ps{...} for PostScript.

You should end a letter file with the following commands: \end{letter} and \end{document}. That's it. You can save it as described above.

There is one trick which you can use to save yourself a bit of work when you need to type several letters. It is possible to begin another letter in the same file, just put the \begin{letter}{...} and the other commands mentioned above between the \end{letter} and the \end{document} commands. LaTeX will automatically use the signature, date and sender's address you specified at the beginning of a file (that's why you had to put your signature text at the top of the file).

Changing Text into Type

To start LaTeX, type this at the prompt:

latex businessletter.latex


After you press the ENTER key, LaTeX will print some cryptic messages, two of which are most important: Output written on businessletter.dvi... and Transcript written on businessletter.log. Your letter is output into a DVI (device independent) file, a universal format, which you can turn into fax, PostScript or printer files.

If there are problems, LaTeX will sometimes stop in the middle of its work and ask you for help. When that happens, make a note of the line number at which the error has been found, then keep tapping the ENTER key until you see the “Transcript written on” message or the command prompt. Then run xdvi, and after visually finding the place where the error occurred, go back to Emacs and correct your mistake. Usually it will be a missing bracket or a misspelled command.

Previewing Documents

The best way to find errors and check the document's look before you print it is to use the xdvi previewer. It works only in the X Window System. To start it, you either choose it from a menu or type xdvi businessletter.dvi & on a command line in a terminal window and press the ENTER key.

Using xdvi is easy. The buttons on the right-hand side of a window are fairly self-explanatory, and you can press the PAGEUP/PAGEDOWN keys to flip pages back and forth or use the arrow-up/arrow-down keys to scroll the page you are looking at up and down (the scroll bars work just like in MS Windows, although with a two-button mouse, you will have to press both buttons to use them). Pressing the Q key exits xdvi.

Some Unbreakable Rules

The most common errors that can be found just by looking at a page in xdvi are the overfull boxes and sudden changes in font and style. These errors usually happen when you forget to obey some of the following rules of typesetting in LaTeX:

• Each paragraph must by separated from another by a blank line (just tap the ENTER key twice at the end of a paragraph).

• No matter how many spaces you put between words, LaTeX will treat them as one space and will format it according to its own typesetting rules. (You might change this behaviour, as described in the section “Overriding LaTeX Rules” below.)

• Quotation marks are made using  and ' or and instead of ", so to typeset ''funny'', you'll need to type ''Funny'' instead of "funny".

• Ellipsis (...) is printed with the \ldots command; consequently, to typeset bye..., you ought to type bye\ldots and not bye....

• LaTeX commands should be separated from the actual text. We achieve that in one of the following ways:

that begins above]

• bye, bye\ldots my love (note: the \ character starts a command and therefore does not need to be separated with a space, also see the list of special characters below).

• bye, bye\ldots{ }my love.

• LaTeX interprets some characters as special, and to print them literally, we need to use a special command instead. See list in “Special LaTeX Characters”.

Special LaTeX Characters
• Commands can be nested, i.e., you can put one or more commands within curly brackets of another, e.g., extsf{life is \emph{wonderful}!}.

Getting Rid of Overfull Boxes

LaTeX is very good at documenting its work and puts a lot of information, including error messages, into a log file. For businessletter.latex, it will be called businessletter.log. Every error is described there as best as LaTeX can, together with a line number, which helps to quickly find the right place in a file.

Although the visual method of finding errors with the help of xdvi is probably best for a beginner, there is one category of bugs that requires a different approach—the famous Overfull box. LaTeX produces that message when it cannot properly break a line of text or hyphenate a word, which happens quite often when trying to print a long web page address.

The quickest way of finding those messages is by using grep:

grep Overfull businessletter.log | less


After issuing the above command in an Xterm window, you will see either an empty window (a good thing) or a list of lines where LaTeX has put the ominous word. Go back to Emacs, find the offending lines, then use xdvi to judge how to best fix your document.

Overriding LaTeX Rules

LaTeX is very good at typesetting, but it still needs our help from time to time, especially in the case of the Overfull box error. Helping LaTeX usually means manually breaking a particular line of text. Don't worry, it will not hurt; just follow the rules given below:

• To correct bad hyphenation, put \- inside a word, at a place where you think it should be hyphenated, e.g., lab\-yrinth or laby\-rinth.

• To break a line after or before a word, without inserting a hyphen, use the \linebreak[4] command. (Try it on a line from the earlier example to see how it works for yourself.) The text before the command will be set to fill the whole width of the paragraph.

• To break a line without filling the width of a paragraph, use \\.

• To end a page and start a new one, use \pagebreak[4] or \newpage.

• To keep a part of text together (such as a phone number), use the \mbox{...} command; e.g., \mbox{+0 (11) 123 456 789} will be moved to a new line if it does not fit on the current one, but it will not be broken in half.

After you insert one of these commands into the text, save it, run LaTeX, see how it looks in xdvi and use grep to find out whether any problems remain. Repeat until you get rid of all Overfull boxes.

Some Useful Formatting Tips

So far, you have read about formatting letters, but you can typeset all sorts of documents with LaTeX. For example, using \documentclass[...]{report} will put LaTeX into a nice report formatting mode. Brochures can be typeset with \documentclass[...]{book}; memos with a \documentclass[...]{article} and presentation slides with \documentclass[...]{slides}.

To make those documents look truly professional, there are a few additional commands like \author{...}, itle{...}, and if necessary, \date{...}. To generate a title header or a title page, use \maketitle after the last one. You should place those commands before \begin{document}.

In all cases of documents other than a letter, we do not need the \address{...}, \signature{...}, \begin{letter}, \opening{...}, \closing{...}, \cc{...}, \encl{...}, \ps{...} or \end{letter} commands.

To divide long text into parts, sections and chapters, use the \part{...}, \section{...} and \chapter{...} commands.

Lists

Listing 2

There are two kinds of lists you can typeset with LaTeX: bulleted (see Listing 2) and numbered (see Listing 3). Numbered lists are especially handy for all sorts of agreements, contracts, instructions, etc.

Listing 3

Fonts and Styles

Here is a list of additional useful commands for formatting text:

• italics: enclose the text you want printed in italics with the \emph{...} command, e.g., I wish to \emph{emphasize} this!

• alignment of text—left:right:center: \begin{center}...\end{center};

• typewriter text: exttt{...};

• sans-serif font: extsf{...};

• font sizes: main document font size \normalsize{...}, and (in order of decreasing size) \small{...}, \footnotesize{...}, \scriptsize{...}, iny{...}, or (in order of increasing size) \large{...}, \Large{...}, \LARGE{...}, \huge{...}, \Huge{...}.

Templates

Any LaTeX file can be turned into a template with the following command:

chmod 444 businessletter.latex


These permissions will ensure that no one (including you) can overwrite the file you created. Anyone can open it, but to save the changes, it must be given a different name. In Emacs, you can do that with CTRL-X and W. It is also a good idea to place all templates in a separate directory.

Printing

Before you send files generated by LaTeX to a printer or a fax modem, they need to be converted to the right format. Fortunately, all distributions of Linux come with a set of conversion utilities that can handle this job without too much human intervention—you just give them the name of a file and they do the rest:

• dvi2fax: turns DVI files into fax format, making it possible to send them via a fax modem.

• dvilj: turns DVI files into Hewlett-Packard LaserJet format. Even if your printer is not made by HP, it can probably still understand or emulate LaserJet commands. All you have to do is switch it into HP LJ emulation mode, which should be described in the printer's manual. Some printers can switch into that mode automatically.

• dvilj2p: the DVI to Hewlett-Packard LaserJet 2p format converter (similar to dvilj).

• dvilj4: the DVI to Hewlett-Packard LaserJet 4 format converter (similar to dvilj).

• dvips: turns DVI files into PostScript format, allowing them to be printed on an Adobe PostScript compatible printer.

If you want to print the example letter, type:

dvilj businessletter.dvi

and then:
lpr businessletter.lj

If nothing happens (you did remember to switch the printer on, didn't you?), type lpq and see if the name of your document is on a list there; if you get a “no entries” message, then your machine is probably not set up properly for printing. In that case, ask the system administrator or the service person for help. Sometimes the printer receives the document, but waits after receiving each page for you to press the Print or On-line button. This depends on the printer, but a good rule of thumb is if the Data light is on or blinking and the Print or On-Line lights are off or blinking, then pressing one of them will solve the problem.

Also, on some printers you will need to feed an additional page at the end—it will come out blank, and you can reuse it.

Converting Files between Microsoft Word and LaTeX

So far, converting Microsoft Word files to LaTeX is a bit difficult. There are several strategies, but none of them will make you perfectly happy. To convert a Word file to LaTeX, you can:

• Save the MS Word file as a TEXT or an ASCII file. You will lose all formatting, pictures, drawings, linked and embedded documents, but you will at least get the text in a format that can be read by Emacs and LaTeX.

• Save the MS Word file as an RTF file and use either catdoc or word2x command to turn a DOC file into a LaTeX file. (Type man catdoc or man word2x to learn more about their use and options. If man does not work, try info.) You will lose some of the formatting information, but most of it will be preserved, making your job a little easier.

If you need to convert a LaTeX document into a DOC file, try the following method:

• Use delatex (or detex) to convert a LaTeX file into a plain text (ASCII) file:

        delatex businessletter.latex >\
`
• Compare the output with the original file, and if necessary, remove some of the commands and add missing text. These converters do not yet work as we need them to, unfortunately.

• Open the TXT file in Word; you will then be asked if you want to convert it from a text format. Click Yes, apply formatting as it is needed and choose the Save as... item from the File menu. In the Save as dialog, choose the Word document option and click Save.

So far, these are the most common ways of exchanging files between MS Word and LaTeX, or any other word processor like Corel WordPerfect or Lotus AmiPro/WordPro, even if some of them are available for Linux. There are some interesting developments on the horizon, but none of them can be recommended for use in a typical office yet.

That is just about everything you will need to start using LaTeX in an office. Of course, there is more to learn and I recommend you use the locate 'lshort2e.dvi' command to see if you can find the “Not So Short Introduction to LaTeX2e”. It is a well-written LaTeX manual filled with many interesting examples.

All examples from this article can be found on the Internet at the site www.wszechnica.safenet.pl/archiwum/lfors.htm.

If any of the commands or programs mentioned above aren't available on your system, ask the administrator to install them and give you the necessary permissions to use them. All of those tools should be available for any Linux distribution.

Jacek Artymiak is a consultant specializing in helping companies and individuals use Linux as a desktop or personal system for common, everyday jobs. His other occupations include being a writer, journalist, web designer, computer graphics artist and programmer. Readers are welcome to send their comments via electronic mail to artymiak@safenet.pl or visit http://www.wszechnica.safenet.pl/.