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