R markdown / bookdown - 如何切换到文章?

R markdown / bookdown - how to switch to rticles?

输入数据

我准备了一个示例 Rmd 文件,参考了图 table 和方程,设置为输出 'bookdown::pdf_document2'。它编译成 PDF 没有错误。

我将它放在保管箱中: https://www.dropbox.com/sh/zmu0a4wq95ywssv/AAD-nHlkDiLknLk2NVR4Xup3a?dl=0


问题

现在我想设置为输出格式'rticles::elsevier_article'

我该怎么做?

问题

当我更改输出行时: bookdown::pdf_document2 到 rticles::elsevier_article

我收到一条错误消息。

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

我仍然收到一条错误消息:

! Undefined control sequence.

输入 "as is" 时的重音字符在 elsevier_article 中表现不佳。请参阅以下建议。


Bare-bones 文档

这是一个 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.

没有投诉的渲染:


带重音的引用

现在,我们希望添加带有重音符号的参考。我们按照这里的答案:https://tex.stackexchange.com/questions/57743/how-to-write-%C3%A4-and-other-umlauts-and-accented-letters-in-bibliography。我将你的参考书目导入 Zotero,然后用 "Central European (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

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


其他问题

对于图形标题中的重音字符,相应地对其进行编码(与参考书目一样)。您可能会发现 http://w2.syronex.com/jmr/latex-symbols-converter 有帮助。此外,据我所知,bookdown 风格 cross-referencing 不适用于 rticles。如果您有 follow-up 个问题,将问题分解成更小的问题可能会得到更有帮助的答案。

我在评论中添加了一些更新的 material 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 文档中引用图形和 table。