Ade*_*scu 5 latex r r-markdown
我已经找到了控制文本对齐的方法,但是我找不到任何PDF输出.
有一个现有的答案,但仅与HTML输出有关:如何在rmarkdown中编织html时向双方证明文本的合理性.
R Markdown应该默认使用对齐文本。但是,如果你只想要导出为PDF,我们可以直接用LaTeX命令的document.using标准的争论中\centering \raggedright和\raggedleft,如解释在这里。
这是一个最小的示例:
---
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]`
Run Code Online (Sandbox Code Playgroud)
如果要还原为对齐文本,则可以使用ragged2eLaTeX软件包。您需要通过添加以下内容在YAML中加载此文件:
---
output: pdf_document
header-includes:
- \usepackage[document]{ragged2e}
---
\raggedleft
**Ragged Left**
`r lipsum[1]`
\justify
**Revert to Justified**
`r lipsum[1]`
Run Code Online (Sandbox Code Playgroud)
如果使用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]`
Run Code Online (Sandbox Code Playgroud)