[R] Latex Question

Christophe Declercq cdeclercq at nordnet.fr
Fri Dec 7 11:35:02 CET 2001


Hi, Brian

> De : owner-r-help at stat.math.ethz.ch
> [mailto:owner-r-help at stat.math.ethz.ch]De la part de Brian Scholl
> Envoyé : vendredi 7 décembre 2001 04:57
> À : r-help at stat.math.ethz.ch
> Objet : [R] Latex Question
>
>
> Sorry this is more of a Latex than an R question. I'd
> like to be able to insert figures created in R in a
> Latex document.  I'm a bit new to Latex so please
> speak slowly.   I'm using winedt/miktex (great
> programs incidentally).

You need the 'graphicx' package with different options if you use LaTeX
or pdfLaTeX.
A short (and dummy) example:

1) LaTeX

Use the postscript device in R:

> postscript("fig1.eps", horizontal=FALSE, onefile=FALSE, width=8,
height=8)
> plot(1:10, rnorm(10))
> dev.off()

Put in your LaTeX document preamble something as:

\usepackage[dvips]{graphicx}

and where in the document you want the figure:

\includegraphics[width=\textwidth]{fig1.eps}

2)pdfLaTeX

Use the pdf device in R:

> pdf("fig1.pdf", width=8, height=8)
> plot(1:10, rnorm(10))
> dev.off()

Put in your LaTeX document preamble something as:

\usepackage[pdftex]{graphicx}

and where in the document you want the figure:

\includegraphics[width=\textwidth]{fig1.pdf}

To know more,  you could read:
- '?postscript 'and '?pdf' in R
- 'The not so Short Introduction to LaTeX2e'
(http://www.ctan.org/tex-archive/info/lshort/english/lshort.pdf).

Hope it helps.

Christophe
--
Christophe DECLERCQ, MD
Observatoire Régional de la Santé Nord-Pas-de-Calais
13, rue Faidherbe 59046 LILLE Cedex FRANCE
Phone +33 3 20 15 49 24
Fax   +33 3 20 55 92 30
E-mail c.declercq at orsnpdc.org

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list