I want to insert a word count into my .Rnw file.
To do this, I have the following line in myfile.Rnw:
\makeatletter\@@input|"echo `texcount -1 myfile.tex`| cut -c1-4"\makeatother
But this requires me to run pdflatex with the --shell-escape flag. With Sweave, I have a makefile that includes the line:
...
R CMD Sweave myfile.Rnw
pdflatex --shell-escape myfile.tex
...
...
Is there a way to add the --shell-escape to pdflatex when I use knit instead of the makefile to compile the document?
Reproducible example:
contents of myfile.Rnw:
\documentclass{article}
\begin{document}
Words: \makeatletter\@@input|"echo `texcount -1 myfile.tex`| cut -c1-4"\makeatother
Lorem ipsum dolor
\end{document}
what works:
R CMD Sweave myfile.Rnw
pdflatex --shell-escape myfile.tex
what doesn't work:
knit("myfile.Rnw")
"myfile.pdf" %in% dir() ## False