sublime-ide-r icon indicating copy to clipboard operation
sublime-ide-r copied to clipboard

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

Open adibender opened this issue 6 years ago • 2 comments

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.

adibender avatar Feb 09 '19 20:02 adibender

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

randy3k avatar Aug 25 '19 09:08 randy3k

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.

pascalsiemsen avatar Feb 19 '21 15:02 pascalsiemsen