yihui/knitr — Issue #37: Error with dev = tikz, external = T
Author: mnel
Created: 2011-12-05 02:31:16+00:00
State: open

I'm in the process of converting from pgfSweave to knitr -- a great package!

The following basic code chunks (adapted from the minimal example)

```
<< setup,echo=FALSE,results=hide,message=FALSE >>=
options(replace.assign=TRUE,width=90,tikzDefaultEngine=pdfTex)
knit_hooks$set(fig=function(before, options, envir){if (before) par(mar=c(4,4,.1,.1),cex.lab=.95,cex.axis=.9,mgp=c(2,.7,0),tcl=-.3)})
@

<< boring-plots,fig=TRUE,dev=tikz,width=5,height=5,out.width=.45\linewidth, external=T >>=
par(las=1) # tick labels direction
boxplot(x)
@
```

gave the following error

```
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (MiKTeX 2.9)
entering extended mode
! I can't find file `'miminal-boring-plots.tikz''.
<*> 'miminal-boring-plots.tikz'

Please type another input file name:
! Emergency stop.
<*> 'miminal-boring-plots.tikz'

! ==> Fatal error occurred, no output PDF file produced!
Transcript written on texput.log.
Error: failed to compile figure/miminal-boring-plots.tikz to PDF
In addition: Warning message:
running command 'C:\PROGRA~2\MIKTEX~1.9\miktex\bin\pdflatex.exe 'miminal-boring-plots.tikz'' had status 1
```

The original dev = pdf works fine, as does external = F.

My R session is below:

```
library(tikzDevice)
> getOption("tikzDefaultEngine")
[1] "pdftex"
> sessionInfo()
R version 2.14.0 (2011-10-31)
Platform: i386-pc-mingw32/i386 (32-bit)

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

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

other attached packages:
[1] tikzDevice_0.6.2 pls_2.3-0 knitr_0.0.3 devtools_0.4 Cubist_0.0.8 reshape2_1.2
[7] lattice_0.20-0 Hmisc_3.9-0 survival_2.36-10 munsell_0.3 gridExtra_0.8.5 treemap_0.10
[13] RColorBrewer_1.0-5 ggplot2_0.8.9 proto_0.3-9.2 reshape_0.8.4 plyr_1.6 signal_0.7-1
[19] MASS_7.3-16 pgfSweave_1.2.1 cacheSweave_0.6 formatR_0.3-4 optparse_0.9.4 getopt_1.17
[25] highlight_0.2-5 parser_0.0-14 Rcpp_0.9.7 codetools_0.2-8 stashR_0.3-4 filehash_2.2

loaded via a namespace (and not attached):
[1] cluster_1.14.1 colorspace_1.1-0 digest_0.5.1 evaluate_0.4 RCurl_1.8-0.1 stringr_0.5
```