LaTeX: It's Not Just for Academia, Part 2
Pages: 1, 2, 3
Examples
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.
An Article
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.
A Presentation
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 slides
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).
Output Formats
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
The 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
= -1, 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
The 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
text.
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.
Final Thoughts
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.
Resources
|
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.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 6 of 6.
-
PDFLaTeX seems slow...
2004-03-24 08:50:35 plumcreek [Reply | View]
...I'm trying LaTeX on my Pismo PowerBook (400Mhz) and it seems slow. I've used both the i-Installer version and the fink version (currently using). Even for a simple one-page letter it seems to take a couple minutes before I get my pdf.
Any suggestions on how to speed things up? ---or is this just the way it is. I have no frame of reference since I'm a brand-new LaTeX user. The only comparison I have is groff, which gives me a .ps file in about a second (I know the two programs are very different and I much prefer the output I get from LaTeX, but, like I said, I have no other frame of reference, I just want a completed pdf!)
Thanks!
-
Online Resources kind of problematical
2004-03-11 07:38:27 willadams [Reply | View]
General LaTeX web resources
and
MacOS X TeX/LaTeX Web Site
both point to the same page:
http://www.esm.psu.edu/mac-tex
Perhaps ``The TeX Showcase'' would be better to use?
http://www.tug.org/texshowcase/
I've also a listing of free e-texts on typography available from my web site, http://members.aol.com/willadams (click on ``Bibliography'' then either ``free texts on typography and related subjects'' or ``TeX'' or ``(incl. free texts)''
I've a few things in my portfolio, but most of the TeX stuff I've done is already in the TeX Showcase.
William
-
Presentations
2004-03-07 15:04:00 pmccann [Reply | View]
Using keynote with pdflatex is easy and produces beautiful output: from either the texshop preview window, or from preview itself, you can simply drag over the equation you wish to include in your presentation and then copy/paste or drag it into the keynote window. Works beautifully and embeds the equation as a pdf, so resizing etc is no problem. Best of both worlds in many ways. (Note that you need to engage the selection tool to do the dragging.)
-
LaTeX part 2: corrections
2004-03-06 05:49:03 maartensneep [Reply | View]
I have some remarks:
The article states:
"Any line beginning with a % is a comment. When LaTeX reads the % character in a file, it treats the rest of that line as a comment."
This is true, but the comment does more: it also removes the return and any whitespace at the beginning of the next line. This makes it essential for suppressing unwanted spaces in the output (remember that a return counts as a space). BTW: to get a '%' in the output, type \%.
After this, the article states:
"In addition to the comment token, you can use the comment command.
\begin{comment}
This is a comment and is not displayed in the final document.
\end{comment}"
This does not work out of the box, but only after loading the comment package: \usepackage{comment}
=====
The standard document classes are not very flexible. The memoir (book) class is very flexible, and comes with a great manual. Others prefer the KOMA script bundle. For letters and slides, the other options are way better than the original classes. Most installations (teTeX through i-Installer certainly) come with these classes.
=====
(typo: in the "Generating an index" section, first paragraph: "makeinx package"should be "makeidx package")
=====
Regarding BibTeX: a slightly more elaborate example might help:
@article{okeefe1988,
author = {O'Keefe, A. and Deacon, D.A.G.},
title = {Cavity ring-down optical spectrometer for absorption
measurements using pulsed laser sources},
journal = rsi,
year = 1988,
volume = 59,
number = {12},
pages = {2544-2551},
annote = {Abstract goes here...}
}
Note that the authors are separated by and, not by commas!
For most articles I write, I need to submit without the title. Just put as much information into the bibliographic database, and use the appropriate bib style format to get what I need. These bst-files are notoriously hard to write, the makebst script will help you here: run tex makebst, and answer all questions. You'll end up with a bst file that does what you want it to do. I've made one which allows me to print a whole database, including the abstracts, so I have an easy overview of the articles I've read.
=====
In addition to the tables mentioned here, you may need tables that split across multiple pages. The standard ones don't do this, I recommend the package longtable to do this.
=====
The graphics files supported by pdflatex are (without dirty tricks): pdf, png, jpg, and metapost output. eps can be converted to pdf with either ghostscript (wich gives you access to epstopdf) or Panther's pstopdf, just use Preview.app. Only eps is reliably supported by (standard) latex.
If you leave out the extension, latex will search itself for a file with the most appropriate extension, so you can have eps and pdf files in the same dir, and (pdf)latex will figure it out for you.
=====
Maths: use the amsmath-package, you won't regret it. Get a manual for serious usage. Normally maths (inline) is inserted like $f(x) = \sin(2\theta)$, displayed equations are given between \begin{equation} ... \end{equation}.
=====
Further references: the comp.text.tex usenet FAQ: http://www.tex.ac.uk/cgi-bin/texfaq2html.
=====
Happy TeXing!
Maarten






I'm thinking of a book that starts simple (about the level of your articles, probably) and then includes a lot of the advanced stuff towards the end.
Anybody have any ideas/suggestions?
Mel