[R] knitr customization

Giovanni Petris gpetris at uark.edu
Fri May 25 21:30:04 CEST 2012


I am trying to transition from Sweave to knitr, but there are a few
things about customization of the appearence of R input and output that
I did not get yet. Maybe somebody on the list can help me.

In my Sweave presentations I used a slanted font for the R input and a
normal font for the output, both in a small font. I also indented
everything by an extra 2em. All this was achieved by the following
instructions in the .Rnw file:

\DefineVerbatimEnvironment{Sinput}{Verbatim}{xleftmargin=2em, 
  fontsize=\footnotesize, fontshape=sl}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{xleftmargin=2em, 
  fontsize=\footnotesize}

In order to get a similar result (with a tiny size instead of a footnote
size, but that is not the point) with knitr I included in the .Rnw file
the lines

\ifdefined\knitrout
  \renewenvironment{knitrout}{\begin{tiny}\slshape}{\end{tiny}}
\else
\fi
  
What I get is something like this: 

http://definetti.uark.edu/~gpetris/knitr-output.pdf 

The problem is that the prompt sign '>' did not change either size or
shape. So I am probably not using the correct approach. How should I be
doing?

Also, what do I have customize, and how, in order to get the extra left
margin?

Final question: how can I get the continuation sign '+'? (This is for an
introductory presentation in which I want to show people exactly what
they are going to see on their screen.) 

Oops, one more... How can I change the spacing between regular text and
R code (input/output)? With Sweave I would do

\fvset{listparameters={\setlength{\topsep}{0pt}}}
\renewenvironment{Schunk}{\vspace{\topsep}}{\vspace{\topsep}}


Sorry for the many questions and thank you in advance for any help and
insight you can give me.

Best,
Giovanni


-- 

Giovanni Petris  <GPetris at uark.edu>
Associate Professor
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/



More information about the R-help mailing list