Giter Club home page Giter Club logo

multibib's Introduction

multibib

GitHub build status

This filter allows to create multiple bibliographies using citeproc. The content of each bibliography is controlled via YAML values and the file in which a bibliographic entry is specified.

The bibliographies must be defined in a map below the bibliography key in the document's metadata. E.g.

---
bibliography:
  main: main-bibliography.bib
  software: software.bib
---

The placement of bibliographies is controlled via special divs.

# References

::: {#refs-main}
:::

# Software

::: {#refs-software}
:::

Each refs-x div should have a matching entry x in the metadata. These divs are filled with citations from the respective bib-file.

Important

This filter works best with citation styles that use non-numeric citation labels.

Usage

The filter modifies the internal document representation; it can be used with many publishing systems that are based on pandoc.

Plain pandoc

Pass the filter to pandoc via the --lua-filter (or -L) command line option.

pandoc --lua-filter multibib.lua ...

Quarto

Users of Quarto can install this filter as an extension with

quarto install extension pandoc-ext/multibib

and use it by adding multibib to the filters entry in their YAML header. (You also need to add validate-yaml: false, as per this discussion.)

---
filters:
  - multibib
validate-yaml: false
---

R Markdown

Use pandoc_args to invoke the filter. See the R Markdown Cookbook for details.

---
output:
  word_document:
    pandoc_args: ['--lua-filter=multibib.lua']
---

License

This pandoc Lua filter is published under the MIT license, see file LICENSE for details.

multibib's People

Contributors

badumont avatar bbolker avatar tarleb avatar the-solipsist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

multibib's Issues

multibib extension installed but not found during render

I am experiencing a similar issue to the one I encountered previously (and resolved) when using the section-bibliographies filter (link to description of section-bibliographies issue). That is, using RStudio/Quarto I installed the multibib extension and added multibib to the filters entry in the document's YAML header. When I render the document (to PDF), I get the error message, "Error running filter multibib: Could not find executable multibib". I then added the full relative path for multibib.lua to the multibib filter entry (/_extensions/pandoc-ext/multibib/multibib.lua). That errors with the message, "Error running filter /_extensions/pandoc-ext/multibib/multibib.lua: cannot open /_extensions/pandoc-ext/multibib/multibib.lua: No such file or directory." Using the full absolute file path produces the same error message. I have confirmed that multibib.lua is present in the referenced directory. The relevant portion of the YAML is as follows:

bibliography: 
  main: translocation.bib
  supporting: supporting_info.bib
filters: 
  - multibib
validate-yaml: false
csl: pnas.csl
format: pdf

Do you have any suggestions on how to resolve this?

Environment: Quarto 1.2.335, RStudio 2023.09.1+494, OS Ubuntu 22.04.3 LTS

quarto complaining that bibliography field should be a string

I'm sure I'm doing something silly here, but with Quarto 1.3.450, pandoc 3.1.8, quarto render books.qmd --to markdown gives:

ERROR: Validation of YAML front matter failed.
ERROR: In file books.qmd
(line 7, columns 4--24) Field "bibliography" has value main: main_books.bib, which must instead be a string
6: bibliography:
7:    main: main_books.bib
     ~~~~~~~~~~~~~~~~~~~~~
8: filters:
✖ The value main: main_books.bib is of type object.
ℹ The error happened in location bibliography.

ERROR: Render failed due to invalid YAML.

Should I be asking for help here or on Quarto forums?

Test file (I don't think you need the bib file to diagnose this ...?)

---
title: "Annotated bibliography"
bibliography:
   main: main_books.bib
filters:
   - multibib
---

## Primary references

::: {#refs-main}
:::

failure to compile pdf

I am using R version 4.2.2 and pandoc version 3.1.1 on MacOS Big Sur 11.6.

I am trying to use this filter to add multiple bibliographies to my academic CV with the vitae package. I link to a reproducible example of my issue below.

When I try to compile the document, I get the following output:

[WARNING] Citeproc: Citation with no printed form:
[WARNING] Citeproc: Citation with no printed form:
! You can't use `\vadjust' in vertical mode.
l.130 \leavevmode\vadjust
pre{\hypertarget{ref-4}{}}%

Error: LaTeX failed to compile cv_temp_test.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See cv_temp_test.log for more info.
Execution halted

I have successfully used this lua filter to knit a Word Document with Bookdown, so this appears to be an issue with knitting to a PDF specifically.

cv.zip

Improvement: Avoid repetition of references in the bibliography

In some cases, a reference may be present in more than one bibliography file. Would it be possible to avoid this repetition? That is, if a reference has already appeared in a previous bibliography section/file, to avoid displaying it again.

## Bib 1

::: {#refs-some-references}                       <!-- if it appears here -->
:::

## Bib 2

::: {#refs-other-references}                       <!-- avoid displaying it again here -->
:::

I have no idea if this is feasible, to be honest.

Inline citations not being processed when converting to Typst

I noticed a curious pattern. It happens when using multibib and converting to typst. The inline citations are not getting rendered, instead they are being converted to the typst markup.

Here is how a working document looks like after conversion to HTML.

(base) ➜  mwe3 pandoc -f markdown index.qmd -dfilters --to html
[WARNING] Citeproc: citation EN not found
<p><span class="citation" data-cites="EN">(<a href="#ref-EN"
role="doc-biblioref">Aristotelis 1831</a>)</span>.</p>
<div id="refs-primary" class="references csl-bib-body hanging-indent"
data-entry-spacing="0" role="list">
<div id="ref-EN" class="csl-entry" role="listitem">
Aristotelis. 1831. <span>“Ethica Nicomachea.”</span> In <em>Aristotelis
Opera</em>, edited by Immanuel Bekker. Berlim: Reimer.
</div>
</div>
(base) ➜  mwe3

Here is how the same file converts to typst.

(base) ➜  mwe3 pandoc -f markdown index.qmd -dfilters --to typst
[WARNING] Citeproc: citation EN not found
#cite(<EN>);.

#block[
#block[
Aristotelis. 1831. “Ethica Nicomachea.” In #emph[Aristotelis Opera];,
edited by Immanuel Bekker. Berlim: Reimer.

] <ref-EN>
] <refs-primary>
(base) ➜  mwe3

Instead of #cite(<EN>) we should be getting Aristotelis 1831.

Here is a MWE.

I still have no idea where the error could be. Using pandoc 3.1.11.

Adapting to quarto book

Hi,
I was wondering if that could be used in quarto for books (PDF) . The idea would be to have a refernce section for each chapter of my book that has a reference section in their qmd file.

I tried the following as a _quarto.yml file but it does not work


project:
  type: book

book:
  title: "Test"
  author: "name"
  date: "15.06.2023"

  chapters:
    - index.qmd
    - part: "part1"
      chapters: 
        - Article1.qmd
        - Article2.qmd
    - part: "part2"
       chapters:
          - Chapter1.qmd
          

filters: 
  - multibib
bibliography: 
  Art1: refArt1.bib
  Art2: refArt2.bib
  
format:
  html:
    theme: cosmo
  pdf:
    documentclass: scrreprt
  
editor: visual

In Article1.qmd I have a reference section


## References {.unnumbered}

::: {#refs-Art1}
:::

and the same principle in Article2.qmd.

Any idea how this would be possible or what I could try next ?

Consistent numbering between bibliographies and citations

Is it possible to get continuous number between the two bibliographies? Currently, the citations are given for example 1-18, while the corresponding two bibliographies with 9 entries each would both show 1-9. The numbering of the citations in the text are therefore not consistent with the numbering in the bibliographies.

Feature: recursive citeproc?

There some demand for recursive citations, i.e. handling \cite commands within the bibliographies themselves, usually in the BibTeX note field. See this exchange on pandoc-discuss. Would you be interested in a PR adding this?

I've written a recursive citeproc filter that we use in the journal dialectica. I'm considering updating it for Quarto, but I'd be glad to contribute to section-bibliographies and multibib and use one of these instead.

I'd try to make the addition as lightweight as possible when no recursion is needed by first scanning the first citeproc pass's output with a filter {{ Citation = function(elem) has_citations = true end }}.

Compatibility with citefield

The multibib/multiple-bibliographies filters are not compatible with citefield. I cannot say where the problem lies, but both (multibib/multiple-bibliographies & citefield) are compatible with citation-backlinks, so it seems that it should be a matter of adjusting something. However, it could be that the multibib filter is resolving all the inline citations and that when citefield comes around there is nothing left to do. In this case, it seems that the citefield filter would have to be incorporated into the multibib filter somehow for it to work. But I am not sure about this yet.

Und eine Kleinigkeit mehr...

The configuration is the same in both cases. Just the filter is different (multibib/multiple-bibliographies).

image

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.