knitr →LATEX→ HTML testing

September 18, 2012@ 13:10

1 introduction

I have been trying to find an Sweave LATEX HTML pathway that works via knitr

I think I can get it to work now, although it’s not as pretty as I’d like. The bottom line is that to get this working you need to

2 example

## normally also include=FALSE 

(An equation)

a+ b

Some code:

## heres a comment ... 
(x  52)  
[1] 25  
y  17  

A figure:

plot(rnorm(10), rnorm(10))  


Inline R expression: the value of x is 25.

Session info:

R Under development (unstable) (2012-07-27 r60013) 
Platform: i686-pc-linux-gnu (32-bit) 
 [1] LC_CTYPE=en_CA.utf8       LC_NUMERIC=C 
 [3] LC_TIME=en_CA.utf8        LC_COLLATE=en_CA.utf8 
 [5] LC_MONETARY=en_CA.utf8    LC_MESSAGES=en_CA.utf8 
 [7] LC_PAPER=C                LC_NAME=C 
 [9] LC_ADDRESS=C              LC_TELEPHONE=C 
attached base packages: 
[1] stats     graphics  grDevices utils     datasets  base 
other attached packages: 
[1] knitr_0.8 
loaded via a namespace (and not attached): 
[1] digest_0.5.2   evaluate_0.4.2 formatR_0.6    plyr_1.7.1 
[5] stringr_0.6    tools_2.16.0  

3 issues

4 references

5 latexml

latexml is an alternative conversion program that I haven’t managed to get working equally well …

system(latexml --dest=’knitr_listings_test.xml knitr_listings_test.tex) 
system(latexmlpost --dest=’knitr_listings_test.xhtml knitr_listings_test.xml)  

6 myhtml.cfg

  %% the following is from
  %%         how-to-get-tex4ht-to-respect-listings-styling-better
  %% it’s supposed to get listings looking nice, but works with
  %% standard listings output -- rather than output generated by
  %% Sweavel.sty, which defines new listing environments
  %% Sinput, Scode, Soutput ... ???
    \Css{div.lstinputlisting table.caption {
       background: rgb(64,128,64);
       color: white;
       font-family: sans-serif;
       padding-right: 100\%;
       div.lstinputlisting .pcrro7t- {
         color: red;
   %% the following is from
           {\Needs{"convert \csname Gin@base\endcsname.pdf
                                 \csname Gin@base\endcsname.png"}%
            \Picture[pict]{\csname Gin@base\endcsname.png}%