While not having a perfect solution, I have made enough progress to be able to declare "good enough", thanks in particular to Duncan Murdoch and Yihui Xie.

First, the font can be made smaller so output fits on a line and does not overflow the margins. This is accomplished by putting the command

\RecustomVerbatimEnvironment{Soutput}{Verbatim}{fontsize=\small}

in the .Rnw file. \scriptsize makes things even smaller, but it appears also to shift things towards the left margin too. The command is slightly changed from Duncan's.

Second, the strings that are giving us trouble can be wrapped. The simplest solutions are not always ideal, but seem to avoid margin intrusions. These are to use

  print(strwrap(answer))

or

  cat(strwrap(answer), sep='\n')

A suggestion was to use capture.output() and then process it, which allows more fine control, but is a lot more work.

These steps (combined in my case) did a reasonable job on a package vignette I 
was preparing.

JN

______________________________________________
R-help@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.

Reply via email to