编织到PDF的文件不包含注释

问题描述 投票:2回答:2

[当尝试将我的Rmarkdown文件编织为PDF时,knitr似乎没有将注释换行,并且文本仅超出了pdf的空白。

我尝试指定几个参数,但似乎没有任何效果。

---
title: "Demo margin"
output: pdf_document
---

```{r setup, include=FALSE}
options(width=80)
knitr::opts_chunk$set(echo = TRUE,out.width = 40, tidy=T, tidy.opts=list(width.cutoff=60))
```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r cars, out.width=80, tidy = 'formatR', tidy.opts = list(blank = FALSE, width.cutoff = 60)}
summary(cars)
#very very very very very very very very very very very very very very very very very very very very very very very very incredibly very long comment
```

## Including Plots

You can also embed plots, for example:

```{r pressure, echo=FALSE}
plot(pressure)
```

enter image description here

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252   
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.6.1  htmltools_0.4.0 tools_3.6.1     yaml_2.2.0      Rcpp_1.0.3     
 [6] rmarkdown_2.0   knitr_1.26      xfun_0.11       digest_0.6.23   rlang_0.4.2    
[11] evaluate_0.14 

我如何获得knitr将注释包装在页边空白内?

r pdf r-markdown knitr margin
2个回答
0
投票

我有同样的问题,即使进行了详尽的搜索,也找不到其他解决方案:

  • 手动将评论分成几行
  • 使用paste0(“ foo ...”,“ ... bar”)

0
投票

我的猜测是您尚未安装formatR软件包。在这种情况下,您需要install.packages('formatR')。这是我在计算机上得到的:

comments rewrapped by formatR

© www.soinside.com 2019 - 2024. All rights reserved.