2013-04-18 31 views
6

Tôi đã cài đặt các gói R extrafontfontcm. Sau đó cố gắng để âm mưu dữ liệu với font chữ hiện đại máy tính trong Sweave:R Sweave Computer Sử dụng phông chữ hiện đại

<<test,fig=TRUE,echo=False>>= 
plot(na, family="CM Roman") 
@ 

Nhưng nó không thành công với lỗi:

> grDevices::pdf.options(useDingbats = FALSE); utils::Sweave('test.Rnw', encoding='UTF-8') 
Writing to file test.tex 
Processing code chunks with options ... 
1 : echo keep.source term verbatim (test.Rnw:76) 
2 : keep.source term verbatim pdf (label = test, test.Rnw:80) 

Error: chunk 2 (label = test) 
Error in axis(side = side, at = at, labels = labels, ...) : 
    invalid font type 
In addition: Warning messages: 
1: In axis(side = side, at = at, labels = labels, ...) : 
    font family 'CM Roman' not found in PostScript font database 
2: In axis(side = side, at = at, labels = labels, ...) : 
    font family 'CM Roman' not found in PostScript font database 
3: In axis(side = side, at = at, labels = labels, ...) : 
    font family 'CM Roman' not found in PostScript font database 
4: In axis(side = side, at = at, labels = labels, ...) : 
    font family 'CM Roman' not found in PostScript font database 
5: In axis(side = side, at = at, labels = labels, ...) : 
    font family 'CM Roman' not found in PostScript font database 
6: In axis(side = side, at = at, labels = labels, ...) : 
    font family 'CM Roman' not found in PostScript font database 
7: In axis(side = side, at = at, labels = labels, ...) : 
    font family 'CM Roman' not found in PostScript font database 
Error in rle(filenames) : 'x' must be an atomic vector 
Calls: <Anonymous> -> <Anonymous> -> RweaveTryStop 
Execution halted 

loadfonts(device="postscript") cho thấy phông chữ là already registered with postscriptFonts()

Làm thế nào tôi có thể sử dụng nó với Sweave ?

Trả lời

2

dường như là một câu hỏi ngu ngốc và dễ dàng . Tôi cần tải các gói extrafontfontcm trong tệp Sweave của tôi:

<<setup,echo=FALSE>>= 
    library(extrafont) 
    library(fontcm) 
@ 
4

Bạn có chắc chắn đang sử dụng đúng tên không? Hãy thử điều này và xem nếu kết quả là thông tin:

> names(postscriptFonts()) 
[1] "serif"    "sans"     "mono"     "AvantGarde"   
[5] "Bookman"    "Courier"    "Helvetica"   "Helvetica-Narrow"  
[9] "NewCenturySchoolbook" "Palatino"    "Times"    "URWGothic"   
[13] "URWBookman"   "NimbusMon"   "NimbusSan"   "URWHelvetica"   
[17] "NimbusSanCond"  "CenturySch"   "URWPalladio"   "NimbusRom"   
[21] "URWTimes"    "ComputerModern"  "ComputerModernItalic" "Japan1"    
[25] "Japan1HeiMin"   "Japan1GothicBBB"  "Japan1Ryumin"   "Korea1"    
[29] "Korea1deb"   "CNS1"     "GB1"     

On xét tôi thấy rằng pdf.options đã tham gia và bạn cũng có thể cần phải xem xét:

> names(pdfFonts()) 
Các vấn đề liên quan