1

I can't seem to get knitr to work with tikzdevice. A simple example:

\documentclass{article} 
\begin{document} 
<<test, dev='tikz'>>=
library(knitr)
library(tikzDevice)
library(ggplot2) 
plot(1) 
@ 
\end{document} 

produces:

Quitting from lines 4-5 (testets.Rnw) 
Error in system(latexCmd, intern = T, ignore.stderr = T) : 
'C:\Program' not found
Calls: knit ... print.recordedplot -> replayPlot -> <Anonymous> -> getMetricsFromLatex

It seems clear to me that there is a problem with the path including spaces - my LaTeX installation is under "C:\Program Files\" but I'm at a loss as how to fix that short of re-installing Latex. For what it is worth, knitr works fine as long as I don't call tikzDevice and MikTeX + tikz works fine outside of knitr.

sessionInfo() produces:

R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_1.0.0    tikzDevice_0.8.1 knitr_1.8       

loaded via a namespace (and not attached):
[1] colorspace_1.2-4 digest_0.6.8     evaluate_0.5.5   filehash_2.2-2   formatR_1.0      grid_3.1.2       gtable_0.1.2    
[8] labeling_0.3     MASS_7.3-35      munsell_0.4.2    plyr_1.8.1       proto_0.3-10     Rcpp_0.11.3      reshape2_1.4.1  
[15] scales_0.2.4     stringr_0.6.2    tools_3.1.2   
  • library(knitr); library(tikzDevice); sessionInfo() please. – Yihui Xie Jan 7 '15 at 23:45
  • @Yihui: Including library(knitr); library(tikzDevice) gives exactly the same results. Result of `sessionInfo()' added to post above b/c of character limit in comments. – Indridi Indridason Jan 8 '15 at 4:51
  • Thanks! We just uploaded a new version of tikzDevice to CRAN yesterday, and could you update.packages(ask = FALSE, repos = 'http://cran.rstudio.com') then retry? If the problem still persists, please file an issue to github.com/yihui/tikzDevice/issues – Yihui Xie Jan 8 '15 at 6:11
  • @Yihui: Thanks, I tried that but the problem still persists. – Indridi Indridason Jan 8 '15 at 23:53
  • @IndridiIndridason The same error with the latest version of tikzDevice? If the error message is different, could you update your sessionInfo() and the error message in the post? – Yihui Xie Jan 9 '15 at 1:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.