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.
But It Didn't Work

Now, back to your letter. Suppose that you typed it all in, tried to LaTeX it, and it didn't work. This happens to everyone once in a while. To get back to the prompt after a failed LaTeX run, type q or x or ctrl-d (this is one of my favorite features of TeX—it's very easy to get out of). A number of common problems cause errors. First, did you remember to put an end{document} at the end of your file? Or are there any other \begin statements without a matching end statement? A variation of this is missing or mismatched braces or brackets. Another common problem is misspelled commands—if you tell LaTeX to “senter”, it doesn't know what to do. My most common problem using forward slashes instead of backslashes, so I routinely do a search-and-replace for forward slashes with backslashes before printing. Also, I use Emacs in latex-mode, so it warns me about mismatched braces.

Finally, LaTeX has some special characters which can't be used in text as they are, because they have special meanings (which aren't covered in this article). These characters are:

# $ % & _ { } ~ ^ < >

All of these characters can be produced by LaTeX. The first seven can be produced by typing #, $, \\%, &, \\_, {, and }, and the rest can be produced by typing verb+~+, verb+^+, verb+<+, verb+>+, and verb++.

LaTeX's error messages are usually helpful, giving a line number near where the error may have occurred and the error type. They are not always correct, though, so you must do a bit of work, but since everything is out in the open, it is usually not too onerous. I recommend frequently saving and LaTeXing your work, so you catch errors quickly and not after your 3000 word report is finished (or so you thought). It is also useful to display your work frequently, and if you are using X-Windows, you can iconify the xdvi window when you are entering text or LaTeXing. xdvi will automatically use the newest version of the dvi file, so you don't need to exit and restart xdvi over and over.

Printing

When you are finished editing and are ready to print, you have a few options. If you have a PostScript printer, the easiest way to print is probably to use the dvips program that should have come with your TeX/LaTeX installation. If you have the lpr program installed, the command:

dvips filename.dvi | lpr

will print the file. If you want to create a PostScript file, you can instead type:

dvips filename.dvi -o filename.dvi

Other programs are available for other printers. A series of drivers for the HP LaserJet printers are commonly used; for a LaserJet 4, you might type:

dvilj4 -e- filename.dvi | lpr

to print. The documentation for the LaserJet drivers is available by typing man dvilj.

If you have any other printer, it is probably supported by the Ghostscript program. Ghostscript is a PostScript language interpreter included in most Linux distributions. Setting it up is beyond the scope of this article, but once it is set up, you can use dvips to create a PostScript file and Ghostscript to print it. For instance, if you have a printer which is compatible with the HP DeskJet 500, you can run:

gs -q -sDEVICE=djet500 filename.ps quit

A full list of devices is available by typing:

gs
devicenames ==
quit

Don't use the “/” preceding the device names.

If your printer supports printing at different resolutions, you may be able to specify the resolution on the gs command line as well. For example, for 240 pixels per inch by 72 pixels per inch, add -r240x72 to the command line before the filename. More information about Ghostscript may be obtained by running man gs.

Warning: Do not just type lpr letter.dvi to print your letter; it will most likely be a mess. Most Linux distributions do not come set up to automatically print DVI files correctly. It is possible to install “print filters” which will make your life easier. One such program is called apsfilter and will be explained in a future article in Linux Journal.

______________________

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix