macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

LaTeX: It's Not Just for Academia, Part 1
Pages: 1, 2, 3

X11-Based LaTeX Implementations

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.

LaTeX via Fink

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:

  • Open a shell (either from Terminal or X11)
  • Change directory (cd) to the directory that contains your LaTeX file
  • type: latex <latex-file>

Unix LaTeX Programs

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.

Installing TeXShop

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.

Installing TeXShop

  1. Download the latest version of TeXShop
  2. Locate and open the TeXShop .dmg file and drag TeXShop to your Applications folder (if you wish, place TeXShop in the Dock)
  3. Place pdfsync.sty in your ~/Library/texmf/tex/latex folder (if necessary, create the folders within your Library folder)
  4. Save the remaining files in the folder to a new folder called TeXShop

Installing TeXLive and teTeX Distributions

  1. Download II2.dmg from the TeXShop site (under Obtaining TeXShop and TeXLive-teTeX)
  2. Open II2.dmg and drag i-Installer to the Utilities folder inside Applications
  3. Double-click on the i-Installer, choose i-Package->Known Packages i-Directory...
  4. Install each of the following packages, in this following order

    (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

    • TeX
    • CM Super for TeX
    • Ghostscript 8
    • Freetype 2
    • wmf and iconv conversion support
    • ImageMagick
    • TeX Support: TeX4ht

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.

LaTeX Versus Word Processors

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

Conclusion

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!

Resources

General LaTeX Web Resources
LaTeX Books
  • The TeXbook, by Donald Knuth (ISBN: 0-201-13447-0) pages: ix+483
  • The LaTeX Companion, by Goossens, Mittelbach, and Samarin (ISBN: 0-201-54199-8) pages: xxx+530
  • The LaTeX Graphics Companion, by Goossens, Rahtz, and Mittelbach (ISBN: 0-201-85469-4) pages: xxv+554
  • LaTeX : A Documentation Preparation System User's Guide and Reference Manual, by Leslie Lamport (ISBN: 0-201-52983-1) pages: xvi+272

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