Configure Kile for knitr under GNU/Linux

April 13, 2013
By

(This article was first published on Rexamine » Blog/R-bloggers, and kindly contributed to R-bloggers)

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:

  1. Open Settings -> Configure Kile menu
    1. Tools -> Build in the options tree
      1. Click New and set:
        Name : knitr
        Default behavior : build
        
      2. General tab:

        Command: ~/knitr-compile.sh
        Options: '%source'
        
      3. Advanced tab:

        Type: Run Outside of Kile
        Class : Compile
        Source extension: Rnw
        Target extension: pdf
        Target file: /blank/
        Relative dir: /blank/
        State: Editor
        
      4. Menu tab:
        Add tool to Build menu: Compile
    2. Automatic syntax highlighting of .Rnw sources
      Select Editor -> Open/Save in the options tree,
      and then the Modes & Filetypes tab

      Filetype: Markup/LaTeX
      add "*.Rnw" to File extensions
      
    3. Click OK
  2. Click Settings -> Configure Shortcuts (I use ALT+1)


Marek Gągolewski

To leave a comment for the author, please follow the link and comment on his blog: Rexamine » Blog/R-bloggers.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.