Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is knitr unable to find framed.sty or kpsewhich?

Tags:

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
 >

I'm on OSX Lion 10.7.3

Path for kpsewhich:

   $ which kpsewhich
    /usr/texbin/kpsewhich


$ which pdflatex
/usr/texbin/pdflatex

Both paths are in my .bash_profile in my home directory. I do have the framed package in my Tex install.

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

Solution

Adding this to my .rprofile fixed it:

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

like image 850
Maiasaura Avatar asked Mar 06 '12 19:03

Maiasaura


2 Answers

Just FYI, now knitr will automatically add /tex/texbin to PATH for Mac OS if it is not already in PATH.

like image 56
Yihui Xie Avatar answered Sep 20 '22 11:09

Yihui Xie


Installing texlive-latex-extra solved for me. The original answer (https://stackoverflow.com/a/25517332/1169233) is intended for Ubuntu, but AFAIK it should work verbatim on Mac OS too.

like image 44
Waldir Leoncio Avatar answered Sep 19 '22 11:09

Waldir Leoncio