jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.68k stars 3.39k forks source link

How to resolve the issue of duplicate references in the compilation output when citing literature in Markdown language using Pandoc in VSCode #9282

Closed YeyouminTian closed 10 months ago

YeyouminTian commented 10 months ago

I was using Pandoc within Visual Studio Code (VSCode) to compile a Markdown document that contains literature citations. The specific problem arises after compilation: the resulting document displays each referenced bibliography entry twice, leading to duplicate references in the output. This issue persists despite the correct implementation of Markdown syntax for citations and the appropriate setup of the bibliography file (mybib.bib) and the CSL file (china-C.csl). Additionally, the YAML header in the Markdown document seems to be correctly formatted with necessary fields like bibliography, csl, and other document settings. The problem appears to be related to the Pandoc conversion process or possibly the settings or templates used during this conversion.

---
bibliography: ['bibliography.bib']

csl: [china-national-standard-gb-t-7714-2015-numeric-AuLower-Bilan.csl]

title: Test
link-citations: true
lang: en-US
figPrefix:
  - "Fig."
  - "Figs."
linkReferences: true
papersize: a4
colorlinks: true
links-as-notes: true
author: Author
abstract: Abstract
keywords: [nothing, nothingness]

---

Reference[@aidalaHousingStatusMedical2016]

The result of compilation is:

Reference[1]

[1] Matthews R B, Gilbert N G, Roach A, et al. Agent-Based Land-Use Models: A Review of Applications[J/OL]. Landscape Ecology, 2007, 22(10): 1447–1459[2023–12–18]. https://doi.org/10.1007/s10980-007-9135-1. DOI:10.1007/s10980-007-9135-1[1]Matthews R B, Gilbert N G, Roach A, et al. Agent-based land-use models: A review of applications[J/OL]. Landscape Ecology, 2007, 22(10): 1447–1459[2023–12–18]. https://doi.org/10.1007/s10980-007-9135-1. DOI:10.1007/s10980-007-9135-1.

How can I fix it?

jgm commented 10 months ago

Unless you can give full instructions for reproducing the issue in pandoc (not some third-party plugin), we can't help you. At minimum we'd need the full pandoc command line used and not just the markdown above but the bib and csl files it uses. Also the pandoc version number.

I think it's unlikely that it's an issue in pandoc itself, but we can't tell without further information. If you can't reproduce the issue in pandoc without VSCode, then I'd report the issue instead to the author of the preview plugin.