Permalink
bb5bbcf Feb 18, 2012
1 contributor

Users who have contributed to this file

61 lines (50 sloc) 2.79 KB
% Source: http://biostat.mc.vanderbilt.edu/wiki/pub/Main/SweaveTemplate/Sweavel.sty
% Author: Frank Harrell (with slight tweaks by Yihui Xie)
% Usage: \usepackage{Sweavel}
% To change size of R code and output, use e.g.: \def\Sweavesize{\normalsize}
% To change just the size of output, use e.g.: \def\Routsize{\smaller[2]}
% To change colors of R code, output, and commands, use e.g.:
% \def\Rcolor{\color{black}}
% \def\Routcolor{\color{green}}
% \def\Rcommentcolor{\color{red}}
% To change background color or R code and/or output, use e.g.:
% \def\Rbackground{\color{white}}
% \def\Routbackground{\color{white}}
% To use rgb specifications use \color[rgb]{ , , }
% To use gray scale use e.g. \color[gray]{0.5}
% If you change any of these after the first chunk is produced, the
% changes will have effect only for the next chunk.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{Sweavel}{} % substitute for Sweave.sty using
% listings package with relsize
\RequirePackage{listings,fancyvrb,color,relsize}
\providecommand{\Sweavesize}{\smaller}
\providecommand{\Routsize}{\Sweavesize}
\providecommand{\Rcolor}{\color[rgb]{0, 0.5, 0.5}}
\providecommand{\Routcolor}{\color[rgb]{0.461, 0.039, 0.102}}
\providecommand{\Rcommentcolor}{\color[rgb]{0.101, 0.043, 0.432}}
\providecommand{\Rbackground}{\color[gray]{0.91}}
\providecommand{\Routbackground}{\color[gray]{0.935}}
% Can specify \color[gray]{1} for white background or just \color{white}
\lstdefinestyle{Rstyle}{fancyvrb=false,escapechar=`,language=R,%
basicstyle={\Rcolor\Sweavesize},% some want \ttfamily too
backgroundcolor=\Rbackground,%
showstringspaces=false,%
keywordstyle=\Rcolor,%
commentstyle={\Rcommentcolor\ttfamily\itshape},%
literate={<-}{{$\leftarrow$}}2{<<-}{{$\twoheadleftarrow$}}2{~}{{$\sim$}}1{<=}{{$\leq$}}2{>=}{{$\geq$}}2{^}{{$^{\scriptstyle\wedge}$}}1,%
alsoother={$},%
alsoletter={.<-},%
otherkeywords={!,!=,~,$,*,\&,\%/\%,\%*\%,\%\%,<-,<<-,/},%
escapeinside={(*}{*)}}%
% Other options of interest:
% frame=single,framerule=0.1pt,framesep=1pt,rulecolor=\color{blue},
% numbers=left,numberstyle=\tiny,stepnumber=1,numbersep=7pt,
% keywordstyle={\bf\Rcolor}
\lstdefinestyle{Routstyle}{fancyvrb=false,literate={~}{{$\sim$}}1{R^2}{{$R^{2}$}}2{^}{{$^{\scriptstyle\wedge}$}}1{R-squared}{{$R^{2}$}}2,%
frame=single,framerule=0.2pt,framesep=1pt,basicstyle=\Routcolor\Routsize\ttfamily,%
backgroundcolor=\Routbackground}
\newenvironment{Schunk}{}{}
\lstnewenvironment{Sinput}{\lstset{style=Rstyle}}{}
\lstnewenvironment{Scode}{\lstset{style=Rstyle}}{}
\lstnewenvironment{Soutput}{\lstset{style=Routstyle}}{}