0

How can get an upshape font (\rm) [with Sweave] in lines which display code (such as 1:300 + runif(300)) below? I tried a couple of things (I found fontshape=n online), but they did not influence the result.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{fancyvrb}

% \DefineVerbatimEnvironment{Sinput}{Verbatim}{fontsize=\small, fontshape=n}
% \DefineVerbatimEnvironment{Soutput}{Verbatim}{fontsize=\small, fontshape=n}
% \DefineVerbatimEnvironment{Scode}{Verbatim}{fontsize=\small, fontshape=n}
\fvset{listparameters={\setlength{\topsep}{0pt}}, fontsize=\small}

\SweaveOpts{engine=R, pdf=TRUE, eps=FALSE, width=5.33, height=3}
\SweaveOpts{strip.white=TRUE, keep.source=TRUE}

\begin{document}
<<label=preliminaries, echo=FALSE, results=hide>>=
options(width=70, useFancyQuotes="UTF-8", prompt="> ", continue="  ")
options(SweaveHooks=list(fig=function() par(mar=c(4, 4, 0.4, 0.7))))
@
<<label=foo>>=
1:300 + runif(300)
@
\end{document}
1

Okay, I just realized I forgot to load Sweave, so this works:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{fancyvrb}

\usepackage{Sweave}
\DefineVerbatimEnvironment{Sinput}{Verbatim}{fontsize=\small, fontshape=n}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{fontsize=\small, fontshape=n}
\DefineVerbatimEnvironment{Scode}{Verbatim}{fontsize=\small, fontshape=n}
\fvset{listparameters={\setlength{\topsep}{0pt}}}

\SweaveOpts{engine=R, pdf=TRUE, eps=FALSE, width=5.33, height=3}
\SweaveOpts{strip.white=TRUE, keep.source=TRUE}

\begin{document}
<<label=preliminaries, echo=FALSE, results=hide>>=
options(width=74, useFancyQuotes="UTF-8", prompt="> ", continue="  ")
options(SweaveHooks=list(fig=function() par(mar=c(4, 4, 0.4, 0.7))))
@
<<label=foo>>=
round(1:300 + runif(300))
@
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.