| Crates.io | mdbook-bib |
| lib.rs | mdbook-bib |
| version | 0.5.2 |
| created_at | 2021-02-10 02:39:16.502229+00 |
| updated_at | 2026-01-20 20:17:43.58334+00 |
| description | mdbook plugin allowing to load and present a bibliography in BibLaTex format in your books and cite its references |
| homepage | |
| repository | https://github.com/francisco-perez-sorrosal/mdbook-bib |
| max_upload_size | |
| id | 353011 |
| size | 439,119 |
A mdBook plugin for creating a bibliography & citations in your books.
Create an example mdbook:
cargo install mdbook mdbook-bib
mdbook init mybook && cd mybook
Add mdbook-bib config to book.toml:
[preprocessor.bib]
bibliography = "refs.bib"
Create example bibliography src/refs.bib:
@article{hello,
author = {World, Hello},
title = {My First Citation},
year = {2024}
}
Cite in src/chapter_1.md:
As shown in @@hello, citations are easy!
Build book: mdbook build
Serve the book: mdbook serve
Then open http://localhost:3000 in your browser to view your book.
If you have mdbook installed just do:
cargo install mdbook-bib
Make sure your PATH env var contains Cargo's /bin directory where the plugin was installed. Then follow the instructions below to use the plugin.
See all options in the Install section of the manual.
Add a bibliography file in BibTeX/BibLaTeX or YAML format to your mdbook's src/ directory and configure in book.toml:
[preprocessor.bib]
bibliography = "my_biblio.bib"
Now you can cite entries using either syntax:
{{#cite my-citation-key}}
@@my-citation-key
Enable Pandoc citation syntax for cross-tool workflows:
[preprocessor.bib]
...
citation-syntax = "pandoc"
Then use standard Pandoc citations:
@key # Author-in-text: "Smith (2024)"
[@key] # Parenthetical: "(Smith, 2024)"
[-@key] # Suppress author: "(2024)"
This lets you use the same source files with both mdBook (HTML) and Pandoc (PDF).
mdbook-bib provides two rendering backends:
Choose Custom for custom layouts or interactive elements. Choose CSL for standard academic formatting with minimal setup.
The default backend uses Handlebars templates for full customization:
[preprocessor.bib]
bibliography = "my_biblio.bib"
# Optional: custom templates
hb-tpl = "render/references.hbs"
cite-hb-tpl = "render/citation.hbs"
css = "render/style.css"
See Custom Backend documentation for template variables and examples.
For standard academic citation styles, enable the CSL backend:
[preprocessor.bib]
bibliography = "my_biblio.bib"
backend = "csl"
csl-style = "ieee" # or: chicago-author-date, nature, apa, mla, harvard, ...
See CSL Backend documentation for available styles and examples.
See the manual for all configuration options.
Tip: Debug builds with MDBOOK_LOG=mdbook_bib=debug mdbook build.
Check the Contrib section of the manual if you want to contribute to mdbook-bib!