Now that you understand some basic LaTeX commands, let's put it all together by looking at some sample LaTeX documents. We'll look at two kinds of documents; an article and a slide presentation.
For these examples I will provide a sample document source file that you can use as a starting point for creating your own documents. Be advised -- these are simple examples that contain minimal commands.
Composing papers and reports is something many of us do daily. For example, if you are a student, you need to take class notes and write papers for your classes. If you are a developer, you can write many kinds of project documents, such as design documents and reference manuals.
Imagine you need to write a short paper for a class or maybe a series
of articles. For this
project you use the
article document class.
See the LaTeX source file for this article.
At one point or another, we have all had to give a presentation. Faced with this, most of us will reach for PowerPoint or Apple's Keynote. Both programs are excellent choices that enable you to quickly build very professional presentations. However, you can also create slides and computer-based presentations with LaTeX.
There are many advantages to using LaTeX for your presentations. First, LaTeX presentations require less disk space to store than their PowerPoint or Keynote counterparts. With disks being cheap these days, this is not much of an issue. But I still like the idea of keeping file sizes down when I can.
Another reason for choosing LaTeX is if your presentation uses lots of mathematical equations. Imagine your presentation uses lots of mathematical equations. If you use LaTeX, you can easily copy and paste these into your slides. Otherwise, you need some way of getting them out of LaTeX and into your presentation software (maybe using tex2im or TeXShop).
Finally there's the simplicity factor. I don't know about you, but the world we live in has become preoccupied with appearance at the expense of content. I find it distracting to go to a talk and watch cute animations and graphics when plain old text would have been a lot clearer. Yes, a picture is worth a thousand words, but the picture does not need to fly onto the screen for the slide to be effective.
With LaTeX, there are many ways to create quality slides. The
simplest is to use the LaTeX
slides class, which comes with your LaTeX
distribution. In the past, if you wanted to create slides you used
SliTeX. Today, this has been replace by the
slides class. The
class enables you to create simple slides with very little work.
There are many other ways to create slides with LaTeX. Some of the most popular are FoilTeX, Prosper, Seminar, ifmslide, pdfslide, PPower4.
I create my presentations using a combination of PDFLaTeX, FoilTeX, and PPower4. My needs are quite basic, as you will see in the example slides. For a more complete solution, see "Creating Presentations in PDFLaTeX" by Matt Welsh (see the Reference sections).
As you learned in the first article, a great reason for using LaTeX is that it can render your source document in many output formats, including PDF, Postscript, HTML, and RTF.
Putting Your Documents on the Web
These days, putting documents on the Web is a common task. For example, imagine keeping notes in LaTeX and generating HTML so you can view them from anywhere. The best way to accomplish this is to install latex2html by Nikos Drakos (available from Fink). Once you have it installed, all you need to do is type the following command to generate a HTML version of your document.
% latex2html latex-file
latex2html Perl script processes the specified LaTeX file,
converts it to a set of HTML pages, and places the HTML files into a
new directory, titled with the name of the file. There are lots of
options to this script. One useful option is split (
-split [n]). If n
latex2html generates one large HTML file. If n = some number
then that many pages are generated.
Here is an example of the HTML pages generated from this article.
Converting to RTF
latex2rtf program (available from Fink) converts a LaTeX file into RTF-text format. This
provides some compatibility with users of other programs, such as
MS Word. In truth, the compatibility it affords is minimal and is not
very useful for larger, more complex documents.
Converting to Text
In the first article, you were introduced to a program called DeTeX. DeTeX is a filter that removes LaTeX/TeX control sequences from its input. DeTeX is available from Fink. You can use DeTeX to extract your text from a LaTeX document. DeTeX has several options, so be sure to read its man page.
Another option is to convert the document to a single HTML file, using
latex2html. Then, open the HTML file in a web browser and save it as
Converting to Microsoft Word
An often asked question is how can I take a document I created in LaTeX and convert it to Word. The short answer is that I have not found any reliable way to do this. There are some strategies you can use, such as converting the LaTeX document to text (using DeTeX) and importing it into Word, but all formatting is lost. Another is to convert to RTF, and import the RTF to Word; but this will also lose some formatting information. Another is to convert to HTML and then import to Word, but again, you will lose formatting information.
If anyone has discovered a reliable way to handle this case, please let me know.
LaTeX Integration with Mac OS X Applications
Many Mac OS X applications support integration with LaTeX. As you saw in the first article, BBEdit supports a user-contributed glossaries of LaTeX commands. OmniOutliner from The Omni Group is a Mac OS X application for creating many different kinds of lists and outlines. OmniOutliner LaTeX Export is a set of AppleScripts by Landon Fuller that export an OmniOutliner document to LaTeX format.
I hope you've enjoyed this brief tour of LaTeX on Mac OS X. As you've seen, Mac OS X supports a rich set of LaTeX environments and implementations, making it a formidable platform for composing LaTeX documents. If you use a word processor for your writing, using LaTeX will be a shift in focus, and will probably require some time to learn. But, as these articles have pointed out, there are many advantages to using LaTeX.
In any event, I hope these articles have inspired you to begin using, or return to using, LaTeX. Good luck and as always, if you discover something interesting, post it in the Comments section or send me an email.
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 MacDevCenter.com.