- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在寻找控制文本对齐方式的方法,但是我找不到用于PDF输出的任何内容。
有一个现有答案,但仅与HTML输出有关:How to justify the text to both sides when knitting html in rmarkdown。
最佳答案
R Markdown应该默认使用对齐文本。但是,如果只想导出为PDF,我们可以使用标准参数\centering
\raggedright
和\raggedleft
直接在文档中使用LaTeX命令,如here所述。
这是一个最小的示例:
---
output: pdf_document
---
```{r, include = FALSE}
devtools::install_github("coolbutuseless/lipsum")
library(lipsum)
```
**Default**
`r lipsum[1]`
\centering
**Centered Text**
`r lipsum[1]`
\raggedright
**Ragged Right**
`r lipsum[1]`
\raggedleft
**Ragged Left**
`r lipsum[1]`
ragged2e
LaTeX软件包。您需要通过添加以下内容在YAML中加载此文件:
---
output: pdf_document
header-includes:
- \usepackage[document]{ragged2e}
---
\raggedleft
**Ragged Left**
`r lipsum[1]`
\justify
**Revert to Justified**
`r lipsum[1]`
papaja
模板,则需要包括所有YAML。不提供作者,简称或其他字段将导致其崩溃。
---
title : "The title"
shorttitle : "Title"
author:
- name : "First Author"
affiliation : "1"
corresponding : yes # Define only one corresponding author
address : "Postal address"
email : "my@email.com"
- name : "Ernst-August Doelle"
affiliation : "1,2"
affiliation:
- id : "1"
institution : "Wilhelm-Wundt-University"
- id : "2"
institution : "Konstanz Business School"
author_note: |
Add complete departmental affiliations for each author here. Each new line herein must be indented, like this line.
Enter author note here.
abstract: |
Enter abstract here. Each new line herein must be indented, like this line.
keywords : "keywords"
wordcount : "X"
bibliography : ["r-references.bib"]
figsintext : no
figurelist : no
tablelist : no
footnotelist : no
lineno : yes
mask : no
class : "man"
output : papaja::apa6_pdf
header-includes:
- \usepackage[document]{ragged2e}
---
```{r load_packages, include = FALSE}
library(lipsum)
```
\justify
**Default**
`r lipsum[1]`
关于r - 在pdf输出中进行编织时,如何在R Markdown中对文本进行正反对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50041549/
我在编织我的 RMarkdown 文件时遇到以下错误。 Parser error: while parsing a block mapping at line 1, column 1 did not
有人在 Knitr 中使用 gridSVG 吗?我发现包“gridSVG”提供了一个名为“gridsvg”的设备,我编写的代码如下。 ```{r message=FALSE, echo=FALSE,
在下面的代码片段中,我有一段代码目前正在按我希望的方式运行: def weave_iterable(*iters): return ''.join('{}'.format('{}'*len(c
我有一个相当长的 R 代码,需要大约 2-3 小时才能运行并编织成 HTML。然而,即使出现小错误或警告......编织也会中止......在下面的示例中,由于保存历史错误,它已经这样做了。 proc
我想分享一个关于如何使用github页面在rstudio上在线发布工作的逐步说明。 如果不是来自计算机科学,包括我自己,很多服用Coursera courses on data的人都会有问题,所以我想
我最近开始使用 Sweave * 用于创建使用 R 运行的分析报告,现在我希望对我的 python 脚本做同样的事情。 我找到了对 embedding python in Sweave 的引用docs
我试过在谷歌上搜索来解决这个问题,但有用的解决方案很少。 我已经安装了 Miktex、R 和 R studio。我想使用 Sweave 在 Miktex 中创建 PDF 文档。每次我打开我的 .Rnw
我有一个用 MyEclipse 制作的 Spring MVC 应用程序,其中包含生成的源代码以及我自己的源代码,以及我在生成的类上定义的方面。一切都在 MyEclipse 中编译得很好,但我现在想切换
我正在考虑使用 Postsharp 框架来减轻应用程序方法日志记录的负担。它基本上允许我用日志属性装饰方法,并在编译时将所需的日志代码注入(inject)到 il 中。我喜欢这个解决方案,因为它可以将
docs解释一下,必须通过使用 来启用 LTW xml指令或使用@EnableLoadTimeWeaving注解。然而,我两者都没有做过,但我仍然看到我的项目中的方面是正确编织的! 在这种情况下,我
我正在尝试在运行时加载类,并在此时将它们与一些 AspectJ 方面编织在一起。我启用了加载时织入,当我更常规地使用它时它会起作用。 我的@Aspect 类中有以下内容: @Before("call(
我有一个 .Rmd 文件,以前编织过没有任何问题。现在我在执行此指令时收到以下错误 confusionMatrix(prediction1, ssTesting$classe) 错误是 Error i
我有一个项目 foo-instrumented这取决于 foo . 这个项目实际上仪器foo用额外的代码,并替换它。即,foo是 foo-instrumented 的编译时依赖项但它绝对不是运行时依赖
我有一个项目,它有多个 Maven 模块,其中一个包含我的方面。如何获取方面并编织多个 Maven 模块? AspectJ Maven 插件的文档有点稀疏,找不到很多示例。 我曾尝试将 aspectj
我正在尝试使用 DT::datatable在 R 中输出格式良好的交互式表格。 ...唯一的问题是我想要一份 heroku 工作来为我编写文档,而且我了解到 RStudio 和 rmarkdown::
我正在尝试让 AspectJ 编织在一个简单的 Maven 项目中工作,但不确定哪里出了问题:当我使用“mvn exec:java”运行代码时,我没有看到预期的输出。 我确信代码可以正常工作,因为我在
尝试为大量 DTO 编织默认的 toString() 方法,仅使用编译时编织。目标是使用 Jackson 库返回 JSON 表示。 遵循了 this article 中的建议, 变成了注解式的切面配置
我正在尝试从 RStudio 编织 PDf 文件,但出现以下错误: ! LaTeX Error: File `framed.sty' not found. R 版本:3.2.2 (2015-08-14
kableExtra 创建一个包含一些图表的表格,如 its manual演示。我们将在下表中使用 kableExtra::spec_pointrange() 绘制点范围图,运行本文底部的代码。 但是
假设我在 R 中有代码 not working ,即我运行该代码并得到一些错误和警告,我想通过 R markdown 与第三人共享显示错误和警告的代码和输出. 如果我在 r 代码块中有错误,是否可以编
我是一名优秀的程序员,十分优秀!