Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I will be using Microsoft Excel to produce graphs and I was wondering if there was a simple way to put those graphs into a LaTeX document?

share|improve this question
You have to export the graphs to eps or pdf or jpg and then include them with \includegraphics{}. – Sigur Dec 28 '12 at 23:06
So I just save the graphic to .eps, .pdf or .jpg? I have heard that .png is the best file format to use? Is this right? – CAF Dec 28 '12 at 23:13
@CAF: No, PNG is a raster format, which means it is not scalable. PDF or EPS are much better. – C.R. Dec 29 '12 at 0:56

2 Answers

up vote 12 down vote accepted

You can put the graph as a seperate document tab (opposed to inside a sheet). Then you can print it to PDF, using either some installed PDF printer or the Office built-in PDF printer. Then you can include the graph using the package graphicx and the command \includegraphics[width=\linewidth]{graph.pdf}.

You can as well download the TeX fonts as OTF and use them in Office, achieving the font consistency. The basic Computer Modern can be gotten here in the renewed version Latin Modern:

http://www.gust.org.pl/projects/e-foundry/latin-modern/download

share|improve this answer
2  
Or use the data points and plot the graph using pgfplots or tikz. – Harish Kumar Dec 28 '12 at 23:11
@HarishKumar TBH, If I had to do it, and I had some calculations in Excel, I would prefer exporting the graphs, and would only care about the proper font family and eventually font size. – tohecz Dec 28 '12 at 23:13
Where you say save to pdf, could I use png? I have heard this is the most reliable format. If so, why? – CAF Dec 28 '12 at 23:20
2  
In this case, pdf is certainly better, because png is raster graphics, making it badly scalable. For this, you are safe with pdf because you don't use any special functions (hyperlinks, embedded videos or who-knows-what). – tohecz Dec 28 '12 at 23:24
I have tried this code, but the following error message appears: 'The required file tex\context\base\supp-pdf.mkii is missing. It is part of the following package: mptopdf. The package will be installed from: (link to choose repository directory). It then allows an option to install, but I have clicked this and the exact same message appears again and again... Any ideas? – CAF Dec 29 '12 at 9:02
show 3 more comments

In addition to what the other posters said it is worth mentioning that one can also use VBA code to create regular exports from Excel, quite helpful if you need to repeat the exports because the data have changed.

A while ago I wrote a blogpost on this, the following VBA code is taken from this post:

Sub ExportAllCharts()

    If ActiveSheet.ChartObjects.Count > 0 Then
        For Each Diagram In ActiveSheet.ChartObjects
            ActiveSheet.ChartObjects(Diagram.Name).Activate
            Filename = ActiveChart.Name
            ActiveChart.Axes(xlValue).MajorGridlines.Select
            ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "C:\" & Filename, Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
        Next Diagram
    End If

End Sub
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.