Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From   "Feiveson, Alan H. (JSC-SK311)" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   FW: st: Any way to annotate a Stata graph with LaTeX?
Date   Fri, 7 Aug 2009 09:56:54 -0500

This just came to me from a colleague. It may be out of date - but here it is, if it's of help.

Al Feiveson

-----Original Message-----
From: Fiedler, James (JSC-SK)[USRA] 
Sent: Thursday, August 06, 2009 5:44 PM
To: Feiveson, Alan H. (JSC-SK311)
Subject: RE: st: Any way to annotate a Stata graph with LaTeX?

Hello, 

[A year later...]  You know, I think I found exactly the right LaTeX package for this a while ago.  It's called overpic:
http://www.nada.kth.se/~carsten/latex/overpic.html .


What's suggested below seems like more work.  

James
________________________________________
From: Feiveson, Alan H. (JSC-SK311)
Sent: Monday, August 25, 2008 2:06 PM
To: Fiedler, James (JSC-SK)[STU]
Subject: FW: st: Any way to annotate a Stata graph with LaTeX?

Hi James - FYI -

Al

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Daniel Becker
Sent: Monday, August 25, 2008 1:59 PM
To: [email protected]
Subject: Re: st: Any way to annotate a Stata graph with LaTeX?

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/

*
*   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/



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