简体   繁体   中英

Automatically update PDF as I write .Rnw file with knitr

I'm writing a .Rnw file in TextMate when using knitr to convert this file to a .tex file, then converting the .tex file a PDF. I'm wondering if there are any tools available that will automate this process, ie everytime anything updates in the .Rnw file, the PDF also updates? Using knitr to combine R and LaTeX code is great, but I think the conversion process to PDF takes up a lot of time, especially if changes to the .Rnw file are small but need to be cross-checked in the PDF file everytime they are made.

If you are on Linux use inotifywait for that. Most distributions have the package inotify-tools

Then do something like

while inotifywait -e close_write myfile.Rnw; do compile_myfile.sh; done

or

while inotifywait -e delete_self myfile.Rnw; do compile_myfile.sh; done

It depends on how your editor actually saves files. Just try and read the man page.

You have to write compile_myfile.sh of course to compile the .Rnw to .pdf - but I guess you know the commands.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM