LaTeX for the Slightly Timid

Are you used to the simplicity of your old DOS word processor, and afraid of the complexity of LaTeX? This article tells you how to write a beautiful letter—and gets you started using LaTeX.

I admit it. LaTeX was not my first choice for a text formatter. I was pressured into using LaTeX by my (then) fiancé, and the fact that at the end of the semester, all the IBM PCs and the Macs were being used 24 hours a day, while the Unix terminals were almost totally free. Also, I had to reboot from Linux into DOS every time I wanted to use one of my favorite word processing programs on my fiancé's computer, which was no fun. So, armed with a topology assignment I wanted to type, I started to learn LaTeX.

Even after the first week or so of using LaTeX, it was not my favorite program. It wasn't a word processor or an editor—it was something new to me. I didn't see the italics or the underlining or my math equations on the screen as I entered or edited my papers. After a while, though, I got used to the rules, and my papers looked so beautiful that I fell in love with LaTeX. I am not a LaTeX or TeX (LaTeX is based on TeX) guru—it is all I can do to remember how to start a document. But the freedom and power of LaTeX make it well worth the initial time investment to learn it, and if you are doing ordinary everyday writing, LaTeX is not terribly difficult to use.

It Takes Some Work

There are a few major differences between LaTeX and your favorite word processor. It is not WYSIWYG (what you see is what you get) or WYSLRN (what you see looks really neat—bold is bold, italic is italic, but new lines and page breaks aren't necessarily where they will be when the document is printed). With LaTeX, what you see is what LaTeX sees, and you type in the exact commands that you want LaTeX to use. This means that WYSLRU (what you see looks really ugly) while you are entering your text. [There are so-called front ends to LaTeX that are almost WYSIWYG. Linux Journal will probably contain articles on those in later issues, because they can make it much easier for you to use LaTeX—ED] However, because what you see is exactly what LaTeX sees, if something in your document output doesn't look right, you can perhaps find it and fix it more easily than you could with a word processor.

Another difference is that when it comes to formatting decisions, LaTeX will handle the details if you handle the general idea. For example, if you want your footnotes labeled with letters instead of numbers, or the numbering of footnotes to begin at 1 on every page, or some other labeling scheme, you need only instruct LaTeX once at the beginning of your document. If you change your mind, you don't need to change all your footnotes—just change the instructions at the beginning, and LaTeX will handle the rest.

The last difference is that there is no standard user interface for LaTeX; you can use whatever text editor you want. I use Emacs, but any Emacs clone, or vi or another editor which uses plain text, will work. Because you can use any editor, starting an article or paper is a little more complex than in a word processor. You need to tell LaTeX the type of document you are creating, normally a “book”, “article”, “report”, or “letter”. Any book on LaTeX will explain the specific differences between the document types; their names should give a good idea of what they are for.

Writing a Letter

Having told LaTeX which type of document you are doing, it figures out the page formatting and the special options needed throughout the document. I will use the “letter” document style to demonstrate the basics of typing documents in LaTeX, as well as the power of LaTeX to make documents easy to format and beautiful.

To begin any document, after starting your editor you need to place a preamble at the start of the file, of the form:

documentstyle[...]{...}

A few things need to be noted about this preamble. First, the backslash. LaTeX uses the backslash before most commands, so you should get familiar with its location on your keyboard. The brackets contain options that change something less drastic than the document style. For instance, you can change the type size from 10 point to 11 or 12 point, set the entire document in two columns, or use other more advanced options. The braces hold the name of the document type: usually article or letter. The braces and their contents are required.

Since we are writing a letter, we will start out with:

documentstyle{letter}

All documents need \begin{document} at the beginning (preceded, of course, by the documentstyle command and, often, by other more advanced commands) and end{document} at the end.

Letters are unique among the styles. You may want to write several letters in the same file, reusing the same return address and signature. LaTeX allows you to do this by stating the address and signature before the \begin{document} statement. Then, each letter is begun with \begin{letter} and ended with end{letter}. After all your letters, put end{document} to end the document.

The format of the address and signature commands are similar and something you will become very familiar with in LaTeX. Type the command, followed by the argument (for these commands, your address and your name and title) in braces:

address{Linux Journal\\P.O. Box 85867\\
Seattle, WA 98145—1867}
signature{Kim Johnson\\Chief Bottle Washer}

Notice the double backslashes; these are added to force a new line—simply pressing return will not work, as I explain later.

Now, begin your first letter:

\begin{document}
\begin{letter}{Aunt Jane\\
St. Mary Mead\\England}

The argument in the second set of braces is the address of the recipient of the letter. Note the recurring double backslashes and the tendency to put arguments in braces to set them apart. You may want to add an end{letter} at this point and then type the rest of the letter between the \begin and end—it saves a lot of time debugging later.

The other options are mostly self-explanatory from the example letter.

opening{Dearest Aunt Jane,}
This is a very short letter.
closing{With love,}
cc{Hercule Poirot\\Tuppence}
encl
ps{P.S. This is a postscript.}
end{letter}
end{document}

Your name is added underneath the closing of the letter from the signature command that was used before the \begin{letter}, as shown in Figure 1.

Figure 1. Output from LaTeX

It would be possible to arrange this letter on the page “by hand” on most word processors, and even on LaTeX, but the point is LaTeX does the formatting and you do the writing. The other document styles do not format quite so aggressively, but they do allow you to add your title and dedications without having to worry about getting everything centered and on the correct page.

______________________

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState