Configure Kile for knitr under GNU/Linux
[This article was first published on Rexamine » Blog/R-bloggers, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Kile
– a convenient LaTeX editor – may also be used to prepare knitr
-generated reports. Here is how we may make our work much more efficient with a convenient compile-on-keypress feature.
Create a bash
script in your home directory, named e.g. ~/knitr-compile.sh
:
#!/bin/bash echo "Compiling $1 with LC_CTYPE=pl_PL.UTF-8..." LC_CTYPE="pl_PL.UTF-8" Rscript -e "knitr::knit2pdf('$1')"
Give the above file EXEC perms by calling chmod 700 ~/knitr-compile.sh
Now it’s time to configure Kile
:
- Open
Settings -> Configure Kile
menuTools -> Build
in the options tree- Click
New
and set:Name : knitr Default behavior : build
-
General
tab:Command: ~/knitr-compile.sh Options: '%source'
-
Advanced
tab:Type: Run Outside of Kile Class : Compile Source extension: Rnw Target extension: pdf Target file: /blank/ Relative dir: /blank/ State: Editor
-
Menu
tab:
Add tool to Build menu:Compile
- Click
-
Automatic syntax highlighting of .Rnw sources
SelectEditor -> Open/Save
in the options tree,
and then the Modes & Filetypes tabFiletype: Markup/LaTeX add "*.Rnw" to File extensions
-
Click
OK
-
Click
Settings -> Configure Shortcuts
(I useALT+1
)
To leave a comment for the author, please follow the link and comment on their blog: Rexamine » Blog/R-bloggers.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.