highlight 0.2-5

December 7, 2010
By

(This article was first published on Romain Francois, Professional R Enthusiast, and kindly contributed to R-bloggers)

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

To leave a comment for the author, please follow the link and comment on his blog: Romain Francois, Professional R Enthusiast.

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...

Tags: , ,

Comments are closed.