1

I have read a lot of question and relative answer but I didn't find a solution! My request is similar to this: Putting line number for R code with knitr, but I want to keep the standard style of Knitr. A user, Thomas, suggest to add language=R to the listings options but this doesn't change the output.

A result like this:

see here

would be great! (The theme isn't relevant just the LINE number). I've tried to use the render_listings() function:

\documentclass{article}
\usepackage{listings}

\lstdefinestyle{Rstyle}{%
  fancyvrb=FALSE,escapechar=`,language=R,%
  basicstyle={\Rcolor\Sweavesize\ttfamily},%         Added \ttfamily
  backgroundcolor=\Rbackground,%
  showstringspaces=false,%
  keywordstyle=\Rcolor,%
  commentstyle={\Rcommentcolor\ttfamily\itshape},%
  %literate=                                         Removed
  alsoother={$},%
  numbers=left,                    
  numbersep=5pt, 
  alsoletter={.<-},%
  otherkeywords={!,!=,~,$,*,\&,\%/\%,\%*\%,\%\%,<-,<<-,/},%
  escapeinside={(*}{*)}}%

\begin{document}

<<setup, include=FALSE>>=
render_listings()
@

<<a, results='hold'>>=
1:2
3:4
5:6
@

<<b>>=
"test1"
"test2"
"test3"
@

\end{document}

Maybe I Have to modify sweavel.sty file too but I haven't idea how to do that.

Community
  • 1
  • 1
Slaf
  • 11
  • 2
  • The results of the code above is http://i.stack.imgur.com/T6tK0.png. An output like that: http://i.stack.imgur.com/8f9LJ.png with line number will be fine. – Slaf Jan 31 '16 at 15:37

0 Answers0