【问题标题】:Show all used references when using compact numeric citation style使用紧凑数字引文样式时显示所有使用过的参考文献
【发布时间】:2020-03-29 01:31:50
【问题描述】:

我正在使用 bookdown 从 markdown 渲染 html,并使用紧凑的数字引用样式,例如,1, 2, 3 显示为 1-3。我希望在每页的底部显示参考 (link-citations: yes),但仅显示范围内的第一个和最后一个参考(仅显示参考 1 和 3,请参见下面的屏幕截图)。有没有办法在每一页上显示所有引用的参考文献,但需要注意的是只有第一个和最后一个会被链接?

注意:所有参考文献都正确显示在最终参考书目中。

复制:

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

然后编织一个markdown文件,内容如下:

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

【问题讨论】:

标签: r r-markdown pandoc bookdown pandoc-citeproc


【解决方案1】:

我的感觉是您需要在 nature.csl 文件中查看两个元素

[第 104-131 行]。

问题似乎是您在第 112 行的 bibliography 依赖于第 104 行的 citation 定义。术语 collapse 与您的 bibliography 格式交互。

我的建议是您查看 Citation Style Language 网站并查看参考样式以更新您的特定格式。希望这能帮助您指明正确的方向。

  1. An Introduction to CSL
  2. Citation Styles Example
  3. IEEE Example
  4. Visual Editor to create a style of your choosing and download

我的感觉是您需要在 .csl 文件中创建自定义 cite-group-delimiter 定义,而不是使用 collapse。可能很棘手,但感觉可行。

  1. http://docs.citationstyles.org/en/stable/specification.html#citation

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

引用

cs:citation 元素描述了引文的格式,它由一个或多个参考书目来源(“引文”)组成。引用以文本引用(在作者中(例如“[Doe]”)、作者日期(“[Doe 1999]”)、标签(“[doe99]”)或数字(“@987654326 @”) 格式)或注释。所需的 cs:layout 子元素描述了书目数据应包含在引文中的内容和方式(请参阅布局)。 cs:layout 前面可能有一个 cs:sort 元素,它可用于指定引用中的引用应如何排序(请参阅排序)。 cs:citation 元素可以携带 Citation-specific Options 和 Inheritable Name Options 的属性。 cs:citation 元素的示例:

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

给 CSL 处理器开发人员的注释 在注释样式中,引用通常是一个句子本身。因此,当注释中没有前面的文本时,引用的第一个字符最好是大写。在所有其他情况下(例如,将引文插入现有脚注的中间时),应按原样打印引文。

参考书目

cs:bibliography 元素描述了书目的格式,其中列出了一个或多个书目来源。所需的 cs:layout 子元素描述了每个书目条目的格式。 cs:layout 前面可以有一个 cs:sort 元素,它可以用来指定参考书目中的参考文献应该如何排序(参见排序)。 cs:bibliography 元素可以携带 Bibliography 特定选项和可继承名称选项的属性。 cs:bibliography 元素的示例:

<bibliography>
  <sort>
    <key macro="author"/>
  </sort>
  <layout>
    <group delimiter=". ">
      <text macro="author"/>
      <text variable="title"/>
    </group>
  </layout>
</bibliography>

【讨论】:

  • 感谢您的解释。您是否期望您链接的 IEEE 示例会立即生成所需的参考列表?我进行了测试,认为我可以修改该样式以使用上标数字,但它也省略了我的文档的参考 2。 (请注意,最终参考列表是准确的 [对于自然风格以及您的链接风格] - 显示了所有 3 个参考。但当前页面的参考列表不完整。)
  • @jbaums 总是乐于提供帮助。我以 IEEE 为例,知道当前页面引用列表需要作为修改后的定义添加到您的 .csl 文件中。我试图找到一个例子,但我认为我应该立即为您指出正确的方向。它还有望让其他人看到他们如何能够在我分享的内容之上提供解决方案。
  • 感谢您的澄清 - 这些链接确实很有用,非常感谢。
  • 如果我有完整的解决方案,我会多做一点,并更新。希望其他人也能提供帮助。
  • 事实证明,这是由于 bookdown 在将围兜分成章节时对待引用的方式。我已经破解了一个解决方案here,它可以在使用非紧凑数字样式渲染 html 后应用(例如this style,但删除了 collapse="citation-number")。希望将来 bookdown 会支持这一点,或者@YihuiXie 可以提出另一种解决方法?
猜你喜欢
  • 2018-06-20
  • 2021-08-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-15
  • 1970-01-01
相关资源
最近更新 更多