This is a such frequently asked question...
The reason is that the output is written in the verbatim environment,
so there is no way to break or wrap it, unless you modify the output
or the environment. In your case, it is harder to modify the
environment, so perhaps you should modify the output.
I have cooked up one example here:
https://github.com/yihui/knitr-examples/blob/master/077-wrap-output.Rmd
https://github.com/yihui/knitr-examples/blob/master/077-wrap-output.md
In RStudio you can see the line wrapped because the <pre> tag was
defined in CSS to wrap the lines:
pre {
margin-top: 0;
max-width: 95%;
border: 1px solid #ccc;
white-space: pre-wrap;
}
Regards,
Yihui
--
Yihui Xie <
xiey...@gmail.com>
Phone:
515-294-2465 Web:
http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA
On Wed, Jan 9, 2013 at 2:11 PM, Dan Tenenbaum <
dand...@gmail.com> wrote:
> Hi,
>
> I am writing a package vignette in an .Rmd file and using knitr and pandoc
> to convert it to PDF.
>
> One of my code chunks produces long lines, ~106 columns. Here is a contrived
> reproduction:
>
> ```{r long_output}
> a <- '## "stx2A; shiga-like toxin II A subunit encoded by bacteriophage
> BP-933W; K11006 shiga toxin subunit A" '
> a
> ```
> When working in RStudio, if I click "Knit HTML", I see this output wrapped,
> and I can make the display window wider to see all of it on one line.
>
> But when I create a PDF from the markdown that knitr generates, the output
> does not wrap and it is cut off at about column 92, so there is no way to
> see the last columns of the line.
>
> I tried adding a width option to the beginning of the document:
>
> ```{r setup, echo=FALSE}
> options(width=80)
> ```
>
> That didn't make any difference. I'd like to cause code chunk output to wrap
> sensibly but at the very least I don't want it truncated in my pdf.
>
> In my Makefile, I don't pass any special options to pandoc. I tried
> --columns=80 and that made no difference. The pandoc docs say wrapping is on
> by default.
>
> In the .md file that knitr generates, the output of my document shows up
> like this:
>
> ```
> ## "stx2A; shiga-like toxin II A subunit encoded by bacteriophage BP-933W;
> K11006 shiga toxin subunit A"
> ```
>
> So I guess I'd like to know how to force that to wrap.
> Thanks,
> Dan
>