Jens Nöckel's Homepage

Computer notes home

LaTeX Info Page

LaTeX: separating content from style, the scientific way

LaTeX is the de facto standard for scientific typesetting; in a nutshell, it's the markup language for maths-oriented print media, in the same way that HTML is the language with which hypertext on the web is formatted. But LaTeX had "style sheets" long before they appeared on the internet as CSS.

LaTeX is capable of essentially everything that you can do in HTML/CSS, including hyperlinks and multimedia, but it can do much more because its foundation, TeX, is actually a kind of programming language, albeit not one that implements the latest fashions. It is from a time when graphical user interfaces (GUIs) were still in their infancy, and most user-interfaces were text or script based. Of course as GUIs matured, they themselves became "scriptable" (see, e.g., ApppleScript on the Mac). The moral of the story is that scripting is still the only way to do serious work on a computer, so why abandon a powerful program like TeX only because it isn't GUI-oriented?

Unfortunately, schools and even Colleges do not teach this, and instead perpetuate the erroneous notion that efficient and professional writing requires Microsoft Word or similar software. Equating "Computer Literacy" with mastery of Microsoft Office is the same as equating "Literacy" with mastery of McDonald's menus.

Typing LaTeX feels more like typing a program, and the editor you'll end up using for this may lack some features familiar from Word. But that isn't necessarily a shortcoming: One thing that traditional word processors do is to breed a reliance on "on-the-fly spell checking". This may be useful in some contexts, but it can also be detrimental for several reasons:

In LaTeX, you can do spell-checking as well, but it is usually done as a separate step, not "on-the-fly spell checking". If you really need a feature like this, there are editors (see below) that offer it. Emacs has a mode called flyspell for this purpose.

Word processors versus LaTeX

LaTeX allows you to produce high-quality PDF output, and can also be converted to other formats such as RTF, OpenOffice or HTML. But just like HTML, it isn't so easy to see what the output will look like while you're typing the source code. That immediate feedback is something you only get with WYSIWYG editors, i.e., the garden-variety word processor to which MS Word has become eponymous. This is a drawback of LaTeX; but it is at the same time a potential advantage. This is because LaTeX allows you to adjust and tune the appearance of the output pretty much independently of the content. So if you really want to focus on the content and logical structure, LaTeX can provide an environment in which you can essentially "tune out" all worries about what things are going to look like on the printed page. Of course once you actually do address that part, there can still be a lot of work involved, just like with web page design. But at that point, one can often rely completely on pre-existing stylisitc work that has been done by others, and which can be made available to your document by simple one-line instructions that load such styles in the form of "packages".

If you want the best of both worlds, you may find yourself using WYSIWYG word processors for small and simple documents, and LaTeX for large and complex works, especially when mathematical typesetting is required. Before diving into LaTeX, it's therefore useful to realize that the two worlds aren't completely disconnected: one can, within limits, convert a given document from word processor format to LaTeX format and back. Here are two pages that deal with the conversion problem under various aspects:

The return journey from LaTeX to word processor format is, however, a more advanced topic, because it involves the tex4ht package - a highly customizable but also highly intricate system for translating both the semantic and stylistic content of a LaTeX document into HTML and related markup languages. I'll write more about that later.

Here is an example for the uses of tex4ht.

Where to get LaTeX

Fancy formatting with LaTeX

Your computer comes with many fonts installed. In a word processor, you are usually limited to a certain set of font sizes, and of course the text flows along horizontal lines. In LaTeX, this is similar for basic usage, but with only a few customizations it's possible to go much further. There is, e.g., the scalefnt package, and the rotating package. With these you can create text that is either huge or microscopically small, and criscrosses the page at any desired angle. Scaling to arbitrary sizes doesn't work with all maths fonts (the age of TeX shows here), but it does work, e.g., with mathtime or mathpazo.

How to get started with LaTeX

Perhaps the best way to learn LaTeX is to place the student in front of a computer from which Microsoft Word has been surgically removed for therapeutic reasons. On a Windows PC, this is admittedly risky and perhaps not worth the side effects. Treatement of the patient should therefore ideally be initiated in a Mac OS X or Linux environment. Alternatively, one may just have to wait a few more years until Microsoft Office automatically removes itself from all computers through some virus.

Some remarks on Windows-based treatment

If the subject shows resistance or withdrawal symptoms upon removal of the Windows platform, a simple LaTeX installation on a PC can be achieved using freeley available packages:

In cases like this, it may be advisable to require a vow of abstinence from Word for the duration of the LaTeX training.

Seriously, LaTeX on a PC is just as easy and powerful as on any other platform. My own experience is that I learned LaTeX on a system where there was no other typesetting program available at all, and hence you were forced to do everything with LaTeX/TeX (I first used LaTeX on an Atari ST connected as a terminal to a VAX station at the I. Institute for Theoretical Physics in Hamburg, to write my master's thesis in 1991/1992).

But can you survive without Word?

There are reasons for using Office-like programs once in a while, if only to read files that others send you. My kids like AppleWorks a lot, and that's OK because you can do cool stuff with it. But I would tend to categorize such software as somewhere between toy and edutainment, and under this aspect there is a justification even for Word. See my Pages pages for a discussion of alternatives replacing Word, especially geared toward Mac OS X, but essentially under the premise that you're looking for something to play with.

So can you survive without Word? Some people need expensive toys, some have more fun with cheap ones. In either case, you can survive. But if you spend your money on expensive toys, you may be all the more frustrated if they don't work as advertised.

But how can I switch from Word to LaTeX?

That can be very easy if you don't have complicated formatting going on, and if you aren't using math formulas, cross references and other fancy things. OK, so in other words, for the audience I'm talking to here, it is not easy.

So don't even start with Word for serious work. It's hard to keep it future-proof and portable (unless you're able to spend the money on upgrades and site-licensing etc.)

For people who want to go through with the switch, I'll try to give some advice on a separate page.

Learning LaTeX

There is an inexhaustible amount of information on LaTeX on the web -

Useful LaTeX/PDF tools

This is a random and incomplete list!
noeckel@uoregon.edu
Last modified: Tue Dec 8 16:46:46 PST 2009