【问题标题】:R Sweave Computer Modern font usageR Sweave Computer Modern 字体使用
【发布时间】:2013-04-12 00:26:06
【问题描述】:

我已经安装了 R 包 extrafontfontcm。然后尝试在 Sweave 中使用 Computer Modern 字体绘制数据:

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

但它失败并出现错误:

> 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") 显示字体为already registered with postscriptFonts()

如何将它与 Sweave 一起使用?

【问题讨论】:

    标签: r fonts sweave


    【解决方案1】:

    您确定您使用的名称正确吗?试试这个,看看结果是否有用:

    > 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"                 
    

    在审核时,我发现涉及 pdf.options,您可能还需要检查:

     > names( pdfFonts() )
    

    【讨论】:

      【解决方案2】:

      似乎是一个愚蠢而简单的问题。我需要在我的 Sweave 文件中加载 extrafontfontcm 包:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-03-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-01-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多