Blog

Posted 2011/05/03

Excel charts to LaTeX

I am working on a paper with one of our students. He has his draft in Word, with the charts in Excel. It is time to get the paper into LaTeX so he is charged with exporting the charts into a format I can consume. The best format is EPS or PDF and it turns out that Word can now save a chart as a PDF (it was not this easy back in the day).

In Excel:

  1. Select your chart
  2. File -> Save as
  3. Select PDF or XPS
  4. An options dialgogue box will open. Under Publish what select Selected chart

At this point you have a PDF of your chart but it has a big white space around it. To trim the white space you can use a program like Acrobat Professional. Or if (like me) you have an Apple Mac you can trim using the built in PDF support.

To trim on the Mac:

  1. Open the PDF in preview
  2. Select the part of the chart you want with the rectangular select tool
  3. Edit -> Copy
  4. File -> New from Clipboard
  5. Save your new chart as a PDF

To use your PDF in LaTex:

\begin{figure}[!t]
\centering
\includegraphics[width=8.10cm]{motivation.pdf}
\caption{Caption goes here.}
\label{figure:motivation}
\end{figure}

If you forget to add the correct graphics package to your preamble you will see this error:

   paper.tex:252: Undefined control sequence.
   l.252 \includegraphics
                        [width=8.10cm]{motivation.pdf}
   ?

You need to use this package to import your PDF graphics:
\usepackage[pdftex]{graphicx}