[R] Formatting Sweave in R-News
Duncan Murdoch
murdoch at stats.uwo.ca
Wed Aug 22 14:36:20 CEST 2007
On 8/22/2007 3:20 AM, Gregor Gorjanc wrote:
> Arjun Ravi Narayan <contact <at> arjunnarayan.com> writes:
>> I am editing a document for submission to the R-news newsletter, and
>> in my article my Sweave code inserts a dynamically generated PDF
>> report that my R program generates.
>>
>
> Slightly off Arjuns topic is a problem with Schunk, Sinput and Soutput
> environments. They just use to much inline space. I have tweade this
> problem with sed (see bellow for Makefile content), but wonder if there
> is a better solution.
You can change the spacing by redefining those environments. I use this:
% This removes the extra spacing after code and output chunks in Sweave,
% but keeps the spacing around the whole block.
\fvset{listparameters={\setlength{\topsep}{0pt}}}
\renewenvironment{Schunk}{\vspace{\topsep}}{\vspace{\topsep}}
> Thanks, Gregor
>
> default: Sweave fixTex
> texi2pdf --clean wrapper.tex && evince wrapper.pdf
>
> Sweave: # Sweave myPaper.Rnw
> R CMD Sweave myPaper.Rnw
>
> fixTex: Sweave # Change all S* environments to smallverbatim
> @cat myPaper.tex | sed -e '/\\begin{Sinput}/d' \
> -e '/\\end{Sinput}/d' \
> -e '/\\begin{Soutput}/d' \
> -e '/\\end{Soutput}/d' \
> -e 's/\\begin{Schunk}/\\begin{smallverbatim}/g' \
> -e 's/\\end{Schunk}/\\end{smallverbatim}/g' \
> > myPaper2.tex
> @mv -f myPaper2.tex myPaper.tex
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list