编织RMarkdown文档时YAML中的错误-扫描仪错误

时间:2018-10-02 06:09:22

标签: r

我正在尝试在RStudio中编织RMD文件,但出现以下错误

  

yaml :: yaml.load(string,...)中的错误:扫描仪错误:在第31行的第5列扫描普通标量时,发现了制表符   在第34行第1栏违反了意图的调用:...   parse_yaml_front_matter-> yaml_load_utf8->执行   停止

rmd文件的标题如下:

> --- 
> title: "Homework 4" 
> author: NAME OF THE AUTHOR, Fall 2018 
> date: Due Friday, September 30, 11:59pm 
> subparagraph: yes 
> output:  
> pdf_document:
>     number_sections: true header-includes:
>   - \setcounter{secnumdepth}{1}
>   - \pagenumbering{gobble}
>   - \sloppy
>   - \hypersetup{ breaklinks=true,
>       pdftitle={\@title},
>       pdfauthor={\@author},
>       colorlinks=true,
>       breaklinks=true,
>       urlcolor= blue,
>       linkcolor= blue,
>       citecolor=blue,
>       bookmarksopen=false,
>       pdftoolbar=false,
>       pdfmenubar=false
>     }
>   - \usepackage{titlesec}
>   - \renewcommand{\thesection}{\arabic{section}.}
>   - \usepackage{mathpazo}
>   - \usepackage{etoolbox}
>   - \usepackage{geometry}
>   - \usepackage{graphicx}
>   - \newcommand{\protectbracket}[1]{#1}
>   - \makeatletter
>     \protectbracket{\preto\Gin@extensions{svg,}}
>     \DeclareGraphicsRule{.svg}{pdf}{.pdf}{\noexpand\Gin@base.pdf}     \makeatother
>   - \geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
>   - \usepackage[most]{tcolorbox}
>   - \definecolor{block-gray}{gray}{0.85}
>   - \newtcolorbox{darkquote}{colback=block-gray,grow to right by=-10mm,grow to left by=-10mm, boxrule=0pt,boxsep=0pt,breakable}
>   - \renewenvironment{quote}{\begin{darkquote}}{\end{darkquote}\ignorespacesafterend}
> ---

任何想法是什么原因造成的?错误指向第31行中的字符“ n”,我不确定该如何解决。任何帮助或建议都将受到高度赞赏。

我已经在Mac和PC上都安装了RStudio的情况下进行了尝试。

1 个答案:

答案 0 :(得分:0)

假设行首的>是复制和粘贴后的剩余内容(肯定不会出现在文件中),则您有一个YAML文档,其开头如下:

--- 
title: "Homework 4" 
author: NAME OF THE AUTHOR, Fall 2018 
date: Due Friday, September 30, 11:59pm 
subparagraph: yes 
output:  
pdf_document:
    number_sections: true header-includes:
  - \setcounter{secnumdepth}{1}

,这是无效的,因为您不能同时拥有键pdf_document的映射值和序列(也要减少缩进)。 结合行内冒号和行尾冒号的组合,可能会使解析器混乱

您可能希望将其更改为以下内容:

--- 
title: "Homework 4" 
author: NAME OF THE AUTHOR, Fall 2018 
date: Due Friday, September 30, 11:59pm 
subparagraph: yes 
output:  
pdf_document:
    number_sections: true
header-includes:
  - \setcounter{secnumdepth}{1}