Enrico,
try
<<test, keep.source=TRUE>>
that should keep your linebreaks.
Cheers
Andrew
On Mon, May 26, 2008 at 03:15:39PM -0400, Enrico Rossi
wrote:> Hello,
>
> I'm learning to use Sweave, and I've run into a problem: sometimes,
when
> entering long lines of input and using long variable names, Sweave will not
> insert linebreaks in a way that respects the width setting. This causes
> undesirable overflows into the margins in the latex file. For example,
> consider the following document (adapted from the GLM example):
>
> \documentclass{article}
> \begin{document}
>
> <<setup,include=FALSE,echo=FALSE>>> options(width=80)
> @
>
> <<test>>> countsasdfasdfasdf <-
c(18,17,15,20,10,20,25,13,12)
> outcomeasdfasdfasdf <- gl(3,1,9)
> treatmentasdfasdfasdfasdf <- gl(3,3)
> glm.D93 <- glm(countsasdfasdfasdf ~ outcomeasdfasdfasdf +
> treatmentasdfasdfasdfasdf, family=poisson())
> @
>
> \end{document}
>
> When I compile this, treatmentasdfasdfasdfasdf sticks out into the right
> margin. The linebreak is inserted after the last comma, so that the line as
> printed is 85 characters long, even though I set width to 80 at the top.
> Ideally, Sweave would set the linebreak after the last plus symbol.
>
> There is a simple workaround that I have been using: if a line causes
> problems, set width to something smaller before the line, and set it back
> afterwards. It's pretty clumsy though, and I wonder if there is a
better
> way. My understanding is that there is no way to manually set linebreaks,
> what a pity!
>
> I am using R 2.6.2 and the MacTex 2007 distribution. If this problem has
> been fixed in a recent version, I apologize.
>
> Cheers,
> Enrico
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
--
Andrew Robinson
Department of Mathematics and Statistics Tel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/