[R] Sweave does not respect width

From: Enrico Rossi <enrico.a.rossi_at_gmail.com>
Date: Mon, 26 May 2008 15:15:39 -0400


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):



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()) @


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.


        [[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. Received on Mon 26 May 2008 - 19:28:54 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 26 May 2008 - 20:31:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive