[R] Modifying Sweave.sty to allow escapes with fancyvrb package in LaTeX
Frank E Harrell Jr
f.harrell at vanderbilt.edu
Fri Jun 26 17:39:17 CEST 2009
Dear Colleagues:
In an attempt to have things like # See page \pageref{this} inside
comments in R code chunks I have modified Sweave.sty as below. I have
followed fancyvrb's manual with regard to the use of the commandchars
argument. But when compiling with LaTeX (using attached test file) I
get a LaTeX error
(/usr/share/texmf-texlive/tex/latex/ae/t1aett.fd)
! Missing \endcsname inserted.
<to be read again>
\global
l.25 } else y <- 4
The line in question is
\DefineVerbatimEnvironment{Sinput}{Verbatim}{formatcom=\lstset{fancyvrb=true},commandchars=\\\{\}}
Can anyone give me a pointer to how to properly change Sweave.sty to
allow it to use fancyvrb in this way? I am following the model in
SweaveListingUtils for having Sweave use the listings package to do
pretty-printing.
Thanks very much
Frank
Sweavel.sty:
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{Sweavel}{}
\RequirePackage{listings,ifthen,graphicx,fancyvrb,relsize}
\RequirePackage{ifthen}
\newboolean{Sweave at gin}
\setboolean{Sweave at gin}{true}
\newboolean{Sweave at ae}
\setboolean{Sweave at ae}{true}
\DeclareOption{nogin}{\setboolean{Sweave at gin}{false}}
\DeclareOption{noae}{\setboolean{Sweave at ae}{false}}
\ProcessOptions
\IfFileExists{upquote.sty}{\RequirePackage{upquote}}{}
\ifthenelse{\boolean{Sweave at gin}}{\setkeys{Gin}{width=0.8\textwidth}}{}%
\ifthenelse{\boolean{Sweave at ae}}{%
\RequirePackage[T1]{fontenc}
\RequirePackage{ae}
}{}%
%\DefineVerbatimEnvironment{Sinput}{Verbatim}{fontshape=sl}
\DefineVerbatimEnvironment{Sinput}{Verbatim}{formatcom=\lstset{fancyvrb=true},commandchars=\\\{\}}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{}
\DefineVerbatimEnvironment{Scode}{Verbatim}{fontshape=sl}
\newenvironment{Schunk}{}{}
\newcommand{\Sconcordance}[1]{%
\ifx\pdfoutput\undefined%
\csname newcount\endcsname\pdfoutput\fi%
\ifcase\pdfoutput\special{#1}%
\else\immediate\pdfobj{#1}\fi}
--
Frank E Harrell Jr Professor and Chair School of Medicine
Department of Biostatistics Vanderbilt University
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test3.tex
Type: text/x-tex
Size: 766 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090626/f16f649a/attachment-0002.bin>
More information about the R-help
mailing list