TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use the following Sweave template to get R output into LaTeX.

\SweaveOpts{pdf=TRUE, png=FALSE, eps=FALSE, echo=FALSE, prefix=FALSE, width=6, height=6, res=300}





<<label=FigureLabel, fig=TRUE, include=FALSE>>=
boxplot(Ozone ~ Month, data = airquality)

  \includegraphics[width=17cm, height=17cm]{FigureLabel}


This Sweave template produces R graphs in PDF format. With png=TRUE in SweaveOpts I can also get R graphs in PNG format.

Now I'm inclined to use TikZDevice and pgfSweave. As I know TikZDevice and pgfSweave produce TeX documents only not PDF. I wonder if there is a way to get figures in PDF and PNG format using SweaveOpts in some way. Thanks in advance for your help.

share|improve this question

Try knitr, a "drop-in replacement" for Sweave. With standard settings, it produces a .tex file with TikZ code that is then compiled to PDF and included in your document, automagically.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.