使用 R markdown 和 knitr 时避免文本溢出到边距

Avoid spilling of text to margin when using R markdown and knitr

在使用 rmarkdownknitr 生成 pdf 文件时,如何避免 R 控制台输出的文本溢出到边缘?例如,

---
title: "Illustration"
author: "Temp"
date: "Monday, April 06, 2015"
output: pdf_document
---

Spilling of R output.

```{r}
library("tm")
data("acq")
str(acq)
```

我发现对我来说最一致的处理方式是使用 widthstrict.width 选项到 str() functionwidth 选项指定要使用的页面宽度,并且应该继承活动的 options() 宽度设置。但是,我并不总是发现这一点。 strict.width 允许您控制多余文本的处理方式(剪切、换行)。

---
title: "Illustration"
author: "Temp"
date: "Monday, April 06, 2015"
output: pdf_document
---

Spilling of R output.

```{r}
library("tm")
data("acq")
str(acq,width=80,strict.width="cut")
```