最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

r - Rmarkdown add an item to a bibliography without citing in the text, bibliography by order of appearance - Stack Overflow

programmeradmin2浏览0评论

I would like to have a bibliography which lists items that are cited in the text but also others that are not (e.g. using nocite). The csl style that I am using sorts by order of appearance with:

<sort>
  <key variable="citation-number"/>
</sort>

I cannot change the csl style as it corresponds to a specific scientific journal.

My problem is that the citations that are not quoted in the text systematically appear at the end of the bibliography, whereas I would like some of them to appear before the ones that are cited in the text, or even in between them.

Example of csl style:

I am using Rmarkdown and bookdown. Here is an example:

---
title: ""
author: ""
output:
  bookdown::pdf_document2:
bibliography: references.bib
csl: springer-basic-brackets.csl
nocite: |
  @item1
---

Cite this in the text [@item2].

Also cite this [@item3].

\newpage
# References {-}

<div id="refs"></div>

In this example I would like to have a bibliography with

item1
item2
item3

instead of

item2
item3
item1

I would like to even be able to get somehow:

item2
item1
tiem3

I tried using \nocite{} but it didn't work. Any advice?

I would like to have a bibliography which lists items that are cited in the text but also others that are not (e.g. using nocite). The csl style that I am using sorts by order of appearance with:

<sort>
  <key variable="citation-number"/>
</sort>

I cannot change the csl style as it corresponds to a specific scientific journal.

My problem is that the citations that are not quoted in the text systematically appear at the end of the bibliography, whereas I would like some of them to appear before the ones that are cited in the text, or even in between them.

Example of csl style: https://www.zotero.org/styles/springer-basic-brackets

I am using Rmarkdown and bookdown. Here is an example:

---
title: ""
author: ""
output:
  bookdown::pdf_document2:
bibliography: references.bib
csl: springer-basic-brackets.csl
nocite: |
  @item1
---

Cite this in the text [@item2].

Also cite this [@item3].

\newpage
# References {-}

<div id="refs"></div>

In this example I would like to have a bibliography with

item1
item2
item3

instead of

item2
item3
item1

I would like to even be able to get somehow:

item2
item1
tiem3

I tried using \nocite{} but it didn't work. Any advice?

Share Improve this question asked Feb 7 at 17:59 sebastien1785sebastien1785 957 bronze badges 7
  • Seems like you are contradicting yourself. On the one side "I cannot change the csl style as it corresponds to a specific scientific journal." --> The .CSL explicitly says that bib items should appear in the same order as they do in the text. What you want now is to keep the order in the text, but resort the bibliography order to be item1, item2, item3 (which is not as they appear in the text). Therefore, you either need to adjust the sorting in the CSL by some variable to fit your needs, like <key variable="title" sort="ascending"/> or leave it as is. – dog Commented Feb 7 at 20:33
  • nocite: | @item1 or nocite: '@*' do not work, because they simply add bib items to the toc, but they don't influence the sorting order. – dog Commented Feb 7 at 20:35
  • I think inserting <sort><key/></sort> on line 77 of the .csl and including nocite: '@*' in the yaml should include all entries in the order they appear in the .bib while otherwise staying consistent with the style. – the-mad-statter Commented Feb 8 at 17:24
  • @dog, my issue is precisely that items are in the same order as they appear in the text, but item1 does not appear in the text. I would like to be able to order item1 as if it appeared before, in between or after item2 and item3. – sebastien1785 Commented yesterday
  • @the-mad-statter, it would have indeed been nice to have the entries in the order they appear in the .bib. Unfortunately, inserting <sort><key/></sort> and nocite: '@*' still leads to the entries that appear in the text to be ordered first, regardless of their order in the .bib. – sebastien1785 Commented yesterday
 |  Show 2 more comments

1 Answer 1

Reset to default 0

I figured out a solution after looking at: https://tex.stackexchange.com/questions/591882/citation-within-a-latex-figure-caption-in-rmarkdown

Using the following:

(ref:invisible) [@item1]

allowed me to get what I wanted.

For instance:

---
title: ""
author: ""
output:
  bookdown::pdf_document2:
    toc: no
bibliography: references.bib
csl: springer-basic-brackets.csl
---

(ref:invisible) [@item1]

Cite this in the text [@item2].

Also cite this [@item3].

# References {-}

<div id="refs"></div>

with references.bib:

@article{item1,
    title = {Article1},
    author = {Author1},
    year = {2018},
}

@article{item2,
    title = {Article2},
    author = {Author2},
    year = {2019},
}

@article{item3,
    title = {Article1},
    author = {Author3},
    year = {2017},
}

produced:

By changing the position of (ref:invisible) [@item1], the order of the bibliography changed accordingly, for instance:

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论