1

I'm having an issue with TeXlipse where I'm generating a plot in Eclipse via Sweave, and the TeX file seems to be jamming all of my PDF plots in the left most corner of the page. This is driving me crazy. I'm not sure what SweaveOpts might fix this, but \oddsidemargin, \evensidemargin, \begin{centering}, and \SweaveOpts{width=x, height=y} does not help. My code is below:

Sweave Code:

\documentclass{article}
\usepackage{Sweave}
\usepackage{graphicx}
\SweaveOpts{prefix.string=C:/SweavePlots/bar}
\DeclareGraphicsExtensions{.pdf} 

...

\begin{figure}
\begin{center}

<<figname, fig=TRUE, include=TRUE, echo=FALSE>>=

    plot(1:10)

@
\caption{I hope this Works}
\end{center}
\end{figure}

TeX Code:

\begin{figure}

\begin{center}

\includegraphics{C:/SweavePlots/bar-figname}

\caption{I hope this Works}

\end{center}

\end{figure}

Resultant Figure: enter image description here

4

1 回答 1

0

I found out that since the more recent versions of R only produce PDFs and I'm trying to use DVI, I need to explicitly set \SweaveOpts{eps=true}. The bottom line is that PDF images just don't get along well with DVI viewers like Yap. My successful code is as follows:

% 
\documentclass{article}
\usepackage{Sweave}
\usepackage{graphicx}
\SweaveOpts{prefix.string=C:/SweavePlots/bar}
\SweaveOpts{eps=true}
\DeclareGraphicsExtensions{.eps} 


\title{SweavePlotWithEPS}
\author{user992432}

\begin{document}

\maketitle

\begin{figure}
\begin{center}

<<figname, fig=TRUE, include=TRUE, echo=FALSE>>=
plot(1:10)
@
\caption{I hope this Works}
\label{fig:one}
\end{center}
\end{figure}


\end{document}

Successful plot with a .eps file.

于 2013-05-15T01:37:56.237 回答