Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have tried to set the options in the preamble: \SweaveOpts{keep.source=TRUE, eps=FALSE, pdf=FALSE, png=TRUE}, but this does not reliably produce only .PNG (or indeed any!) figures. I say 'reliably' as I have been successful previously in getting the .PNG figures, but having made some modifications to my document (alas, unscientifically) Sweave no longer produces any figures.

share|improve this question

1 Answer 1

There is no option for automatic PNG output in the official Sweave distribution. The only options are PDF or EPS-- you are not seeing output because you have turned both of those off.

You can use whatever output device you want by forgoing the use of fig=TRUE and writing code that looks like:

\begin{figure}

\caption{Some silly plot.}
\label{fig:sillyPlot}

<<fig1>>=
png( 'fig1.png' )

# Plotting stuff.

dev.off() # <- very very important
@
\includegraphics{fig1}

\end{figure}

Instead of:

\begin{figure}

\caption{Some silly plot.}
\label{fig:sillyPlot}

<<fig1,fig=TRUE>>=

# Plotting stuff.

@

\end{figure}

The fig=TRUE option really just saves some typing by freeing you from opening the device, closing it and then inserting the \includegraphics{} command for LaTeX. If you really want fig=TRUE to support PNG output you will have to roll your own modified Sweave driver or use this one created by Thibaut Jombart.

share|improve this answer

Your Answer

 
discard

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.