Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

migrated from stackoverflow.com Mar 6 '12 at 17:47

This question came from our site for professional and enthusiast programmers.

1 Answer 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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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