I'm trying to convert a .Rnw document to latex (to be included in another .tex-document). All plots are generated using the tikz
device, but each of them as a standalone document. My goal is to have them in tikzpicture
environments.
According to the knitr documentation on plots, it should be possible to pass standAlone=FALSE
via the dev.args
-list. This produces the error message formal argument "standAlone" matched by multiple actual arguments
. Knitr issue #514 describes the same error message, but their solution doesn't work here.
To reproduce, run knitr::knit("mwe.Rnw")
on the following file:
\section*{MWE}
<<echo=FALSE,dev="tikz",dev.args=list(standAlone=FALSE)>>=
plot(x=1:10)
@
Error message:
Quitting from lines 3-4 (mwe.Rnw)
Error in tikzDevice::tikz(..., packages = c("\n\\nonstopmode\n", packages, :
formal argument "standAlone" matched by multiple actual arguments
According to tikzDevice documentation, standAlone=FALSE
should be the default anyway, no idea why this doesn't apply here.
Any help is greatly appreciated. A seemingly related, but less specific, question has been posted but without answer.
> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.2
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
knitr_1.27
tikzDevice_0.12.3
The argument standAlone
is controlled by the chunk option external
, so what you need is:
<<dev="tikz", external=FALSE>>=