Tuesday, February 19, 2013

Onepager Now with knitR

Since at some point I had trouble with a conflict between knitr and the latex package textpos, I used the lesser Sweave in Another Experiment with R and Sweave.  I ran the Sweave2knitr command and discovered that textpos and knitr play well together now.  Here is the result using knitr (go to https://www.box.com/s/4nftk6qpa0cugapmncsn if the embed does not show below):

.rnw source file from Gist

2 comments:

  1. Thanks a lot for sharing!

    got it to work right away with the following:

    ### Delete these 3 lines from onepager+with+knitR.Rnw
    <>=
    opts_chunk$set(concordance=TRUE)
    @

    Execute the following in R:

    ### Load the knitr package
    library(knitr)

    ### Set knitr options
    opts_chunk$set(echo=FALSE, concordance=TRUE)

    ### Create a dated file name for the output file
    onepagereportdated <- paste0("onepager+with+knitR_",format(Sys.time(),"%Y%m%d"),".tex")

    ### Run knitr on the .Rnw file to produce a .tex file
    knit("onepager+with+knitR.Rnw",output=onepagereportdated)

    ### Run texi2pdf on the .tex file within R or process it from your latex system
    tools::texi2pdf(onepagereportdated)

    ReplyDelete
  2. Playing around with this and your previous post on sweave, I discovered that:

    \section*{\Huge etc. --> okay

    \section{\Huge etc. --> not okay

    Omitting the star led to uninformative error messages and failure to compile altogether.

    It's most likely related to the tufte class, which I'm not familiar with.

    ReplyDelete