Open EmmanuelCharpentier opened 6 years ago
We really need to switch to tinytex::latexmk()
in the future when compiling LaTeX files in this package. It is possible to enable -shell-escape
in tinytex through an R option.
It is possible to enable -shell-escape in tinytex through an R option.
How ?
> library(tinytex)
> grep("tiny", names(options()), value=TRUE)
character(0)
Apparently, there is no tinytex-specific option. An the doc doesn't say pip about it.
Unless you mean the tikz(L|Xel|Lual)atex
options ? I tried to set the tikzDefaultEngine
, to no avail. I'll try to modify one of these directlty (but not until a few hours...).
Note that tikzDevice does not use tinytex at the moment. If it does in the future, the option would be options(tinytex.engine_args = '-shell-escape')
.
I tried :
options(tikzLatexDefault="/usr/bin/pdflatex -shell-escape") options(tikzLatex="/usr/bin/pdflatex -shell-escape")
to no avail. Same error :
! Package minted Error: You must invoke LaTeX with the -shell-escape flag.
Ditto for :
options(tikzLatexDefault="/usr/bin/pdflatex --shell-escape") options(tikzLatex="/usr/bin/pdflatex --shell-escape")
Really stuck...
You don't need to try anything, because I don't think the current version of tikzDevice supports custom arguments for the LaTeX engine.
Okay. My current conclusion is that tikzDevice
and packages (such as minted
) needing special LaTeX flags are (currently) mutually incompatible.
One might write shell script calling LaTeX with the needed flag and trying to convince tikzDevice
to use that, but that would be 'orribly nonportable and fragile..
IMHO, it's either a design error or a bug. That should be fixed. Even if LaTeX user are scarce...
Since tinytex
is now mandatory (a call to tikzDevice
(at least from knitr
) fails if tinytex
is not installed), this problem could be fixed in tinytex
.
But I'm not yet convinced of the necessity of such a package. More on this in a future issue, either here or in a tinytex issue : I need to think it over...
BTW : the dependency of tikzDevice
on tinytex
should be explicitly documented.
The tikzDevice package does not depend on tinytex (at least currently). The dependency in knitr has been documented: https://github.com/yihui/knitr/releases/tag/v1.19
tinytex is a fairly lightweight R dependency, and I should make it clear that it does not require TinyTeX (the custom LaTeX distribution). You can use whatever your favorite LaTeX distribution is.
I'm not interested in convincing you of the many advantages of tinytex including the possibility of setting -shell-escape
(I've said enough about other advantages in the documentation), but I'll be happy to know your counterpoints (i.e., why it is bad).
Two things :
I found a workaround for my shell-escape
problem : set the chunk option external
to FALSE
, and the figure will be compiled during the compilation of the main text, whose options are controlled by AUCTeX. Of course, I lose (part of) the benefit of caching...
About tinytex
: I think that it is a great idea, provided that it doesn't try to interfere with an existing (especially systemwide, as in most Linux and some Windows machines) TeX installation. More on this after a bit more exploration (and maybe a more mature version of tinytex
).
And again : your work on knitr
and tikzDevice
is outstanding, and has eased the production of reproducible reports for millions of users. The fact that I'm more fond of \LaTeX than of markdown
is also a question of personal preferences and past experience... BTW, I discovered docbook
and started to explore it. I'm not yet convinced that this solution is simpler that using \LaTeX for a complex report or book ; however, it has the great advantage of not being "paper-bound", as \LaTeX is ; it has therefore a great potential for not-printed documents, which are becoming more and more prevalent.
So don't take my remarks as gratuitous criticism : I aim to constructive criticism (but my aim might be somewhat shaky...).
Since I still think that tikzDevice
should be able to enable shell-escape
, I leave this issue open. Feel free to close it if you feel that this need is too marginal or the benefit (caching of compiled figures) too small to bother...
I have proposed a (partial) solution to this annoyance. There remains problems probably attributable to the way knitr
invokes its compilers. I consider them a separate issue, since the proposed solution allows a correct compilation using other compiler systems (e. g. AUCTeX...).
HTH,
I am stuck with the following problem :
I a .Rnw file, i want to use the
minted
package, which needs to write files and therefore uses the-shell-escape
flag on the latex command line. This is done automagically by my working environment (emacs
+ AUCTeX).When
knitr
ing a.Rnw
file with an R chink generating a figure :tikzDevice
builds a.tex
file using (most of) the master file's preamble (hence uses\usepackage{minted}
if present).tikzDevice
calls (pdf|xe|lua)latex on this file, without using the-shell-escape
flagThe first invocation of
tikz
fails with the message :This log file has :
tikzDevice
currently does not seem to offer a way to add this flag to the (pdf|xe|lua)latex invocation (I checked that this cannot be done by settingtikzDefaultEngine
).It goes without saying that the same .Rnw file without
\usepackage{minted}
compiles perfectly...I'm stuck...