我试图阻止评论从我的RMarkdown输出中溢出。
这是我的工作代码:
---
title: 'This is a test title'
author:
- name: Honk R. \orcidlink{0000-0000-0000-0001}
affil-id: 1,3
- name: Tar F. \orcidlink{0000-0000-0000-0002}
affil-id: 2
affiliations:
- id: 1
name: Lima Beans.
- id: 2
name: Peas.
- id: 3
name: French Beans.
date: July 6, 2023
geometry:
- margin=1in
output:
pdf_document:
number_sections: yes
template: default.tex
---
```{r clustering, echo=TRUE, fig.height=2.5, fig.width=3}
library(tidyverse)
library(factoextra)
# These are the libraries that I am trying the load.
Groups <-as.factor(iris$Species) # This is another attempt at a long comment to try and make it spill out of the margins.
Matrix <-as.matrix(iris[1:4]) # Defining this matrix of numbers for PCA test.
res.pca<-princomp(Matrix)
fviz_pca_biplot(res.pca,
habillage = Groups) # This is going to be yet another attempt at making a long comment to check if it spills out of the margins so I can make my point
字符串
这是输出:
的数据
我如何阻止评论溢出空白并保持扭曲?是否有全局命令来确保文本换行?
1条答案
按热度按时间osh3o9ms1#
如果您将注解放在它们自己的行上,而不是放在包含代码的行的末尾,那么chunk选项
tidy = TRUE
将使它们换行。例如:的数据
将被格式化为这样:
的
tidy = TRUE
选项不会影响你的评论风格,据我所知,没有办法让它这样做。但是,使用tidy = "styler"
将使用styler
包进行格式化,并且它是非常可定制的。我不认为它有一个现有的选项来做你想做的事情,但你可能会写一个。