3

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

\documentclass[a4paper]{article}
\SweaveOpts{pdf=TRUE, png=FALSE, eps=FALSE, echo=FALSE, prefix=FALSE, width=6, height=6, res=300}

\title{Title}
\author{Author}

\begin{document}

\maketitle


<<>>=
data(airquality)

\begin{center}
<<label=FigureLabel, fig=TRUE, include=FALSE>>=
boxplot(Ozone ~ Month, data = airquality)
@

\begin{figure}[h]
  \centering
  \includegraphics[width=17cm, height=17cm]{FigureLabel}
  \caption{Caption}
  \label{fig:figLabel}
\end{figure}

\end{document}

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.

1 Answer 1

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .