如果使用以下 Sweave (R/LaTeX) 代码创建 pdf 文档,则在图的左上角将出现文本 pdf 2
;请注意,这并未嵌入 png
中,但实际上是您可以突出显示的文本。
在.Rnw
中:
\begin{figure}[htb]
\centering
<<fig=FALSE,echo=FALSE>>=
png("test0.png",width=4,height=4,units='in',res=1200)
plot(1)
dev.off()
@
\includegraphics{test0.png}
\caption{Demonstration}
\end{figure}
然后在R
中:
Sweave("report.Rnw") ; texi2pdf("report.tex")
我该如何解决这个问题?
我在 Ubuntu 上使用最新版本的 R
。
最佳答案
使用以下文件
\documentclass{article}
\begin{document}
\begin{figure}[htb]
\centering
<<fig=FALSE,echo=FALSE>>=
png("test0.png",width=4,height=4,units='in',res=1200)
plot(1)
dev.off()
@
\includegraphics{test0.png}
\caption{Demonstration}
\end{figure}
绘图前出现一条 null device 1
消息
它是生成绘图的 R 命令的输出。
您可以通过添加 results=hide
来抑制它。
<<fig=FALSE,echo=FALSE,results=hide>>=
您的消息略有不同,因为 dev.off()
返回当前设备的名称:
我的情况没有(这是一次新的 session ),
以及您之前打开(但未关闭)的 PDF 文件。
关于r - 为什么在 Sweave 中使用 includegraphics 时显示文本 'pdf 2',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19464132/