簡體   English   中英

文章中的交叉引用

[英]Cross-referencing in rticles

bookdown 為方程、圖形、表格和部分提供了很好的交叉引用選項: https ://bookdown.org/yihui/bookdown/cross-references.html

但是,當我將其設置為輸出“文章:: elsevier_article”時,它們似乎不起作用。

文章中的交叉引用有哪些可用選項?

我沒試過,但這里有一個可能的解決方案: https : //bookdown.org/yihui/bookdown/a-single-document.html

特別是,在您的 YAML 元數據中指定:

output:
  bookdown::pdf_book:
    base_format: rticles::elsevier_article

由於我是使用R Markdown新手,因此我決定發布此答案,因為有些人可能會犯同樣的錯誤。 我已經嘗試過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 TemplateElsevier Journal Article 在那之后,我使用了F Rodriguez-Sanchez建議的答案並且它起作用了!

最終的 yaml 標頭是:

---
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 請確保通過從模板中選擇新文件並選擇 Elsevier 期刊版本/模板來打開 RMarkdown。 模板將在文章安裝后可用。

這將設置文章“基礎設施”(特別是相應的 cls 和其他文件)。 這還包括一個 mybibfile.bib 示例(因此,我不需要注釋 biblio)。 如果您選擇將其保存在子文件夾中,請確保您的 Rmd 文件保存在該子文件夾中。

如上/下所示,更改 YAML 的output:標簽以包含 bookdown 和 baseformat rticles::elsevier_article 指針。
仔細檢查冒號和制表符的使用。

根據上面的示例,您可以使用 bookdown 交叉引用,如下所示。 我用了
(i) 使用(ref:awesomeplotcaption)在代碼塊之前定義的外部(bookdown)圖形標題。 這對於保持塊選項簡短(er)很有用。
(ii) 對圖\\@ref(fig:awesomeplot)的(bookdown)交叉引用。 請注意\\@ref(fig:...)使用塊名稱來使指針工作。 因此,請確保您的塊名稱帶有標准字母、數字和破折號,即沒有下划線!

按下針織按鈕會變魔術!

---
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).

這導致以下結果:

bookdown-reference-in-elsevier-模板

PS 關注交叉引用並忽略代碼塊,這可以用echo = FALSE隱藏。 下圖如下(在本例中,通過 LATEX 放置)。 我截斷了它以保持數字易於管理:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM