在YAML标头的pdf_document下设置citation_package选项,并使用rmarkdown :: pdf_document函数

时间:2019-04-18 16:44:37

标签: r-markdown

Rmarkdown CRAN软件包的

The help file of the pdf_document函数表示该函数定义了以下选项:

pdf_document(toc = FALSE, toc_depth = 2, number_sections = FALSE,
  fig_width = 6.5, fig_height = 4.5, fig_crop = TRUE,
  fig_caption = TRUE, dev = "pdf", df_print = "default",
  highlight = "default", template = "default", keep_tex = FALSE,
  latex_engine = "pdflatex", citation_package = c("none", "natbib",
  "biblatex"), includes = NULL, md_extensions = NULL,
  pandoc_args = NULL, extra_dependencies = NULL)

我的印象是,我可以在Rmarkdown文档的YAML标头的输出部分的pdf_document下将这些参数中的任何一个添加为选项。它是否正确?当我使用pdf_document的以下选项/参数时,文档成功进行了编译:{{1​​}},tocnumber_sectionsfig_captiondf_print。但是,当我将keep_tex添加到列表中时,编译时出现错误。例如,考虑以下模板Rmarkdown文档。

citation_package

提到的--- title: "Untitled" author: "Unknown" date: "4/18/2019" output: pdf_document: # toc: true number_sections: true fig_caption: true df_print: kable keep_tex: true citation_package: biblatex bibliography: sample_bib.bib csl: /Users/Shared/Zotero/styles/multidisciplinary-digital-publishing-institute.csl --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` ## R Markdown I love R [@rcoreteamLanguageEnvironmentStatistical2018]. 是看起来像的围嘴文件

sample_bib.bib

但是,我无法编制此Rmarkdown文档。我收到以下错误。

@software{rcoreteamLanguageEnvironmentStatistical2018,
  location = {{Vienna, Austria}},
  title = {R: {{A Language}} and {{Environment}} for {{Statistical Computing}}},
  url = {https://www.R-project.org/},
  version = {3.5.1},
  organization = {{R Foundation for Statistical Computing}},
  date = {2018},
  author = {{R Core Team}}
}

幸运的是,可以通过将“ citation_package”从pdf_document下的选项移动到YAML标头中的单独一行来轻松解决此问题。或者:

/usr/local/bin/pandoc +RTS -K512m -RTS rmarkdown_pdf_document.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output rmarkdown_pdf_document.tex --template /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rmarkdown/rmd/latex/default-1.17.0.2.tex --number-sections --highlight-style tango --pdf-engine pdflatex --biblatex --variable graphics=yes --variable 'geometry:margin=1in' --variable 'compact-title:yes' 
output file: rmarkdown_pdf_document.knit.md

INFO - This is Biber 2.7
INFO - Logfile is 'rmarkdown_pdf_document.blg'
INFO - Reading 'rmarkdown_pdf_document.bcf'
INFO - Found 1 citekeys in bib section 0
INFO - Processing section 0
INFO - Looking for bibtex format file 'sample\_bib.bib' for section 0
ERROR - Cannot find 'sample\_bib.bib'!
INFO - ERRORS: 1
Error: Failed to build the bibliography via biber
Execution halted
Warning message:
LaTeX Warning: Citation 'rcoreteamLanguageEnvironmentStatistical2018' on page 1
 undefined on input line 137.
LaTeX Warning: Empty bibliography on input line 169.
Package rerunfilecheck Warning: File `rmarkdown_pdf_document.out' has changed.
(rerunfilecheck)                Rerun to get outlines right
(rerunfilecheck)                or use package `bookmark'.
LaTeX Warning: There were undefined references.
LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
Package biblatex Warning: Please (re)run Biber on the file:
(biblatex)                rmarkdown_pdf_document
(biblatex)                and rerun LaTeX afterwards. 

编织此调整后的Rmarkdown文档后,结果是pdf_document。

所以我的问题是:我是否可以在CRAN的pdf_document帮助文件中添加任何参数作为Rmarkdown文件中YAML标头中“ pdf_document”下的选项?或者,在使用此特定的--- title: "Untitled" author: "Unknown" date: "4/18/2019" output: pdf_document: # toc: true number_sections: true fig_caption: true df_print: kable keep_tex: true citation_package: biblatex bibliography: sample_bib.bib csl: /Users/Shared/Zotero/styles/multidisciplinary-digital-publishing-institute.csl --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` ## R Markdown I love R [@rcoreteamLanguageEnvironmentStatistical2018]. 参数/选项时,这可能是citation_package()函数中的错误吗?

ALSO POSTED ON RMARKDOWN's GITHUB;请参阅以获取更多评论。

0 个答案:

没有答案