REditorSupport / sublime-ide-r

R-IDE: Make Sublime Text a perfect IDE for R
MIT License
112 stars 7 forks source link

Feature request: Build With: R Sweave knitr executes main document instead of child #26

Open adibender opened 5 years ago

adibender commented 5 years ago

LaTeXTools: allows to place something like %!TEX root = main.tex at the top of a .tex file that is included in main.tex and when the build is triggered, main.tex is build instead of the child document. It would be nice to have similar feature for .Rnw (and .Rmd) files.

randy3k commented 4 years ago

It would be a bit tricky, for instance, consider that TEX root could be also a Sweave file.

pascalsiemsen commented 3 years ago

I know that this is an old post but the following settings get the job done:

Create a custom ride_exec command where you replace the standard '$file_name' with your main file. In my case it is index.Rnw. This can be done in the R-IDE settings.

{ "caption": "Knit Rnw Index", "cmd": "knitr::knit2pdf('index.Rnw',compiler = 'xelatex')", "working_dir": "$file_path", "selector": "text.tex.latex.rsweave" }

You can also create a keybinding for this command that only works for rsweave

{"keys": ["ctrl+alt+b"], "command": "ride_exec", "args": {"cmd": "knitr::knit2pdf('index.Rnw',compiler = 'xelatex')", "selector": "text.tex.latex.rsweave", "working_dir": "$file_path"}, "context": [ { "key": "selector", "operator": "equal", "operand": "text.tex.latex.rsweave" } ]}

But cmd/ctrl+b let's you also choose resp. just uses the command created above. So I just use that.

Hope that helps.