编织为pdf时出现YAML问题

时间:2019-07-10 10:00:59

标签: pdf yaml r-markdown rnotebook tinytex

我有一篇用rnotebook编写的论文,我想将其编织成pdf。 这是它的开始,包括YAML:

---
title: "Are shifts between points of view challenging for readers? An examination of readers' eye movements in response to Woolf's *To the Lighthouse* and *Mrs Dalloway*"
author: "Giulia Grisot, Kathy Conklin, Violeta Sotirova - The University of Nottingham"
date: '`r format(Sys.time(), "%d %B %Y")`'
output:
  html_notebook:
    fig_caption: yes
    force_captions: yes
    #highlight: pygments
    number_sections: false
    theme: readable
# csl: sage-harvard.csl
csl: apa.csl
bibliography: library.bib
link-citations: yes
nocite: | 
  @Grisot2018

---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE)
```

```{r, include=F}
library(tidyverse)
library(ggpubr)
```

# Abstract

The emergence of empirical approaches within stylistics has increased interest in how literary texts are processed by readers. Techniques of speech and thought representation represent an area ripe for empirical investigation in this respect, especially when these cause interpretative ambiguities.

我已经安装了tinytex,并且已经安装了miktex和pandoc。 我试图在RStudio中仅使用“编织到pdf”命令,但它给了我这个错误,我不知道该怎么办

Error in yaml::yaml.load(..., eval.expr = TRUE) : 
  Scanner error: while scanning for the next token at line 4, column 31 found character that cannot start any token at line 4, column 31
Calls: <Anonymous> ... parse_yaml_front_matter -> yaml_load -> <Anonymous>
Execution halted

1 个答案:

答案 0 :(得分:0)

我认为这取决于您Yaml中的格式。当我编入代码时,R Studio对标题进行了一些重新格式化,但是在此过程中,日期中的'替换为',从而导致错误。我没有您的.bib文件,所以我无法测试您的确切代码,但以下内容对我有用:

---
title: Are shifts between points of view challenging for readers? An examination of
  readers' eye movements in response to Woolf's *To the Lighthouse* and *Mrs Dalloway*
author: "Giulia Grisot, Kathy Conklin, Violeta Sotirova - The University of Nottingham"
date: '`r format(Sys.time(), "%d %B %Y")`'
output:
  pdf_document: default
  html_notebook:
    fig_caption: yes
    force_captions: yes
    number_sections: no
    theme: readable
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE)
```

```{r, include=F}
library(tidyverse)
#library(ggpubr)
```

# Abstract