"Don Knuth's Tau Epsilon Chi (TeX) is potentially the most significant invention in typesetting in this century. It introduces a standard language in computer typography, and in terms of importance, could rank near the introduction of the Gutenberg press."
--Gordon Bell, forward to Tex and metafont, New Directions in Typesetting
A new year is upon us and you've finally decided it's time to take the plunge and write the next great American (French, German, Japanese?) novel. Or maybe you just need to update your resume, compose some letters, or write some project documentation. If you're like most Macintosh users, you probably use a word processor like MS Word or Nisus Writer Express for your daily writing needs.
This article suggests an alternative to commercial word processors--a program called LaTeX. It provides as much, if not more, utility as commercial word processors. It's rock solid, has a long history of use, a large user base, and best of all, it's free. It may not be right for everyone or for every writing situation, but LaTeX is worth exploring and testing out. You may find it really enhances your writing process and offers some key advantages over word processors.
This is the first of two articles that cover the LaTeX document preparation system. It introduces you to LaTeX, and details the various versions of LaTeX available for Mac OS X, including Aqua-based versions, as well as versions used under Unix. It also shows you how to install a LaTeX implementation and demonstrates how to use it. (The second article will introduce you to writing in LaTeX by showing examples of common writing needs.)
The main advantage to using commercial word processors is that you can see the end result of your document as you work--a concept known as WYSIWYG (What You See Is What You Get). Another advantage is that word processors provide many of the tools writers count upon to support the writing process.
For example, when writing anything nontrivial, having a program that automatically creates and maintains a table of contents and index, has a good quality spell checker, and counts the number of words and lines in a document, is indispensable. Program like MS Word, AppleWorks, and Nisus Writer Express provide these features.
The fact is, most of us have used word processors for so long we have ignored other writing tools and techniques that offer some real benefits. For example, being able to see the final document as you work is great, but it can get in the way of the writing process. As you write, you are forced to think simultaneously about the form of the document, as well as its content.
For most users, this process is so ingrained that they don't even notice it anymore. As an experiment, try this test. For a few weeks, use a text editor like BBEdit or Emacs as your main writing tool. Forget about formatting (fonts, font styles, and so forth); just concentrate on the writing. What you may find is that your writing improves because you're concentrating on writing and not worrying about the appearance of the document.
Another result of this process is that many documents are formatted according to personal preferences, as opposed to more established conventions. I'm not sure about you, but I'm no typesetter and don't always make the right choices for producing the best looking, most readable documents. Styles, like those in MS Word, can be a help, but they are not a substitute for a real typesetter.
Also consider that most word processors save files in proprietary, non-text, formats. Heck, I'm mainly a Unix guy and I like having my files stored as text (ASCII), where I can access and manipulate them using the tools of my choice. I'm willing to bet that any file saved as ASCII today will be readable for many years to come, on many different systems.
|
Related Reading
Running Linux |
You can always save word processor documents as text, but this is just one more step, and may not be possible if you don't have access to the version of the program that you used to create the document. A current movement is for word processors to save documents in XML, which is a step in the right direction.
Finally, consider the cost factor. Most users have no problem shelling over some money for a program that makes them more productive. However, sometimes you're paying a lot for a full program and only using a small subset of its features. Consider MS Word--why should we have to pay so much for the program, not to mention the upgrades, when we only want to use a very small number of its features?
Once you consider all these factors, I think you'll see that using an alternative like LaTeX for your document preparation needs makes sense.
Before getting started, let's look at what LaTeX is all about. First and foremost, LaTeX is not a word processor. It's a document preparation and typesetting system that excels in producing high-quality documents. This is the main attraction of LaTeX--its output is both fantastic and printer ready. In fact, LaTeX is the standard document preparation system in academia. It's mainly used by scientists and mathematicians, and is the accepted submission format for most journals in these fields. As you will see, LaTeX is also very useful for your daily writing needs.
LaTeX is composed of two main systems: TeX and a macro package that sits on top of it called LaTeX. In this article, I will use LaTeX to refer to the entire system.
TeX (pronounced Tech) was written by Donald Knuth in the late 1970s. If you are not familiar with Donald Knuth's work, stop now and check out his web site. Knuth is considered one of the pioneers of computer science and his books have influenced generations of programmers and computer scientists. TeX came to life because of Knuth's frustration with the quality of typesetting for his books.
As Knuth writes in the foreword of The TeX book, "TeX is a new typesetting system intended for the creation of beautiful books--and especially for books that contain a lot of mathematics. By preparing a manuscript in TeX format, you will be telling a computer exactly how the manuscript is to be transformed into pages whose typographic quality is comparable to that of the world's finest printers."
The TeX software is basically a macro processor, with an accompanying macro package called Plain TeX. TeX is exceedingly stable. In fact, Donald Knuth offers a reward if you're the first person to report a new error.
LaTeX (pronounced Lah-tech) is a macro package written by Leslie Lamport. This macro package uses the typesetting functionality of TeX, but adds high-level abstractions that simplify the creation of documents. According to the TeX FAQ, "LaTeX allows markup to describe the structure of a document, so that the user need not think about presentation. By using document classes and add-on packages, the same document can be produced in a variety of different layouts."
To sum up, TeX provides typesetting facilities, and LaTeX provides the high-level macros that make TeX easier to use, and it simplifies the creation and production of documents.
To use LaTeX, you first compose a LaTeX source file. A LaTeX source file is a text file with a .tex extension, which consists of your writing content and LaTeX control sequences. Next, you pass the document to the LaTeX system, where it reads the document, processes the file, or files, and produces its output files. In practice, the process is more complex. For more information see the "Introduction" in The LaTeX Companion, which is listed in the resources section.
The primary strength of LaTeX is its typesetting quality. It effectively enforces a consistent and professional layout and typographical convention for your document. As such, it provides structure to your document and makes it far more professional and readable. Additionally, it relieves you from thinking about the visual aspects (form) of the document and making ad hoc decisions concerning the document's appearance. This enables you to think about the substance of your writing and let LaTeX worry about the form of the document, and it allows you to produce the highest quality output.
Another nice feature of LaTeX is that it renders your source document in many output formats. For example, imagine writing your resume in LaTeX and producing a PDF, Postscript, HTML, and RTF version--all from a single source file and rendered in the highest quality output.
I won't lie to you, LaTeX does have a learning curve, both technically and conceptually, and it is not right for all users or purposes. This is especially true if you have primarily used word processors. That said, I think much of the complexity has been masked by more advanced LaTeX writing environments such as those discussed in this article. In the end, your decision, like life, is simply a tradeoff. You can get a lot from LaTeX, but there is a time investment; one that I feel is justified.
Now that you know something about LaTeX, let's look at the most popular Aqua-based implementations for Mac OS X. In this category, there are several players, including TeXShop, iTeXMac, and OzTex. I will also cover BibDesk, a bibliography manager for Mac OS X. This list focuses on programs that are freely available or are shareware--commercial implementations such as ScientificAssistant are not discussed.
Also, my comments focus on each program's usability and highlight some of their features. My comments are intended to give you a flavor of the applications rather than a complete review of their features. For this information, go directly to the program's web site.
TeXShop
TeXShop is an integrated writing environment for composing LaTeX documents.
Accordingly, it's a front end for TeX, and includes an editor, previewer,
and many other features to support composing LaTeX.
TeXShop is available in a compiled version (.dmg file), or as source code. It can also use other programs that support the writing process, including spell checking, bibliography management, and equation editing. The TeXShop distribution does not come with TeX itself, but uses the TeXLive-teTeX distribution of Tex, which you need to install yourself.
TeXShop uses Apple's built-in spell checker (like TextEdit), but can also use the Mac OS X port of Aspell, called cocoAspell. Another useful feature is that TeXShop contains menus that hold LaTeX macros and it documents navigation features. Using the macro menu enables you to easily insert common LaTeX commands into your document without remembering their syntax. TeXShop supports many more features than described here, as well as an excellent PDF document previewer. These features are well documented in its online help.
For many Macintosh users, TeXShop is a good solution that offers many advantages over the other packages. It's written in Cocoa so it feels like a Mac OS X program and using it requires very little work. It also contains plenty of features, customization options, and online help.
|
iTeXMac
iTeXMac is another LaTeX writing environment and previewer in the same
sprit as TeXShop. Like TeXShop, it's a front end for TeX, and includes
an editor, previewer, and many other features to support composing LaTeX. It also uses the teTeX distribution, but can be configured
to use other LaTeX distributions, such as the Fink TeX package. iTeXMac
is available in a compiled version (.dmg file), or as source code. In
addition to the application, you can also download an assistant-SDK
for writing iTeXMac extensions, and an excellent online Apple Help Books
for TeX and LaTeX.
iTeXMac provides many of the same features as TeXShop, such as spelling support using either Apple's built-in spell checker or the cocoAspell program. It also contains menus that hold LaTeX macros, an excellent PDF previewer, and can be configured to support external editors. This feature enables you to compose LaTeX documents in your favorite editor and use iTeXMac for rendering your document. Unlike TeXShop, iTeXMac supports projects, which aggregate information (files to be processed, typesetting commands, BibTeX settings, and so on), so iTeXMac can render PDF documents. It also supports AppleScript.
iTeXMac is a very complete environment for composing LaTeX. It's a native Mac OS X application so it feels like the Mac OS X program you are used to. It contains lots of features, excellent online help, and is a very well-designed program. Overall, iTeXMac's has more features thanTeXShop, and will require a bit more time to learn.
LyX
LyX is an open source document processor. LyX comes in two flavors: a Mac OS X program, which you can install from its .dmg file, and a version
that runs under X11, which you can install using Fink (discussed in
the next section). LyX's Mac OS X version is written using the Qt GUI
toolkit so it feels different than the Mac OS X applications you are
used to.
The LyX writing environment is somewhat different from the other tools discussed here, or even from word processors. According to its documentation, "Think of LyX as the first WYSIWYM word processor: What You See Is What You Mean." To really get the feel for LyX, give it a try and check out is documentation page.
BibDesk
When writing articles, reports, and books, it's important to keep track
of bibliographic information . You can use commercial programs like
EndNote, but they cost money and
do not integrate well with LaTeX environments. If you are using LaTeX,
the typical way to manage your citations is using BibTeX.
BibTeX is an extension package to TeX that you use to manage your bibliographic citations, and merge selected citation information onto your LaTeX documents. The details of this process will be discussed in the second article in this series.
BibDesk is a Mac OS X BibTeX bibliography manager. Basically, it provides a GUI for managing your BibTeX files. If you are more comfortable using a GUI for managing citations, this program is a good choice.
OzTeX
OzTeX is a popular implementation of TeX for the Macintosh and has been
around since the early Mac OS days. OzTeX comes with its own version of TeX
so you will not need to install another TeX distribution. Like the other
packages, OzTeX contains a previewer, in this case a DVI previewer.
Unlike the other packages, OzTeX is distributed as shareware so there's
a $30 fee for individuals and $300 for groups.
The OzTeX distribution includes the OzTeX program, which includes TeX, a DVI previewer, a DVI-to-PostScript translator, dvidvi, dvicopy, and PostScript utilities psbook, psnup, and psselect, to name a few. OzMF is a Mac implementation of Knuth's Metafont program. OzMP is a Mac implementation of John Hobby's MetaPost program for producing PostScript pictures. OzTtH is a TeX-to-HTML translator.
Unlike the other programs, OzTeX does not have an integrated editor, and as such, does not have a set of menu-driven macros that support your writing. OzTeX is configured through a local configuration file. An example file is enclosed, which you can edit to suit your needs. This file enables you to choose your default editor, web browser, default paper size, and printer settings.
To use OzTeX, you compose the source document in your favorite text editor. Next, you activate OzTeX, making sure that LaTeX is selected from the TeX menu. To process the document, choose the TeX command from the TeX menu. OzTeX processes the document and writes runtime information to the OzTeX window (you can repeat the run by pressing Command-T). To view the DVI output, select View [DVI-file], or press Command-O. To continue editing, press Command-E. The Tools menu contains many commands for rendering your document in different formats.
OzTeX is not an integrated environment like TeXShop or iTeXMac, but rather a front end that knits together several tools. This design has some advantages and is great for users who like this approach. Experienced Macintosh LaTeX users like OzTeX because they are use to the environment. Also, some Mac OS X editors, like AlphaX, contain very good OzTeX integration.
CMacTeX
CMacTeX is an integrated suite of programs for implementing TeX on the
Macintosh. It includes TEX, e-TEX, pdfTEX, a DVI and Postscript previewer,
and a Postscript converter, to name a few. It also supports AppleScript.
CMacTeX comes in versions for Mac Classic as well as Mac OS X (Carbon
and Classic versions). It's compatible with Unix TeX versions and understands
Unix directory paths embedded in your LaTeX document. This feature is
useful if you plan on sharing LaTeX documents with Unix users.
CMacTeX is similar in spirit to OzTeX. It's mainly a front end to TeX that enables you to conveniently access TeX tools. Also like OzTeX, it comes with its own version of TeX. CMacTeX integrates well with BBEdit and even comes with a set of plugins that simplify using it from BBEdit. For example, you can compose your document in BBEdit and use the plugins to process your document, go to errors, and view the DVI output.
Like OzTeX, CMacTeX is distributed as shareware so there's a $35 U.S. registration fee for a single user.
|
The above programs focus on bringing Mac OS X users a comfortable and familiar environment for composing LaTeX documents. These programs mainly offer LaTeX services, wrapped in an Aqua interface. However, if you have a Unix background, or are a bit more adventurous and willing to learn some new tools, you can use LaTeX under Unix.
As you know, lurking under Mac OS X's familiar Aqua interface is Unix, specifically BSD. Apple's implementation of X11, the XFree86 project, and projects such as Fink are actively bringing the world of Unix open source software to Mac OS X. This is great news for users since it opens up a whole new world of high-quality software for the Macintosh, all for free.
Now, LaTeX users under Mac OS X have access to many of the LaTeX tools from the Unix world. To use these tools, you will need to install Fink, as well as X11. This is a very simple process and each of the web sites provide all the information you need.
Once Fink is installed, you use the Fink command-line program fink or apt-get, the cursors-based package management front end called dselect, or Fink Commander, to install and manage your Unix software. The Fink tools are documented on the Fink site and in man pages, which are placed on your system when you install Fink. Use any of these programs to install the Fink LaTeX packages (tetex-base, tetex-texmf, and so on). In addition to these packages, there are many other TeX packages available via Fink. For example, LaTeX2rtf will convert a LaTeX file to an RTF file; LaTeX2html converts LaTeX documents to HTML; and texpower can be used for creating dynamic online presentations with LaTeX. Note: you will need root permission to install the software.
Now that TeX is installed, you can process your LaTeX files from the command line, just as you would under Unix. For example, to process a file:
There are many Unix LaTeX programs and utilities available for Mac OS X. LyX is an open source document processor. The visual appearance for this version is similar to the native Macintosh version, except that it uses the X11 environment.
AUCTeX is a GNU Emacs-based package that provides a customizable integrated environment for composing LaTeX files using Emacs. To use AUCTeX, you need to install Emacs version 21 (emacs21). Once installed, when you open a LaTeX file in an Emacs buffer, several new menus are added to the EMacs menu bar. These include Preview, LaTeX, Commands, Math, and Ref. These menus hold commands and shortcuts that support composing and viewing LaTeX documents--much like the Mac OS X programs previously discussed.
TeX Mode is an Emacs mode that supports editing LaTeX files. The mode usually come installed with Emacs. When you open a LaTeX file in an Emacs buffer, Emacs selects the LaTeX mode. The mode provides support for editing and composing LaTeX files with Emacs. See the TeX Mode site for more information.
GNU TeXmacs is a free TeX-based WYSIWYG environment that enables you to write structured documents. The goal of the project is to produce a complete scientific office suite, including a spreadsheet, a technical drawing editor, and a presentation program.
Now that you have seen what versions of LaTeX are available for Mac OS X, let's look at one of them in more detail. For this example, we will use TeXShop. To begin using TeXShop, go to the TeXShop web site and perform the following instructions. Note: you will need root permission to install the software.
pdfsync.sty in your ~/Library/texmf/tex/latex folder (if
necessary, create the folders within your Library folder) (not all of these packages are required, but it's a good idea to install them anyway). To install a package, select the package, click the "Open i-Package" button, and click the "Install & Configure" button
Now that you've installed the program, launch TeXShop and select File->Open.
Maneuver to the TeXShop folder (that you saved above) and open example.tex, which is located in TeXShop_Folder. Finally, click on the Typeset button in
the editors toolbar. If everything installed correctly you will
see TeXShop process the document and display the corresponding PDF file.
An advantage to using a word processor is that it comes with integrated features that support the writing process. Since LaTeX files are stored as text, you can easily roll your own support tools by using Unix commands and some open source applications.
For example, when submitting articles for publication, you sometimes need to stay under a certain number of words. So, you will need a method for determining the number of words in a LaTeX document. Since LaTeX documents contain LaTeX control sequences as well as your text, the problem is somewhat more complicated. To accomplish this, you follow the age-old Unix practice of chaining small, pre-existing programs together to accomplish new tasks. To do this you will need DeTeX, a filter program that removes LaTeX/TeX control sequences from the input, and the Unix utility wc, which displays the number of lines, words, and bytes contained in an input stream. DeTeX is available from Fink, wc is a standard Unix utility that comes with Mac OS X.
The following example shows a simple LaTeX file and command for counting and displaying the file's word count.
\section*{Introduction}
This is the first line in the file.
This is the second line.
% detex detex_test.txt | wc -w
14
I hope this article has piqued your interest in trying LaTeX. In reality, the only way to know if it's right for you is to roll up your sleeves and give it a try. If you are most comfortable with Mac OS X applications, try TeXShop and iTeXMac first, and see which one works better for you. You may also want to check out the other Aqua-based programs. If you like using a mixed environment (Aqua and X11), or you are primarily a Unix user, give the Unix-based versions a try. Also, check out the web for more information on TeX and LaTeX.
I'm sure you will see why so many people are using LaTeX. In my next article, I will introduce you to using LaTeX for common writing tasks. I look forward to hearing about your experiences using LaTeX. Until then, enjoy!
ResourcesGeneral LaTeX Web ResourcesLaTeX Books
|
Kevin O'Malley is a long time Macintosh and UNIX developer. His articles have appeared in Dr. Dobb's Journal, IEEE Internet Computing, and The Perl Journal, and he is the author of Programming Mac OS X: A Guide for UNIX Developers.
Return to the Mac DevCenter
Copyright © 2009 O'Reilly Media, Inc.