highlight 0.2-5
By romain francois on Tuesday, December 7 2010, 12:10 - highlight - Permalink
I pushed highlight 0.2-5 on CRAN. This release improves the latex renderer and the sweave driver so that multiple lines character strings are properly rendered.
This example vignette shows it:
\documentclass[a4paper]{report} \begin{document} <<echo=FALSE,results=hide>>= old.op <- options( prompt = " ", continue = " " ) @ <<>>= require( inline ) require( Rcpp ) convolve <- cxxfunction( signature( a = "numeric", b = "numeric" ), ' NumericVector xa(a); int n_xa = xa.size() ; NumericVector xb(b); int n_xb = xb.size() ; NumericVector xab(n_xa + n_xb - 1,0.0); Range r( 0, n_xb-1 ); for(int i=0; i<n_xa; i++, r++){ xab[ r ] += noNA(xa[i]) * noNA(xb) ; } return xab ; ', plugin = "Rcpp" ) convolve( 1:4, 1:5 ) @ <<echo=FALSE,results=hide>>= options( old.op ) @ \end{document}
Once processed with Sweave, e.g. :
require( highlight ) driver <- HighlightWeaveLatex(boxes = TRUE) Sweave( 'test.Rnw', driver = driver ) texi2dvi( 'test.tex', pdf = TRUE )
we get this result, embedded below with google viewer:
See this question on stack overflow for the tip of using google documents to display pdf files
Comments
Thanks for the great job, Romain.
Is there a way to center the figures without affecting the code (still align to the left)? This driver does not use the Verbatim environment, and I don't want to manually insert LaTeX code like begin{center} around my figures. There is no way in Sweave to specify the alignment of figures, AFAIK. Currently I have to sacrifice the highlighting feature when I want to produce plots in Sweave (i.e. use Sweave's default Verbatim environment).
Ah yes. I keep forgetting about this. I'll try next time around. I use code more often than figures, so it skips my mind.
Great!! I've been longing for this for months...
Obviously, contributions are welcome
https://r-forge.r-project.org/proje...