Labeling Figures with Illustrator, WARMreader, and WARMFigToPDF under Mac OS X

                    

Introduction

We do almost all of our writing in LaTeX under Mac OS X and we have several requirements for the figures we insert in our documents:
  • We need to be able to label our figures with some reasonably complex mathematical expressions.
  • We like our figure labels to use the same fonts as the document. For us, this generally means Computer Modern, Lucida Bright, or Times.
  • We draw all of our figures using Adobe Illustrator (sometimes drawn from scratch and sometimes they are cleaned up and annotated Mathematica plots), so we need to be able to label Illustrator figures.
  • We would like to be able to quickly change notation used on figure. As an example, we are writing a textbook with hundreds of figures and we started out using \mathbf to denote vectors. Two years into the project we decided that we wanted to use \vec and the labeling procedure described herein allowed us to re-label every figure in the manuscripts in about an hour!
Under Mac OS 8/9, we used Textures to create the labels, saved the preview as Illustrator 88 files, and then simply placed the labels on our Illustrator drawings. With the advent of Mac OS X, Richard Koch's TeXShop, and Gerben Wierda's TeXLive-teTeX distribution, we tired of running Classic under OS X and chose to go with an OS X-only solution. This required coming up with a new figure-labeling procedure.

Requirements

This web page describes a procedure we have refined since January 2002. The requirements for this procedure are (click on the link for information or download): The following description assumes that you are using TeXShop and Gerben Wierda's TeX distribution.

Procedure

In order to describe the procedure, we will use the figure shown below.

This is what the figure looked like straight out of Mathematica. We now want to modify it by replacing the numbers on the axes with LaTeX fonts (we happen to be using Lucida Bright here -- you will likely use the default LaTeX font, which is Computer Modern), adding axes labels, adding some text above the plot, and throwing a few arrows in for good measure.

Step 1

The above image was saved out of Mathematica as an .eps file and then it is opened in Illustrator. (Of course, you could also simply draw your image in Illustrator from scratch.) Once in Illustrator, you need to go to "Window > SDK Dialogs > Show Marked Objects Dialog" to open and have access to the Marked Objects information dialog (all screen shots are from AI 10 -- they look very similar in AI CS).

You will now start adding Marked Objects (MOs) to the image. MOs are those things that will add labels to the figure. Let's see how.

Installing the MO plug-in to Illustrator also adds a new tool, which can be found by clicking and holding on the Pen Tool. The Marked Object Tool will be on the far right.

Once you have selected the MO Tool, then you can start adding MOs by simply clicking on your image.

The image, with a number of added MOs is shown below.

Notice that each time you click on the image with the MO Tool, Illustrator adds a large "X" with a numbered subscript and the words "Default Text". A number of these things can be changed in the preferences for the MO Tool.

Note: Illustrator puts the MOs in a separate layer. Don't put anything in that layer other than MOs since that layer is hidden when you typeset later on.

Step 2

Now that we have added a number of the MOs, we can now edit them using the Text Tool within Illustrator. The text you place in each MO should be the LaTeX label you wish to place on the figure. The figure, with all labels and all the appropriate text in each label, is shown below.

In addition, the labels have all been moved into their "final" positions. When moving each label to its final position, the thing to keep in mind is that the center of the "X" will be the center of the box bounding the entire label. You will soon see why we have aligned (i.e., placed the center of the X or cross) the y-axis labels on what will be their right edges after typesetting and the x-axis labels on what will be their top edges after typesetting.

Step 3

Now that we have added and placed all the MOs, in Illustrator 10, before closing the file, you need to hide the MO layer by clicking on the little "eye" next to the MO layer. In Illustrator CS, you don't need to hide the MO layer before closing the file.

Having hidden the MO layer, you can now close the file. Simply save the Illustrator file as a PDF as shown below.

This dialog is out of Illustrator 10 -- it looks very different in AI CS. In our experience, it is best to use the "Default" options in either case when saving the PDF. In this case, we have named the file LJTraj.pdf.

Notice that Illustrator will also save a file with the same name but with a .bb ending. Note: There have been some reports of the .bb file not being saved on some systems. If you have this problem, let me know. In the mean time, you can work around this by using the pop-up menu in the upper right corner of the Marked Objects Dialog and choosing "Save ...". Be sure and give the .bb file the same name as the Illustrator PDF file (without, of course, the .pdf ending).

The next step is to run the Illustrator PDF file through WARMFigToPDF. To do this, simply drop LJTraj.pdf on the WARMFigToPDF icon, which is shown below.

When you drop your PDF file onto WARMFigToPDF, the window shown below will appear and it will give you a little feedback as to what is happening (windows may look a little different when using WARMFigToPDF 4).

WARMFigToPDF will change the name of the .pdf and .bb files and it will generate a .tex file as shown below (this screen shot is from Mac OS X 10.2).

Step 4

Now you should open the .tex file, which in this case is named LJTraj.tex, in TeXShop (that is what we use, though you could obviously do this other ways). To save space, we have linked to the original LJTraj.tex file. It should typeset as is, but you will notice that it contains a lot of stuff that is specific to our work. In version 3, the .tex is generated for you and you can either modify the .tex file each time to suit your needs or you can modify the source for the AppleScript and rebuild it so that the .tex file contains what you need for your work. In version 4.0, we have implemented a preferences file that is generated for you the first time you drop an Illustrator PDF file on WARMFigToPDF. It can be found in

~/Library/Application Support/WARMFigToPDF/default.tex

and this file can be modified to suit your needs. If you wish to play with either project, you can obtain the full source via links below. See the History tab in the running app for changes.

Now typeset the .tex file and you will see the following (you will notice that we have already modified the .tex source file so that it uses 12pt Lucida).

The labels are close to where we want them, but they all need to be moved. This is easily done by modifying the lines in the .tex file that look like:
\xyMarkedTextPoints!D( 0.00)!L( 0.00){1}
These are WARMreader commands. The most important things to remember when moving the MOs are that:
  1. The total width and height of each and every label is 2 units.
  2. A positive number in D( 0.00) will move it up and a negative number will move it down.
  3. A positive number in L( 0.00) will move it to the right and a negative number will move it to the left.
  4. Moving a MO, for example, 1 unit to the right will align the left edge of the MO on the position of the center of the "X".
You can now have a look at our modified LJTraj.tex file and see what we have done to move the MOs into their final positions. Some things to notice are:
  • We have made use of WARMreader commands to modify some of the labels. In particular, we have modified label 11 by rotating it by 90 degrees and we have modified label 16 since we didn't want the line break in the label. In the default .tex file, we include templates for doing these things in the section headed by USEFUL WARMreader COMMANDS.
  • We have aligned all the y-axis labels on their right edge by using L(-1.00).
  • We have aligned all the x-axis labels on their top edge by using D(-1.00).

Step 5

Once you have all the MOs exactly where you want them, then close the .tex file and you will see that your directory now looks something like the following.

Many of these files are not needed and WARMFigToPDF can clean them up for you. To get rid of the unneeded files, simply drop the .aux file on either the WARMFigToPDF icon or on the open WARMFigToPDF window and you will see them disappear. You are done! The file LJTraj.pdf is the properly cropped PDF file with all the labels in place.

Finally, here is the final PDF in all its glory.

 

That's it! We sincerely hope this will be helpful to Mac OS X TeX community.


Administration

Email me if you have any questions:

This page was last modified on Monday, July 25, 2005 at 23:20:26.

© Copyright 2003--2005 by Gary L. Gray and Francesco Costanzo. All rights reserved.