# Combining Sweave and fancyvrb

3 messages
Open this post in threaded view
|

## Combining Sweave and fancyvrb

 I find Sweave very useful and I was trying to combine it with the latex package fancyvrb. I was trying to get line numbering and labels in order to reference the lines where particular commands occur. Unfortunately, I haven't been able to figure out how to do it. Maybe somebody can help me. The following is a sample Rnw file: the first part shows what I would like to get, the second what I tried but didn't work. \documentclass[12pt]{article} \usepackage{/usr/local/R-2.7.0-inst/share/texmf/Sweave} \usepackage{fancyvrb} \DefineVerbatimEnvironment{Rcode}{Verbatim}{%   commentchar=@,   frame=lines, label=\textrm{\bf R code}, numbers=left,   framesep=10pt, fontshape=sl, commandchars=\\\{\}} \SweaveOpts{keep.source = TRUE} \begin{document} I would like to produce something like the following, but using Sweave. Note the label on line \ref{Rcode:sum}. \begin{Rcode} > y <- c(53, 57, 66, 67, 72) # count data > n <- length(y) > s <- sum(y) \label{Rcode:sum} \end{Rcode} The following naive approach does not work, not either without the label...   \begin{Rcode} <<>>= y <- c(53, 57, 66, 67, 72) # count data n <- length(y) s <- sum(y) \label{Rcode:sum} @   \end{Rcode} \end{document} Thank you in advance for your suggestions! Giovanni -- Giovanni Petris  <[hidden email]> Associate Professor Department of Mathematical Sciences University of Arkansas - Fayetteville, AR 72701 Ph: (479) 575-6324, 575-8630 (fax) http://definetti.uark.edu/~gpetris/______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.