【发布时间】:2016-10-25 00:30:57
【问题描述】:
我正在使用最新的 R Studio,R 3.2.5,rmarkdown 0.9.6,它附带 pandoc 1.15.2 来写期刊文章。提交要求:linespacing: 1.43 和摘要下方的 keywords: 行。
当我单击Knit PDF 时,我会得到默认模板"C:\R\R-3.2.5\library\rmarkdown\rmd\latex\default-1.15.2.tex",它不支持 YAML 标头中的这些字段。我看到default-1.17.02.tex 支持linespacing:,但不支持keywords:。
我尝试修改后一个模板以添加关键字处理,这看起来很简单。模板的相关部分,我称之为modified-template-1.17.0.2.tex 是
$if(title)$
\maketitle
$endif$
$if(abstract)$
\begin{abstract}
$abstract$
\end{abstract}
$endif$
\providecommand{\keywords}[1]{\textbf{\textit{Keywords---}} #1}
$if(keywords)$
\keywords{$keywords$}
$endif$
我用了下面的 YAML 头,pandoc 找到了;但是,它产生了.tex 语法错误,与keywords: 字段无关。我在想rmarkdown 模板是特定于pandoc 的版本的,但我无法判断。
有人可以帮忙吗?
---
title: "My title"
author: ME
date: '`r format(Sys.time(), "%B %d, %Y")`'
output:
pdf_document:
fig_caption: yes
keep_tex: yes
number_sections: yes
template: "modified-template-1.17.0.2.tex"
keywords: Box M test, HE plots, MANOVA, graphics, ...
abstract: "This paper explores a variety of fascinating topics ... "
---
补充说明:我尝试了修改default-1.15.2.tex 模板,如上所述。我的结果是一样的,我得到的错误是:
! Undefined control sequence.
l.527 {\centering \includegraphics
pandoc.exe: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43
另一个测试:我只是在我的本地文件夹中使用了标准default-1.15.2.tex 模板的副本,带有 YAML 行
template: "default-1.15.2.tex"
这也给出了同样的错误,所以我对原因感到困惑。
【问题讨论】:
-
为什么不编辑 1.15.2 模板以添加关键字和行间距支持(您可以从 1.17 模板复制)。 Linespacing 与 pandoc 支持无关,它是纯乳胶,所以它应该可以工作。
标签: r templates rstudio knitr pandoc