# Citation Style Language are now usable in LaTeX documents!

**URL:** <https://discourse.jabref.org/t/citation-style-language-are-now-usable-in-latex-documents/3175>\
**Category:** Features\
**Created:** [January 26, 2022, 7:47pm UTC](https://discourse.jabref.org/t/citation-style-language-are-now-usable-in-latex-documents/3175 "2022-01-26T19:47:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlep](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/mlep/32/387_2.png) [@mlep](https://discourse.jabref.org/u/mlep)\
**Post date:** [January 26, 2022, 7:47pm UTC](https://discourse.jabref.org/t/citation-style-language-are-now-usable-in-latex-documents/3175/1 "2022-01-26T19:47:59Z")

</div>

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](https://ctan.org/pkg/citation-style-language)

---

<div class="post-metadata">

**Author:** ![ThiloteE](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/thilotee/32/1008_2.png) [@ThiloteE](https://discourse.jabref.org/u/ThiloteE)\
**Post date:** [January 27, 2022, 3:05pm UTC](https://discourse.jabref.org/t/citation-style-language-are-now-usable-in-latex-documents/3175/2 "2022-01-27T15:05:10Z")

</div>

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](https://github.com/michel-kraemer/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.

---

<div class="post-metadata">

**Author:** ![mlep](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/mlep/32/387_2.png) [@mlep](https://discourse.jabref.org/u/mlep)\
**Post date:** [January 27, 2022, 8:33pm UTC](https://discourse.jabref.org/t/citation-style-language-are-now-usable-in-latex-documents/3175/3 "2022-01-27T20:33:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Siedlerchr](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/siedlerchr/32/216_2.png) [@Siedlerchr](https://discourse.jabref.org/u/Siedlerchr)\
**Post date:** [January 27, 2022, 8:43pm UTC](https://discourse.jabref.org/t/citation-style-language-are-now-usable-in-latex-documents/3175/4 "2022-01-27T20:43:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ThiloteE](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/thilotee/32/1008_2.png) [@ThiloteE](https://discourse.jabref.org/u/ThiloteE)\
**Post date:** [February 3, 2022, 4:30am UTC](https://discourse.jabref.org/t/citation-style-language-are-now-usable-in-latex-documents/3175/5 "2022-02-03T04:30:59Z")

</div>

It works not only theoretically, but practically as well 🙂

Minimum working example:

```auto
\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:

```auto
@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 🤨

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](https://tex.stackexchange.com/questions/18910/multiple-citations-with-pages-using-biblatex?noredirect=1&lq=1)).

---

<div class="post-metadata">

**Author:** ![ThiloteE](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/thilotee/32/1008_2.png) [@ThiloteE](https://discourse.jabref.org/u/ThiloteE)\
**Post date:** [February 3, 2022, 4:34am UTC](https://discourse.jabref.org/t/citation-style-language-are-now-usable-in-latex-documents/3175/6 "2022-02-03T04:34:52Z")

</div>

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

> **[Bib CSL mapping · zepinglee/citeproc-lua Wiki](https://github.com/zepinglee/citeproc-lua/wiki/Bib-CSL-mapping)**
>
> A Lua implementation of the Citation Style Language (CSL) - Bib CSL mapping · zepinglee/citeproc-lua Wiki

---

<div class="post-metadata">

**Author:** ![ThiloteE](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/thilotee/32/1008_2.png) [@ThiloteE](https://discourse.jabref.org/u/ThiloteE)\
**Post date:** [February 3, 2022, 4:38am UTC](https://discourse.jabref.org/t/citation-style-language-are-now-usable-in-latex-documents/3175/7 "2022-02-03T04:38:29Z")

</div>

Finally, some are already pondering how Zotero could be integrated. Could be relevant for JabRef integration: [Zotero integration · Issue #8 · zepinglee/citeproc-lua · GitHub](https://github.com/zepinglee/citeproc-lua/issues/8)

---

<div class="post-metadata">

**Author:** ![Siedlerchr](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/siedlerchr/32/216_2.png) [@Siedlerchr](https://discourse.jabref.org/u/Siedlerchr)\
**Post date:** [February 3, 2022, 8:36pm UTC](https://discourse.jabref.org/t/citation-style-language-are-now-usable-in-latex-documents/3175/8 "2022-02-03T20:36:25Z")

</div>

@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](https://github.com/JabRef/jabref/issues/8372#issuecomment-1023768144)

---

<div class="post-metadata">

**Author:** ![zepinglee](https://avatars.discourse-cdn.com/v4/letter/z/ebca7d/32.png) [@zepinglee](https://discourse.jabref.org/u/zepinglee)\
**Post date:** [January 6, 2023, 9:36am UTC](https://discourse.jabref.org/t/citation-style-language-are-now-usable-in-latex-documents/3175/9 "2023-01-06T09:36:49Z")

</div>

> [@ThiloteE](#):
>
> 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}`.

Yes. The `citation-style-language` package redefines several commands related to bibliography (e.g., `\cite`, `\bibitem`, and their internal commands). Other packages modifying them are very likely to cause conflicts. The `babel` in this case redefines `\bibitem` and `\bibcite` and thus crashes. Currently I’ve patched `babel`, `csquotes`, and `hyperref`.

> [@ThiloteE](#):
>
> Hyperref not working properly and Backref not working at all really is a bummer 🤨

I’ve just implemented the hyperlinks of citations and backref.
