[ANN] DocumenterCitations v1.0.0

DocumenterCitations.jl is a Documenter.jl plugin to add BibTeX citations to your documentation.

By default, DocumenterCitations.jl uses a numeric citation style common in the natural sciences. Citations are shown in-line, as a number enclosed in square brackets, e.g., “Optimal control is a cornerstone in the development of quantum technologies [1].”

Alternatively, author-year and alphabetic citations styles are available. It is also possible to define custom styles.

The project recently became part of the JuliaDocs organization and is now available in its first “stable” version 1.0.

Usage

  • Place a BibTeX refs.bib file in the docs/src folder of your project. Then, in docs/make.jl, instantiate the CitationBibliography plugin and pass it to makedocs:

    using DocumenterCitations
    
    bib = CitationBibliography(joinpath(@__DIR__, "src", "refs.bib"))
    makedocs(bib, ...)
    
  • Optional, but recommended: add CSS to properly format the bibliography

  • Somewhere in your documentation, include a markdown block

    ```@bibliography
    ```
    

    that will expand into a bibliography for all citations in the documentation.

  • Anywhere in the documentation or in docstrings, insert citations as, e.g., [GoerzQ2022](@cite), which will be rendered as “[2]” and link to the full reference in the bibliography.

See the documentation and especially the Syntax section for details.

New Features

From the release notes for the 1.0 release:

  • CitationBibliography now takes a style keyword argument. The default style is style=:numeric. Other built-in styles are style=:authoryear (corresponding to the pre-1.0 default) and style=:alpha.
  • It is now possible to implement custom citation styles.
  • The @bibligraphy block can now have additional options to customize which references are included, see Syntax for the Bibliography Block.
  • It is possible to generate secondary bibliographies, e.g., for a specific page.
  • There is new syntax to create links to bibliographic references with arbitrary text.
  • The following variations of the @cite command are now supported: @citet, @citep, @cite*, @citet*, @citep*, @Citet, @Citep, @Cite*, @Citet*, @Citep*. See the syntax for citations for details.
  • Citations can now include notes, e.g., See Ref. [GoerzQ2022; Eq. (1)](@cite).

Upgrading from DocumenterCitations v0.2.12

The most notable breaking change in the 1.0 release relative to the previous version 0.2.12 is that the default citation style has changed from author-year to numeric.

As an existing user of the DocumenterCitations plugin, you should add an explicit style=:authoryear keyword argument when instantiating the plugin in your docs/make.jl file:

using DocumenterCitations

bib = CitationBibliography(
    joinpath(@__DIR__, "src", "refs.bib");
    style=:authoryear
)
makedocs(bib, ...)

In the long term, you may find the default :numeric style preferable, as it is much more common in many of the fields where Julia is most used. However, you will likely have to rephrase parts of your documentation slightly to switch from an author-year style to a numeric style. The @citet and @citet* syntax may be helpful for the transition, as well as the ability to have arbitrary link text.

If you are using DocumenterCitations in your project, consider opening a pull request to add a link to the list of examples.

For any feature requests, please don’t hesitate to open an issue.

36 Likes

Woah! This looks amazing! Thanks for all the work!

I checked back on this every now and then before it moved into the JuliaDocs org and was usually missing one or two things, e.g. bibliography per page and the possibility of 'citet – but all that is present now! I am very much looking forward to reworking all my references (I use them a lot in my docs) to unify them and being read from a bibtex file.

2 Likes

This looks cool! It would be good if CSL were used for the citation styles though, but unfortunately as far as I’m aware CSL.jl doesn’t yet exist.

2 Likes

I was even thinking about starting CSL.jl myself but until now I am too busy already with my existing projects; but I would surely help if someone started that.

CSL would definitely be welcome. There’s an issue with some notes for that: Support for arbitrary CSL styles · Issue #13 · JuliaDocs/DocumenterCitations.jl · GitHub

2 Likes

Is there a way to include all references in a bib but ignore a few supplied as a list?

There is not, but it probably wouldn’t be very hard to implement. You could basically have the same syntax as for explicit inclusion, but with a minus sign in front of the keys to indicate explicit exclusion (hopefully, nobody starts their citation keys with minus).

It feels a little far-fetched, though… why not just leave the entries you don’t want to show out of the .bib file? Can you elaborate a little on your use case?

Opened an issue at Allow to exclude specific entries from the bibliography · Issue #23 · JuliaDocs/DocumenterCitations.jl · GitHub

with a minus sign in front of the keys to indicate explicit exclusion

Keys can technically start with a minus, so maybe that’s not the ideal syntax. Nor is putting a space after the minus, because that looks like a markdown list. Using ! (with a space) would work, though.

I’d still be interested in understanding the use case for this a little better.

I was thinking of a real lazy way to make a CV from exporting citations from google scholar but removing some things like repeat citations from preprints, conference abstracts, and other oddities that show uo from time to time.

Quite honestly, I’m skeptical that you’ll have much luck with that. Any BibTeX code you get off Google Scholar is probably going to be too low quality (missing / extra / inconsistent / improperly capitalized fields, no DOI, etc.) to be very useful. If you have conference contributions or seminar talks, those likely won’t even show up on Google Scholar. You’ll be much better off maintaining a clean .bib file by hand for your CV website. That’s what I do for my own website, albeit rendered via a Python script.

Also note that there’s some potential issues with DocumenterCitations and arbitrary BibTeX files: Not everything that works in a LaTeX context is going to work perfectly with DocumenterCitations, simply because the strings in the .bib file aren’t going be run through the TeX engine, but are considered plain text or markdown after some basic cleanup.

1 Like