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