如何在rticles :: jss函数中包含引文

时间:2019-04-05 14:36:55

标签: r r-markdown

非常感谢 rticles 软件包的许多作者创建了Rmarkdown模板,该模板使我可以在不离开Rmarkdown环境的情况下将文章准备好提交给Journal of Statistics Software。我在R和Rmarkdown方面有经验,但是在LaTex方面却没有太多经验。在查阅了广泛的JSS样式指南之后,我想知道为什么Rmarkdown jss模板中没有基本的引文设置。

由于我的资源使用bibLaTex包,因此我想使用此引文包来处理引文,而不要使用rticles::jss()中的默认“ natbib”参数。我可以使用“ bibLaTex”,因为它是rticles::jss()中的一个参数。使用 knitr 编译时出现错误。 JSS文档说使用“ \ cite {}”命令代替Rmarkdown默认命令“ [@ ...]”。我的降价文件称为“ New_Template.Rmd”,如下所示。

---
author:
  - name: FirstName LastName
    affiliation: University/Company
    address: >
      First line
      Second line
    email: \email{name@company.com}
    url: http://rstudio.com
  - name: Second Author
    affiliation: Affiliation
title:
  formatted: "A Capitalized Title: Something about a Package \\pkg{foo}"
  # If you use tex in the formatted title, also supply version without
  plain:     "A Capitalized Title: Something about a Package foo"
  # For running headers, if needed
  short:     "\\pkg{foo}: A Capitalized Title"
abstract: >
  The abstract of the article.
keywords:
  # at least one keyword must be supplied
  formatted: [keywords, not capitalized, "\\proglang{Java}"]
  plain:     [keywords, not capitalized, Java]
preamble: >
  \usepackage{amsmath}
output: 
  rticles::jss_article:
    number_sections: TRUE     #added argument option 
    citation_package: biblatex  #All my citations use biblatex, not natbib. 
biblio-style: jss      #Added Citation style is listed to use in JSS Instructions for Authors.
bibliography: vignette_bib.bib  #Added here from template.
---

# Introduction

This template demonstrates some of the basic latex you'll need to know to create a JSS article.

A citation \citep{braunWhatCanEpidemiological2016} and not the RMarkdown style <!-- [@braunWhatCanEpidemiological2016] --> 

使用Rmarkdown引用[@ braunWhatCanEpidemiologic2016],编织New_Template.Rmd会在引用时产生此错误。

! Undefined control sequence.
l.53 A citation \autocite
                         {braunWhatCanEpidemiological2016} 

Error: Failed to compile New_Template.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See New_Template.log for more info.
Execution halted

很显然,Rmarkdown语法不起作用。根据JSS作者指南,他们建议使用`\ citep {...}〜。使用\ citep {braunWhatCanEpidemiologic2016},在打印书目时出现此错误。

output file: New_Template.knit.md

This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
! Undefined control sequence.
l.112 \printbibliography

Error: Failed to compile New_Template.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See New_Template.log for more info.
Execution halted

Here are additional files within my folder in compiling this Rmarkdown document.

使用xfun::session_info('rticles')来生成此代码的计算机上的规范

R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6, RStudio 1.1.463

Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8

Package version:
  base64enc_0.1.3 digest_0.6.18   evaluate_0.13   glue_1.3.1      graphics_3.5.2  grDevices_3.5.2
  highr_0.8       htmltools_0.3.6 jsonlite_1.6    knitr_1.22      magrittr_1.5    markdown_0.9   
  methods_3.5.2   mime_0.6        Rcpp_1.0.1      rmarkdown_1.12  rticles_0.7.1   stats_3.5.2    
  stringi_1.4.3   stringr_1.4.0   tinytex_0.11    tools_3.5.2     utils_3.5.2     xfun_0.6       
  yaml_2.2.0     

根据错误消息的建议,使用options(tinytex.verbose = TRUE)tinytex::pdflatex(),我收到了与上述相同的错误。

New_Template.tex的前几行如下:

\documentclass[article]{jss}
\usepackage[utf8]{inputenc}

\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

有趣的是,根据"Bibliography management with biblatex",LaTech文件可能缺少一些代码:

\usepackage[utf8]{inputenc}
\usepackage[english]{babel} 

\usepackage{biblatex}
\addbibresource{vignette_bib.bib}  %where "vignette_bib.bib" is the name of bibliography file

我无法LaTex文档,因为LaTexIt找不到执行jss.cls的{​​{1}}对象。

我确实希望Rmarkdown能够编译,并且引文和参考书目将遵循JSS格式。但是,使用bibLaTex和natbib的引用方式可能存在一些差异。

任何解决此问题的建议将不胜感激。谢谢。

0 个答案:

没有答案