文章中的交叉引用
Cross-referencing in rticles
本书提供了很好的方程式、图形、表格和章节的交叉引用选项:
https://bookdown.org/yihui/bookdown/cross-references.html
但是,当我设置为输出时它们似乎不起作用 'rticles::elsevier_article'。
文章中交叉引用的可用选项有哪些?
我没试过,但这里有一个可能的解决方案:https://bookdown.org/yihui/bookdown/a-single-document.html
特别是,在您的 YAML 元数据中指定:
output:
bookdown::pdf_book:
base_format: rticles::elsevier_article
因为我是 R Markdown
的新手,所以我决定 post 这个答案,因为有些人可能会犯同样的错误。我自己尝试了 F Rodriguez-Sanchez 答案,但没有用。我收到以下消息:
! LaTeX Error: File `elsarticle.cls' not found.
! Emergency stop.
<read *>
Erro: Failed to compile report.tex. See report.log for more info.
它没有用,因为我犯了一个新手错误,因为我试图添加建议的答案选择 New Markdown
然后选择 Document
。
然后我尝试打开 New R Markdown
从 rticles
包中选择 From Template
和 Elsevier Journal Article
。之后,我使用了 F Rodriguez-Sanchez 建议的答案并且有效!
最终的 yaml header 是:
---
title: Short Paper
author:
- name: Alice Anonymous
email: alice@example.com
affiliation: Some Institute of Technology
footnote: Corresponding Author
- name: Bob Security
email: bob@example.com
affiliation: Another University
address:
- code: Some Institute of Technology
address: Department, Street, City, State, Zip
- code: Another University
address: Department, Street, City, State, Zip
abstract: |
This is the abstract.
It consists of two paragraphs.
journal: "An awesome journal"
date: "`r Sys.Date()`"
bibliography: mybibfile.bib
output:
bookdown::pdf_book:
base_format: rticles::elsevier_article
---
@maycca 请确保通过从模板中选择新文件和select Elsevier Journal version/template 打开 RMarkdown。模板将在文章安装后可用。
这将设置文章“基础结构”(特别是相应的 cls 和其他文件)。这还包括一个 mybibfile.bib 示例(因此,我不需要将参考书目注释掉)。
如果您选择将其保存在 sub-folder 中,请确保您的 Rmd 文件保存在 sub-folder.
中
如前所述 above/below 更改 YAML 的 output:
标签以包含 bookdown 和基本格式 rticles::elsevier_article 指针。
仔细检查冒号和制表符的使用。
基于上面的示例,您可以使用如下所示的 bookdown cross-referencing。我用了
(i) 使用 (ref:awesomeplotcaption)
在代码块之前定义的外部(bookdown)图形标题。这对于保持块选项简短(呃)很有用。
(ii) a (bookdown) cross-reference 到图 \@ref(fig:awesomeplot)
。请注意 \@ref(fig:...)
使用 chunk-name 使指针工作。因此,请确保您的 chunk-name 带有标准字母、数字和破折号,即没有下划线!
按下针织按钮就会产生奇迹!
---
title: Short Paper
author:
- name: Alice Anonymous
email: alice@example.com
affiliation: Some Institute of Technology
footnote: Corresponding Author
- name: Bob Security
email: bob@example.com
affiliation: Another University
address:
- code: Some Institute of Technology
address: Department, Street, City, State, Zip
- code: Another University
address: Department, Street, City, State, Zip
abstract: |
This is the abstract.
It consists of two paragraphs.
journal: "An awesome journal"
date: "`r Sys.Date()`"
#bibliography: mybibfile.bib
output:
bookdown::pdf_book:
base_format: rticles::elsevier_article
---
# First Heading
Some cool introductory text.
And an even more fascinating plot.
(ref:awesomeplotcaption) A simple demo plot
```{r awesomeplot, fig.cap="(ref:awesomeplotcaption)"}
x <- -5:5
y <- x^2
plot(x,y)
```
More explanatory text.
Using bookdown cross-referencing, have again a closer look at Fig. \@ref(fig:awesomeplot).
结果如下:
P.S。关注 cross-reference 而忽略 code-chunk,这可以用 echo = FALSE
隐藏。下图如下(在本例中,通过 LATEX 放置)。我截断了它以使数字易于管理:)
本书提供了很好的方程式、图形、表格和章节的交叉引用选项: https://bookdown.org/yihui/bookdown/cross-references.html
但是,当我设置为输出时它们似乎不起作用 'rticles::elsevier_article'。
文章中交叉引用的可用选项有哪些?
我没试过,但这里有一个可能的解决方案:https://bookdown.org/yihui/bookdown/a-single-document.html
特别是,在您的 YAML 元数据中指定:
output:
bookdown::pdf_book:
base_format: rticles::elsevier_article
因为我是 R Markdown
的新手,所以我决定 post 这个答案,因为有些人可能会犯同样的错误。我自己尝试了 F Rodriguez-Sanchez 答案,但没有用。我收到以下消息:
! LaTeX Error: File `elsarticle.cls' not found.
! Emergency stop.
<read *>
Erro: Failed to compile report.tex. See report.log for more info.
它没有用,因为我犯了一个新手错误,因为我试图添加建议的答案选择 New Markdown
然后选择 Document
。
然后我尝试打开 New R Markdown
从 rticles
包中选择 From Template
和 Elsevier Journal Article
。之后,我使用了 F Rodriguez-Sanchez 建议的答案并且有效!
最终的 yaml header 是:
---
title: Short Paper
author:
- name: Alice Anonymous
email: alice@example.com
affiliation: Some Institute of Technology
footnote: Corresponding Author
- name: Bob Security
email: bob@example.com
affiliation: Another University
address:
- code: Some Institute of Technology
address: Department, Street, City, State, Zip
- code: Another University
address: Department, Street, City, State, Zip
abstract: |
This is the abstract.
It consists of two paragraphs.
journal: "An awesome journal"
date: "`r Sys.Date()`"
bibliography: mybibfile.bib
output:
bookdown::pdf_book:
base_format: rticles::elsevier_article
---
@maycca 请确保通过从模板中选择新文件和select Elsevier Journal version/template 打开 RMarkdown。模板将在文章安装后可用。
这将设置文章“基础结构”(特别是相应的 cls 和其他文件)。这还包括一个 mybibfile.bib 示例(因此,我不需要将参考书目注释掉)。 如果您选择将其保存在 sub-folder 中,请确保您的 Rmd 文件保存在 sub-folder.
中如前所述 above/below 更改 YAML 的 output:
标签以包含 bookdown 和基本格式 rticles::elsevier_article 指针。
仔细检查冒号和制表符的使用。
基于上面的示例,您可以使用如下所示的 bookdown cross-referencing。我用了
(i) 使用 (ref:awesomeplotcaption)
在代码块之前定义的外部(bookdown)图形标题。这对于保持块选项简短(呃)很有用。
(ii) a (bookdown) cross-reference 到图 \@ref(fig:awesomeplot)
。请注意 \@ref(fig:...)
使用 chunk-name 使指针工作。因此,请确保您的 chunk-name 带有标准字母、数字和破折号,即没有下划线!
按下针织按钮就会产生奇迹!
---
title: Short Paper
author:
- name: Alice Anonymous
email: alice@example.com
affiliation: Some Institute of Technology
footnote: Corresponding Author
- name: Bob Security
email: bob@example.com
affiliation: Another University
address:
- code: Some Institute of Technology
address: Department, Street, City, State, Zip
- code: Another University
address: Department, Street, City, State, Zip
abstract: |
This is the abstract.
It consists of two paragraphs.
journal: "An awesome journal"
date: "`r Sys.Date()`"
#bibliography: mybibfile.bib
output:
bookdown::pdf_book:
base_format: rticles::elsevier_article
---
# First Heading
Some cool introductory text.
And an even more fascinating plot.
(ref:awesomeplotcaption) A simple demo plot
```{r awesomeplot, fig.cap="(ref:awesomeplotcaption)"}
x <- -5:5
y <- x^2
plot(x,y)
```
More explanatory text.
Using bookdown cross-referencing, have again a closer look at Fig. \@ref(fig:awesomeplot).
结果如下:
P.S。关注 cross-reference 而忽略 code-chunk,这可以用 echo = FALSE
隐藏。下图如下(在本例中,通过 LATEX 放置)。我截断了它以使数字易于管理:)