Citation Style Language are now usable in LaTeX documents!

For a while, JabRef uses Citation Style Language files to display entry previews (you can select among a very long list of citations styles in Options -> Preferences, Tab Entry Preview). And for your LaTeX documents, you had to rely on BibTeX or biblatex.

Thanks to a new LaTeX package, it is now possible to use CSL files within LaTeX documents to format your bibliography. So, from now on, you may use the exact same style in JabRef and in LaTeX.

Here is the package repository on CTAN: https://ctan.org/pkg/citation-style-language

1 Like

This is great news!

First thoughts:

  • As far as i can see, the package uses a CSL lua converter, which is different from the one Jabref currently uses: citeproc-java by Michel-Kraemer. This means, the formatting and rendering within Jabref may slightly differ from the rendering and formatting provided by LaTeX CSL package. This difference may be something for the docs.

  • The getting started example given in the documentation shows your bibliography being saved as a .json file and if so, it seems to be quite easy to use.

    It is not yet clear to me, if it works with a .bib file. Jabref is .bib native and lacks an export to .json :confused:, but maybe the following procedure could work?

    Other engines For engines other than LuaTeX, the citeproc executable is required to
    run on the .aux file to generate the citations and bibliography. The general procedure is
    similar to the traditional BibTeX workflow.

    1. Run latex on example.tex.
    2. Run citeproc on example.aux. The engine reads the .csl style, CSL locale files,
      and .bib database and then writes the processed citations and bibliography to
      example.bbl.
    3. Run latex on example.tex. The .bbl file is loaded and all the citations and bibli-
      ography are printed.

Hello @ThiloteE,
In fact, the documentation you pasted actually shows that it works with a .bib file. :wink:

1 Like

In LaTeX the aux file contains all the references you actually used in your tex document (PS JabRef can parse it and create a new library based on aux files)
So I guess the csl-parser uses that as a starting point

It works not only theoretically, but practically as well :slight_smile:

Minimum working example:

\documentclass[12pt,a4paper]{article}


\usepackage{citation-style-language}
	\cslsetup{
				style = apa,
				}

\addbibresource{bibliography.bib} 

\begin{document}
	
test \cite[p. 23-24]{Glass20210607PGP, Glass20210607PGP}.\\
test 2 \cite[p. 23]{Glass20210607PGP} test.\\
test 3 \cite[whatever]{Glass20210607PGP} test.\\

\printbibliography
	
\end{document}

Here the bibliographic data:

@Article{Glass20210607PGP,
  author    = {Glass, Nicola},
  date      = {2021-06-07},
  title     = {Proteste Gegen Putschisten – Widerstand in Den Nachbarländern Myanmar Und Thailand},
  doi       = {10.11588/XAREP.00004477},
  url       = {http://crossasia-repository.ub.uni-heidelberg.de/4477/},
  urldate   = {2021-09-08},
  file      = {:Glass (2021) Proteste gegen Putschisten - Widerstand in Maynmar und Thailand.pdf:PDF},
  keywords  = {Political science, FOS: Political science, Military science},
  publisher = {Heidelberg University Library},
  urn       = {urn:nbn:de:bsz:16-crossasiarep-44775},
}

Although i have to admit there really seem to be a lot of packages that are (not yet?) compatible with the csl-package. I ran into a problem using the babel package right from the start. This simple line in the preamble crashed everything: \usepackage[english]{babel}.

Hyperref not working properly and Backref not working at all really is a bummer :face_with_raised_eyebrow:

Furthermore, I was not able to cite multiple citations with page numbers (a la: citing - Multiple citations with pages using BibLaTeX - TeX - LaTeX Stack Exchange).

Interestingly, citeproc-lua published their Bib to CSL mapping:

Finally, some are already pondering how Zotero could be integrated. Could be relevant for JabRef integration: Zotero integration · Issue #8 · zepinglee/citeproc-lua · GitHub

@ThiloteE The zotero implementation is irrelevant for us, but the field mapping could be good for citeproc-java with regards to the issue https://github.com/JabRef/jabref/issues/8372#issuecomment-1023768144

1 Like