I'm rendering html from markdown using bookdown
, and using a compact numeric citation style so that e.g., 1, 2, 3
is shown as 1-3
. I'd like references to be shown at the bottom of each page (link-citations: yes
), but only the first and last reference in the range are shown (only refs 1 and 3 are shown, see screenshot below). Is there a way to have all cited references displayed on each page, with the caveat that only the first and last would be linked?
NB: all refs are correctly shown on the final bibliography.
To reproduce:
download.file('https://raw.githubusercontent.com/jgm/pandoc-citeproc/7d824e2e0d4698cf8a6d5e784aa0df27a0f2888a/tests/biblio.bib', 'ex.bib')
download.file('https://raw.githubusercontent.com/citation-style-language/styles/31187daa2c010df338c2bf9b7b30070c91b7af95/nature.csl', 'nature.csl')
and knit a markdown file with the following content:
---
title: A title
author: An author
bibliography: ex.bib
link-citations: yes
output:
bookdown::gitbook:
pandoc_args: [ "--csl", "nature.csl" ]
---
# Intro
baz [@item1; @item2; @пункт3]
# Refs
> sessioninfo::session_info()
─ Session info ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 3.6.0 (2019-04-26)
os macOS Mojave 10.14.3
system x86_64, darwin15.6.0
ui RStudio
language (EN)
collate en_AU.UTF-8
ctype en_AU.UTF-8
tz Australia/Melbourne
date 2020-03-29
─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date lib source
assertthat 0.2.1 2019-03-21 [2] CRAN (R 3.6.0)
bookdown 0.17 2020-01-11 [1] CRAN (R 3.6.0)
cli 2.0.2 2020-02-28 [1] CRAN (R 3.6.0)
crayon 1.3.4 2017-09-16 [2] CRAN (R 3.6.0)
digest 0.6.25 2020-02-23 [1] CRAN (R 3.6.0)
evaluate 0.14 2019-05-28 [2] CRAN (R 3.6.0)
fansi 0.4.1 2020-01-08 [1] CRAN (R 3.6.0)
glue 1.3.2 2020-03-12 [1] CRAN (R 3.6.0)
htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.0)
knitr 1.25 2019-09-18 [1] CRAN (R 3.6.0)
packrat 0.5.0 2018-11-14 [2] CRAN (R 3.6.0)
Rcpp 1.0.4 2020-03-17 [1] CRAN (R 3.6.0)
rlang 0.4.5 2020-03-01 [1] CRAN (R 3.6.0)
rmarkdown 1.16 2019-10-01 [1] CRAN (R 3.6.0)
rsconnect 0.8.15 2019-07-22 [2] CRAN (R 3.6.0)
rstudioapi 0.10 2019-03-19 [2] CRAN (R 3.6.0)
sessioninfo 1.1.1 2018-11-05 [2] CRAN (R 3.6.0)
withr 2.1.2 2018-03-15 [2] CRAN (R 3.6.0)
xfun 0.10 2019-10-01 [1] CRAN (R 3.6.0)
yaml 2.2.0 2018-07-25 [2] CRAN (R 3.6.0)
❯ pandoc --version
pandoc 2.9.2.1
Compiled with pandoc-types 1.20, texmath 0.12.0.1, skylighting 0.8.3.2
...
Copyright (C) 2006-2020 John MacFarlane
Web: https://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.
❯ pandoc-citeproc --version
pandoc-citeproc 0.17
The first item you cite is numbered 1 and the second numbered 2 and so on. If you need to cite an item more than once in your document, use the same number every time. You should use the smallest number - the one used when the item is first cited in the document.
As far as I've found, MLA seems to be the shortest as it switches author names to "et al." when there's four or more authors, whereas other citation styles that I've looked at only switch with a higher number of authors.
The Vancouver referencing style The Vancouver system is numerical; each piece of work cited within the text is identified by a unique Arabic number. The numbers are assigned in the order of citation.
My sense is that there are two elements you need to look at within the nature.csl
file
[Lines 104-131].
The problem appears to be that your bibliography
on line 112 is dependent on the citation
definition on line 104. The term collapse
interacts with your bibliography
formating.
My recommendation is you take a look at the Citation Style Language web site and look over the reference styles to update your particular formating. Hoping this will help point you in the right direction.
my sense is you need to create a custom cite-group-delimiter
definition in your .csl
file rather than use a collapse
. Can be tricky but feels doable.
<citation collapse="citation-number">
<sort>
<key variable="citation-number"/>
</sort>
<layout vertical-align="sup" delimiter=",">
<text variable="citation-number"/>
</layout>
</citation>
<bibliography et-al-min="6" et-al-use-first="1" second-field-align="flush" entry-spacing="0" line-spacing="2">
<layout suffix=".">
<text variable="citation-number" suffix="."/>
<group delimiter=" ">
<text macro="author" suffix="."/>
<text macro="title" suffix="."/>
<choose>
<if type="chapter paper-conference" match="any">
<text term="in"/>
</if>
</choose>
<text macro="container-title"/>
<text macro="editor"/>
<text macro="volume"/>
<text variable="page"/>
<text macro="issuance"/>
<text macro="access"/>
</group>
</layout>
</bibliography>
Citation
The cs:citation element describes the formatting of citations, which consist of one or more references (“cites”) to bibliographic sources. Citations appear in the form of either in-text citations (in the author (e.g. “[Doe]”), author-date (“[Doe 1999]”), label (“[doe99]”) or number (“1”) format) or notes. The required cs:layout child element describes what, and how, bibliographic data should be included in the citations (see Layout). cs:layout may be preceded by a cs:sort element, which can be used to specify how cites within a citation should be sorted (see Sorting). The cs:citation element may carry attributes for Citation-specific Options and Inheritable Name Options. An example of a cs:citation element:
<citation>
<sort>
<key variable="citation-number"/>
</sort>
<layout>
<text variable="citation-number"/>
</layout>
</citation>
A note to CSL processor developers In note styles, a citation is often a sentence by itself. Therefore, the first character of a citation should preferably be uppercased when there is no preceding text in the note. In all other cases (e.g. when a citation is inserted into the middle of a pre-existing footnote), the citation should be printed as is.
Bibliography
The cs:bibliography element describes the formatting of bibliographies, which list one or more bibliographic sources. The required cs:layout child element describes how each bibliographic entry should be formatted. cs:layout may be preceded by a cs:sort element, which can be used to specify how references within the bibliography should be sorted (see Sorting). The cs:bibliography element may carry attributes for Bibliography-specific Options and Inheritable Name Options. An example of a cs:bibliography element:
<bibliography>
<sort>
<key macro="author"/>
</sort>
<layout>
<group delimiter=". ">
<text macro="author"/>
<text variable="title"/>
</group>
</layout>
</bibliography>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With