为什么knitr无法找到framed.sty或kpsewhich?

时间:2012-03-06 19:02:20

标签: r latex knitr

knit('test2.rnw')


processing file: test2.rnw
  |>>>>>>>>>>>>>                                                    |  20%
  |>>>>>>>>>>>>>>>>>>>>>>>>>>                                       |  40%
label: setup (with options) 
List of 2
 $ include: logi FALSE
 $ cache  : logi FALSE

sh: kpsewhich: command not found
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                          |  60%
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>             |  80%
  |>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>| 100%
  ordinary text without R code


output file: /Users/xxx/Desktop/R_meetup/documentation/test2.tex

Warning message:
In test_latex_pkg("framed", system.file("misc", "framed.sty", package = "knitr")) :
  unable to find LaTeX package 'framed'; will use a copy from knitr
 >

我在OSX Lion 10.7.3上

kpsewhich的路径:

   $ which kpsewhich
    /usr/texbin/kpsewhich


$ which pdflatex
/usr/texbin/pdflatex

这两个路径都位于.bash_profile目录中的home。我的Tex安装中有框架包。

PATH=$PATH:/usr/texbin/pdflatex
PATH=$PATH:/usr/texbin/kpsewhich
export PATH

解决方案

将此添加到我的.rprofile修复它:

Sys.setenv("PATH" = paste(Sys.getenv("PATH"),"/usr/texbin",sep=":"))

2 个答案:

答案 0 :(得分:3)

仅供参考,现在knitr会自动将/tex/texbin添加到PATH for Mac OS(如果它不在PATH中。

答案 1 :(得分:3)

安装texlive-latex-extra为我解决了。原始答案(https://stackoverflow.com/a/25517332/1169233)适用于Ubuntu,但AFAIK也应该在Mac OS上逐字处理。