Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: re: inclusion of EPS in pdflatex documents


From   Ian Watson <i.watson@econ.usyd.edu.au>
To   statalist@hsphsun2.harvard.edu
Subject   st: re: inclusion of EPS in pdflatex documents
Date   Sat, 2 Apr 2005 12:52:35 +1000

Tze Kwang Teo wrote:

> I have been encountering the same problem while using Adobe Acrobat
> Distiller to convert EPS graphics from Stata into PDF. The problem is 
> that after conversion, I view the resultant PDF and the graph is always 
> "embedded" in a 8.5in by 11in "canvas" even though the graph is several 
> sizes smaller than letterpaper size. In other words a lot of 
> white-space is created that should not be part of the graph.
> 
> I have been attempting EPS -> PDF conversion because for a variety of 
> reasons I need to use the pdfLaTeX driver (I typeset in LaTeX) ...

and Kit Baum replied in part:

>  I use pdflatex (driven by
> TeXShop on OS X) routinely with eps files as the only form of graphical 
> input.
> 
> % Encapsulated PostScript figures
> \usepackage{epsfig}

While Kit's approach works fine for B&W graphs, I have found problems
in getting good colour graphs into LaTeX (without them being
bitmapped). The solution was suggested on this list some time ago and I
have been using the solution for several months with very good
results. I now use it all the time for both B&W and colour graphs.

Basically, the answer lies in a little ado program (-grexportpdf-)
written by Philippe Van Kerm and kindly provided to the list. His code
for - grexportpdf- (modified for the correct path names to your latex
installation and with erasing the eps file turned off) is shown below:

*! grexportpdf 1.0, Ph. Van Kerm, Aug-2003
* grexportpdf using path/filename

cap pr drop grexportpdf
pr def grexportpdf
     version 8
     syntax using /
     loc using=subinstr("`using'",".pdf","",.)
     gr export "`using'.eps", replace
     winexec c:\texmf\miktex\bin\epstopdf "`using'.eps"
*     erase "`using'.eps"
end


The steps for using it are simple:

Stata commands to create and save your own graph

then:

gr use mygraph.gph
grexportpdf using c:\data\report\mygraph

or wherever you want to send it.


This creates the mygraph.pdf file for inclusion in LaTeX using:

\includegraphics[width=.75\linewidth,trim= 0 -10 0 -10]{mygraph}

with settings which can be tweaked to get the best distance between
Figure headings and captions etc.

Make sure you have a

\usepackage{graphics}

line in your LaTeX preamble.

--
Kind regards, 
Ian

-------------------------------
Ian Watson
Senior Researcher
acirrt, University of Sydney
NSW, 2006, Australia

phone: 02 9351 5622
email:i.watson@econ.usyd.edu.au
www.acirrt.com
-------------------------------

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index