R降价/降价 - 如何切换到rticles?

时间:2017-02-18 07:48:19

标签: r knitr bookdown

输入数据

我准备了一个示例Rmd文件,其中引用了图形,表格和等式,设置为输出' bookdown :: pdf_document2'。它可以毫无错误地编译为PDF。

我把它放在Dropbox上: https://www.dropbox.com/sh/zmu0a4wq95ywssv/AAD-nHlkDiLknLk2NVR4Xup3a?dl=0

问题

现在我希望将其设置为输出格式' rticles :: elsevier_article'

我该怎么做?

问题

当我更改输出行时: bookdown :: pdf_document2 至 艺品:: elsevier_article

我收到了错误消息。

即使我从输出中删除了其他参数:

TriedToSwitch

我仍然收到错误消息:

! Undefined control sequence.

2 个答案:

答案 0 :(得分:2)

“按原样”输入的重音字符似乎与elsevier_article的效果不佳。请参阅以下建议。

Bare-bones文件

以下是使用rticles::elsevier_article的简单文档:

---
title: "Sample document"
author: 
  - name: "Mateusz Kędzior"
    affiliation: Some Institute of Technology
    email: Mateusz@example.com
    footnote: Corresponding Author
  - name: Żąćł Źęń    
csl: https://www.zotero.org/styles/geoderma
output:
  rticles::elsevier_article:
    citation_package: natbib
    keep_tex: yes
    number_sections: yes
    toc: no
keywords: keywordA, keywordB
abstract: This is a sample abstract \newline This is the second line of abstract.
---

Hello world.

呈现无怨言:

enter image description here

带重音的参考

现在,我们希望添加带重音的引用。我们按照这里的答案:https://tex.stackexchange.com/questions/57743/how-to-write-%C3%A4-and-other-umlauts-and-accented-letters-in-bibliography。我将您的参考书目导入Zotero,然后使用“中欧(ISO)”编码(非UTF-8)导出该项目以获取

@article{kedzior_this_2018,
    title = {This is sample title only {\k A} {\L }},
    volume = {99},
    url = {http://megooglethat.com/},
    journal = {Some journal},
    author = {K{\k e}dzior, Mateusz and {\'Z}{\k e}{\'n}, {\.Z}{\k a}{\'c}{\l }},
    year = {2018},
    keywords = {keywordC},
    pages = {21 -- 31}
}

R Markdown文档现在变为

---
title: "Sample document"
author: 
  - name: "Mateusz Kędzior"
    affiliation: Some Institute of Technology
    email: Mateusz@example.com
    footnote: Corresponding Author
  - name: Żąćł Źęń    
csl: https://www.zotero.org/styles/geoderma
output:
  rticles::elsevier_article:
    citation_package: natbib
    keep_tex: yes
    number_sections: yes
    toc: no
biblio-files: bibliography2.bib
keywords: keywordA, keywordB
abstract: This is a sample abstract \newline This is the second line of abstract.
---

## Citations and references

Let me cite an article: [@kedzior_this_2018]

# References

然后我在RStudio中knit编辑了这个,但意识到我必须得到tex输出并重建它(在RStudio之外)以获得所需的输出 enter image description here

其他问题

对于图标题中的重音字符,请相应地对其进行编码(与参考书目一样)。您可能会发现http://w2.syronex.com/jmr/latex-symbols-converter有帮助。此外,据我所知,bookdown样式交叉引用不适用于rticles。如果您有后续问题,如果您将问题分解为较小的块,则可能会获得更多有用的答案。

答案 1 :(得分:1)

我在评论中添加了一些更新的材料https://github.com/rstudio/rticles/issues/92#issuecomment-402784283声明(可能会更新)的地方:

output: 
  bookdown::pdf_document2:
    base_format: rticles::elsevier_article
    number_sections: yes

这样,我的工作方式就是使用pdf_bookpdf_document2

output:
  bookdown::pdf_book:
    base_format: rticles::elsevier_article
    number_sections: yes

这允许在rticles文档中引用图形和表格。

相关问题