--{{0}}--
This plugin supports the use of BibTeX-based references. References can be specified directly inside a LiaScript document as a fenced code block, loaded from a remote URL, or looked up by DOI — and rendered in any of the four supported citation styles.
This LiaScript plugin uses the Citation.js implementation of L. G. Willighagen. Many thanks for his great work!
@bibliography(10.5281/zenodo.1005176)
Try it on LiaScript:
Source on GitHub:
https://github.com/LiaTemplates/citations
--{{1}}--
There are three ways to use this template. The easiest is the import statement. You can also copy the macro definitions directly into your document header, or clone and adapt the project.
{{1}}
-
Import the latest version:
import: https://raw.githubusercontent.com/LiaTemplates/citations/refs/heads/main/README.mdor a tagged version:
import: https://raw.githubusercontent.com/LiaTemplates/citations/refs/tags/0.0.6/README.md -
Copy the macro definitions from this document's header into your own project
-
Clone this repository on GitHub
Four citation styles are supported. Pass the style name as the first argument to any .style() macro variant.
| Style name | Description | Typical use |
|---|---|---|
harvard1 |
Harvard author-date (default) | Humanities, social sciences |
apa |
American Psychological Association | Psychology, education |
vancouver |
Vancouver / ICMJE numeric | Medicine, life sciences |
ieee |
IEEE numeric | Engineering, computer science |
The same DOI rendered in each style:
harvard1 (default): @bibliography.style(harvard1, 10.5281/zenodo.1005176)
apa: @bibliography.style(apa, 10.5281/zenodo.1005176)
vancouver: @bibliography.style(vancouver, 10.5281/zenodo.1005176)
ieee: @bibliography.style(ieee, 10.5281/zenodo.1005176)
| Macro | Input | Output |
|---|---|---|
@cite(...) |
DOI or inline BibTeX block | Short inline citation |
@cite.style(style, ...) |
style + DOI or BibTeX | Short inline citation in chosen style |
@bibliography(...) |
DOI or inline BibTeX block | Full bibliography entry |
@bibliography.style(style, ...) |
style + DOI or BibTeX | Full entry in chosen style |
@bibliography.link(url) |
URL to a .bib file |
Full bibliography from remote file |
@bibliography.link.style(style)(url) |
style + URL to a .bib file |
Full bibliography from remote file in chosen style |
@ref(key) |
BibTeX key from the global bibliography | Short inline citation from pre-loaded .bib |
@bibliography.global |
(no argument) | Full bibliography of all pre-loaded entries |
@bibliography.global.style(style) |
style name | Full bibliography of all pre-loaded entries in chosen style |
The @cite macro produces a compact inline reference such as (Johnson, 2019) or [1]. When a url field is present in the BibTeX, the output is wrapped in a hyperlink.
Syntax:
```bibtex @cite
@book{...}
```
```bibtex @cite.style(ieee)
@book{...}
```Live examples — all four styles:
harvard1 (default):
@book{johnson2019book,
title = {The Complete Guide to Examples},
author = {Johnson, Emily},
year = {2019},
publisher = {Academic Press},
address = {New York},
url = {https://doi.org/10.1000/conf.2021.123}
}apa:
@book{johnson2019book,
title = {The Complete Guide to Examples},
author = {Johnson, Emily},
year = {2019},
publisher = {Academic Press},
address = {New York},
url = {https://doi.org/10.1000/conf.2021.123}
}vancouver:
@book{johnson2019book,
title = {The Complete Guide to Examples},
author = {Johnson, Emily},
year = {2019},
publisher = {Academic Press},
address = {New York},
url = {https://doi.org/10.1000/conf.2021.123}
}ieee:
@book{johnson2019book,
title = {The Complete Guide to Examples},
author = {Johnson, Emily},
year = {2019},
publisher = {Academic Press},
address = {New York},
url = {https://doi.org/10.1000/conf.2021.123}
}The @bibliography macro renders a complete formatted reference. Multiple BibTeX entries in one block are all rendered. When a url field is present, the entry is wrapped in a hyperlink.
Syntax:
```bibtex @bibliography
@book{...}
```
```bibtex @bibliography.style(ieee)
@book{...}
@article{...}
```Live examples — all four styles with two entries:
harvard1 (default):
@book{johnson2019book,
title = {The Complete Guide to Examples},
author = {Johnson, Emily},
year = {2019},
publisher = {Academic Press},
address = {New York},
url = {https://doi.org/10.1000/conf.2021.123}
}
@book{texbook,
author = {Donald E. Knuth},
year = {1986},
title = {The {\TeX} Book},
publisher = {Addison-Wesley Professional}
}apa:
@book{johnson2019book,
title = {The Complete Guide to Examples},
author = {Johnson, Emily},
year = {2019},
publisher = {Academic Press},
address = {New York},
url = {https://doi.org/10.1000/conf.2021.123}
}
@book{texbook,
author = {Donald E. Knuth},
year = {1986},
title = {The {\TeX} Book},
publisher = {Addison-Wesley Professional}
}vancouver:
@book{johnson2019book,
title = {The Complete Guide to Examples},
author = {Johnson, Emily},
year = {2019},
publisher = {Academic Press},
address = {New York},
url = {https://doi.org/10.1000/conf.2021.123}
}
@book{texbook,
author = {Donald E. Knuth},
year = {1986},
title = {The {\TeX} Book},
publisher = {Addison-Wesley Professional}
}ieee:
@book{johnson2019book,
title = {The Complete Guide to Examples},
author = {Johnson, Emily},
year = {2019},
publisher = {Academic Press},
address = {New York},
url = {https://doi.org/10.1000/conf.2021.123}
}
@book{texbook,
author = {Donald E. Knuth},
year = {1986},
title = {The {\TeX} Book},
publisher = {Addison-Wesley Professional}
}The @bibliography.link macro fetches a .bib file from a URL and renders all entries as a formatted bibliography.
Syntax:
@[bibliography.link](https://example.com/refs.bib)
@[bibliography.link.style(ieee)](https://example.com/refs.bib)Live examples using the bundled bibtex.bib:
harvard1 (default):
ieee:
@bibliography.link.style(ieee)
apa:
vancouver:
@bibliography.link.style(vancouver)
Use @ref when your course pre-loads a shared .bib file via window.bibliographyLoad(url) in the @onload block. You can then cite any entry by its BibTeX key anywhere in the document.
Setup (in your course header's @onload):
@onload
window.citationStyle = "ieee" // optional: sets the default style for @ref and @bibliography.global
window.bibliographyLoad("https://raw.githubusercontent.com/LiaTemplates/citations/main/bibtex.bib")
@endUsage:
@ref(dietrich2019liascript)Live example (requires the global bibliography to be loaded):
@ref(dietrich2019liascript)
Use @bibliography.global to render all entries from the globally pre-loaded .bib file at once. It uses the same window.bibliography set by window.bibliographyLoad(url) and respects window.citationStyle for the default style.
Usage:
@bibliography.global
@bibliography.global.style(ieee)Live example (requires the global bibliography to be loaded):
@bibliography.global