0
我想在我的.Rnw
beamer演示文稿中使用自定义字体。再现误差的最小工作的例子是:用sweave和beamer自定义ggplot字体
\documentclass{beamer}
\begin{document}
\begin{frame}[plain]
<<echo=FALSE>>=
library(ggplot2)
library(extrafont)
@
\begin{figure}
\centering
<<label = test, fig=TRUE, include=FALSE, echo=FALSE, message=FALSE>>=
ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() +
ggtitle("Fuel Efficiency of 32 Cars") +
xlab("Weight (x1000 lb)") + ylab("Miles per Gallon") +
theme_bw() +
theme(text=element_text(family="Garamond", size=14))
@
\includegraphics[width=\textwidth]{test}
\end{figure}
\end{frame}
\end{document}
和错误消息是这样的:
Writing to file test.tex
Processing code chunks with options ...
1 : keep.source term verbatim (test.Rnw:6)
Registering fonts with R
2 : keep.source term verbatim pdf (label = test, test.Rnw:12)
Error in grid.Call.graphics(L_text, as.graphicsAnnot(x$label), x$x, x$y, :
invalid font type
Calls: <Anonymous> ... drawDetails -> drawDetails.text -> grid.Call.graphics
In addition: There were 50 or more warnings (use warnings() to see the first 50)
Execution halted
但是,当我在控制台中使用ggplot命令,一切都看起来不错。
任何帮助将不胜感激。
的唯一方法我可以重现你的错误,使用.Rnw文件,是,如果我尝试使用不是已经安装的字体。在控制台中,如果我尝试使用卸载的字体,R将恢复为默认字体并发出警告。 –
这很奇怪。如果我查看'fonts()',我清楚地看到字体已经安装好了,我想可以通过'extrafont'访问。 – Pascal