【发布时间】:2021-02-23 21:56:45
【问题描述】:
如果您将 RMarkdown 文档编织成 PDF,是否有任何方法可以避免超出页面边缘的线条?
插图:
# RMarkdown file
title: "xyz"
author: "John Doe"
date: "23 2 2021"
output:
pdf_document:
latex_engine: xelatex
toc: true
toc_depth: 5
html_document: default
mainfont: Times New Roman
fontsize: 12
text
more text
```{r}
print("This is a very long line illustrating my question that drives me nuts. It should include more text that is supposed line-break if it goes beyond specified margins.)
a <- 10
b <- sqrt(2)
print(paste("This is also a use case that I am looking at right now. I want to print results in the PDF documents of a calcualtion and put it in context.", a, "divided by square root of 2 results in", (a/b))
```
如果文本超出范围,有什么方法可以强制换行?我尝试在 Markdown 文件中编辑 YAML 标头,创建前导文件并在 YAML 标头中引用它们,尝试各种乳胶引擎将我的文档编织为 PDF,定义 PDF 文档的边距,手动拆分长 print() 调用以跨越几行在源文件中并遵守最大值。每行的字符数,但到目前为止都失败了。 HTML 输出似乎还不错。
非常感谢任何提示过去已经提供的答案,因为我确信我不是唯一遇到此类问题的人,但不幸的是我无法找到合适的解决我的问题。
【问题讨论】:
标签: r r-markdown knitr