From: Robert <chr.robert_at_gmail.com>

Date: Mon, 19 May 2008 07:20:06 -0700 (PDT)

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 19 May 2008 - 14:54:00 GMT

Date: Mon, 19 May 2008 07:20:06 -0700 (PDT)

The main goal is to include graphics from R in a LaTeX document. Thanks a lot for all your help - its working now.

/Robert

On 16 Maj, 17:31, "Greg Snow" <Greg.S..._at_imail.org> wrote:

> If the main goal is to include graphs created by R in LaTeX documents and have them look nice, and usingxfigwas just one way of attempting this, then here are a couple other options that may or may not work better.

*>
**> Use the postscript graphics device and use psfrag in LaTeX to replace text in plot with LaTeX commands. This is fine if you are using postscript and only have a couple of things that need to be replaced. This can be a pain if you want to replace every tick mark label with the current font in the document, or if you want to go directly to pdf without going through postscript.
**>
**> Generate pdf/eps files of the graphs using the same font as your LaTeX document (see R-news article (6)2 41-47, on ways to specify the font). This changes the font to match, but does not do arbitrary LaTeX commands.
**>
**> Create an eps file, then use eps2pgf (http://sourceforge.net/projects/eps2pgf/) to convert to a pgf file to be included in your LaTeX file (via \input{}). You need to use the pgf package in your LaTeX file, but then all the graphics are done internally using by default the same fonts as the rest of the document. You can also do psfrag like replacements when converting the file to include LaTeX commands.
**>
**> Hope this helps,
**>
**> --
**> Gregory (Greg) L. Snow Ph.D.
**> Statistical Data Center
**> Intermountain Healthcare
**> greg.s..._at_imail.org
**> (801) 408-8111
**>
**>
**>
**> > -----Original Message-----
**> > From: r-help-boun..._at_r-project.org
**> > [mailto:r-help-boun..._at_r-project.org] On Behalf Of Scionforbai
**> > Sent: Friday, May 16, 2008 6:57 AM
**> > To: Kevin E. Thorpe
**> > Cc: r-h..._at_r-project.org; Robert
**> > Subject: Re: [R] Font settings inxfig
**>
**> > > Is there a reason you are going through this route to get
**> > figures into
**> > > LaTeX instead of using postscript (or PDF for pdflatex)?
**>
**> > To have LaTeX-formatted text printed onto your pdf figures,
**> > to include in LaTeX documents.
**>
**> > R cannot output 'special' text inxfig. You need to
**> > post-process the .fig file, according to the fig format
**> > (http://www.xfig.org/userman/fig-format.html), replacing, on
**> > lines starting with '4', the correct values for font and
**> > font_flags. Using awk (assuming you work on Linux) this is
**> > straightforward :
**>
**> > awk '$1==4{$6=0;$9=2}{print}' R_FILE.fig > OUT.fig
**>
**> > Then, in order to obtain a pdf figure with LaTeX-formatted
**> > text, you need a simple driver.tex:
**>
**> > driver.tex :
**>
**> > \documentclass{article}
**> > \usepackage{epsfig}
**> > \usepackage{color} %(note: you might not might not need to do
**> > this) \begin{document} \pagestyle{empty} \input{FILE.pstex_t}
**> > \end{document}
**>
**> > Now you can go through the compilation:
**>
**> > fig2dev -L pstex OUT.fig > OUT.pstex
**> > fig2dev -L pstex_t -p OUT.pstex OUT.fig > OUT.pstex_t sed
**> > s/FILE/"OUT"/ driver.tex > ./OUT.tex latex OUT.tex dvips -E
**> > OUT.dvi -o OUT.eps epstopdf OUT.eps
**>
**> > Of course you need R to write the correct Latex math strings
**> > (like $\sigma^2$).
**> > Hope this helps,
**>
**> > scionforbai
**>
**> > ______________________________________________
**> > R-h..._at_r-project.org mailing list
**> >https://stat.ethz.ch/mailman/listinfo/r-help
**> > PLEASE do read the posting guide
**> >http://www.R-project.org/posting-guide.html
**> > and provide commented, minimal, self-contained, reproducible code.
**>
**> ______________________________________________
**> R-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
**> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
**> and provide commented, minimal, self-contained, reproducible code.
*

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 19 May 2008 - 14:54:00 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Mon 19 May 2008 - 16:30:37 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*