July 5, 2006

How to use Excel charts in LaTeX documents on Mac OSX

I use LaTeX to write most of my research-related papers. I really like LaTeX. I think it has a high learning curve, but it does give very nice results, makes formatting something you don't have to think about, and is great with references and citations. I love how you can easily re-organize your paper's structure, and LaTeX (with BiBTeX and friends) will always make sure that your section and figuring numbering will be correct.

What I don't really like about LaTeX is that it is very hard to set up, and doesn't integrate well with modern tools. Copy and paste for images is unthinkable in this model. The only real graphic format that is well supported is Encapsulated Postscript (.eps) files. You can argue that using pdf files for graphics works, if you use pdflatex, but that opens up a completely different can of worms. I like sticking with regular LaTeX. You can always convert a .dvi file to ps or pdf, you can use pdflatex with .eps files, but you can not go the other way around: you can't make a .dvi with a LaTeX file that includes .pdf files for graphics, at least in my experience.

I wish LaTeX would support better graphic formats, like SVG. I use Inkscape a lot on Linux, and like it. Since LaTeX does use EPS though, isn't it nice that under Mac OSX we can print anything to a PostScript file? Here is a description (sans photos, for now at least) of how I recently included some Excel charts in a LaTeX paper I'm writing.

Create a .ps file for the chart

In Excel, select the chart you want to include. Print it, and in the print options box click "Page Setup...". Under the "Page" tab, make sure that Orientation is set to "Portrait", then click over to the "Chart" tab. For "Printed chart size" select "Custom". Click "OK" to get back to the regular print options, and click on the PDF drop-down menu. Select "Save PDF as PostScript..." and save the file as a .ps file somewhere.

For reference, I based these directions on some information I found for windows users on the same topic.

Convert the .ps file to a .eps file

Now we have to convert the .ps file to an .eps file. While this is supposed to be a process you can do by hand, I've never had much luck doing it by hand. Instead, I suggest you use ghostview or The Gimp to convert to an .eps file. I have installed The Gimp on my Mac using fink, so that is the route that I took. Be sure to check "Encapsulated Postscript" in the Gimp when you save, and you might not want to have any offset at all. Also, you should crop the image to the correct size - The Gimp's auto-crop feature worked well for me.

Save the file with a .eps extension.

Add graphic to your LaTeX file

I use the graphicx package for graphics usually, and just include the resulting file. I usually have to reduce the size of the charts, but it all works really well.

I hope some people find this information useful. I know that I will in a few months when I ask myself "Now, how did I include that Excel chart in my last paper again?"


Comments

Provide your email address when commenting and Gravatar will provide general portable avatars, and if you haven't signed up with them, a cute procedural avatar with their implementation of Shamus Young's Wavatars.

Re: How to use Excel charts in LaTeX documents on Mac OSX
When I generated the PDF file for submission, the top margin was non-existant, and some pages had a bit of the top cut off. It turns out that this was due to a dvips assuming a default paper size of A4. Using the "-t letter" option fixed that.

Many thanks to http://www.astro.psu.edu/gradinfo/psuthesis/pdf.html
Posted 17 years, 4 months ago by fugu • • • Reply

Comments have now been turned off for this post