# Re: st: Any way to annotate a Stata graph with LaTeX?

 From Daniel Becker To statalist@hsphsun2.harvard.edu Subject Re: st: Any way to annotate a Stata graph with LaTeX? Date Mon, 25 Aug 2008 20:58:59 +0200

Am 25.08.2008 um 10:52 schrieb Richard Sperling:

Has anyone developed a way or method to incorporate LaTeX formatted
text into a Stata graph? It would be great if the Stata graph editor
had the capability to generate LaTeX formatted annotations. For Mac
users, I have in mind something along the lines of the program LaTeXiT
that allows one to add snippets of LaTeX text to Powerpoint or Keynote
presentations.


My way is: Exporting the Stata graph as an eps, then using a .tex file like the one posted below. This file is then typeset by the following sequence of commands aslo posted below (in TeXShop, a Mac-Frontend for LaTeX, I do this via an "engine file" epsoverlay)

If anyone is interested, I could provide more details how to prepare your system to do all this. It assumes that the command epspdf exists, for instance. Of course this is not very convenient, at first sight, but works for me. It is even possible to use pstricks ...

Daniel

++++++++++++++++++++++ start sequence of commands

#!/bin/tcsh

set path= ($path /usr/texbin /usr/local/bin) set filename = "$1"
set dviname = "${filename:r}.dvi" set psname = "${filename:r}.ps"
set pdfname = "${filename:r}.pdf" set pdfnamebb = "${filename:r}-bb.pdf"
set epsnamebb = "${filename:r}.eps" set auxname = "${filename:r}.aux"
set logname = "${filename:r}.log" # run latex via ghostscript on the tex-file latex --shell-escape "$1"
dvips -Ppdf -o "$psname" "$dviname"
ps2pdf13 -dAutoRotatePages=/None "$psname" "$pdfname"

# calculate bounding box
epspdf -bb "$pdfname" "$epsnamebb"
epspdf -bb "$pdfname" "$pdfnamebb"

# clean up

/bin/rm "$pdfname" /bin/rm "$dviname"
/bin/rm "$auxname" /bin/rm "$psname"
/bin/rm "$logname" #rename pictures mv "$pdfnamebb" "$pdfname" +++++++++++++ start LaTeX file %!TEX TS-program = epsoverlay \documentclass{article} \usepackage{graphicx} \usepackage{pstricks} \usepackage{pstricks-add} \usepackage{pst-plot} \usepackage{pst-text,pst-node,pst-tree} \begin{document} \pagestyle{empty} \newsavebox{\Imagebox} %%%% %%%% HERE: Load the eps-file %%%% \savebox{\Imagebox}{\includegraphics{kpath.eps}} \centering %%%% %%%% HERE: add LaTeX/pstricks %%%% \begin{pspicture}(\wd\Imagebox,\ht\Imagebox)% \rput[lb](0,0){\usebox{\Imagebox}} % grid to see coordinates, comment out when done \psgrid[subgriddiv=0,griddots=1,gridlabels=7pt]% (0,0)(\wd\Imagebox,\ht\Imagebox) % Add labels etc here: \rput{0}(5.9,3.9){$b = 1$} \rput{0}(3.4,2.2){$b = 5 $nicht verwendet} \rput{0}(2.9,1.2){$b = 10 $} \rput{0}(0.5,8.1){$k(t)$} \rput{0}(6.7,0.4){$t\$}
\end{pspicture}

\end{document}
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/