A typst library to make multiple bibliographies in a single document.
DISCLAIMER : rudimentary, but functional!
//! rootdirectory/chapters/01_chapter/mod.typ
#import "../../lib/multi-bibs.typ": *
#import "bib_01_chapter.typ": biblio
#include "introduction.typ"
// At the end of the chapter, call the bibliography
#mbibliography(biblio)
//! rootdirectory/chapters/01_chapter/introduction.typ
#import "../../lib/multi-bibs.typ": *
#import "bib_01_chapter.typ": biblio
= Introduction
This is the start of the manuscript.
I am writing a sentence here and here follows a citation #mcitation(("foo2023bar"), biblio).
The second sentence includes another citation #mcitation(("qoo1973qux"), biblio).
//! Function signatures :
// manual citation function
#mcitation(references: array<string>, biblio: dict)
// manual bibliography function
#mbibliography(biblio: dict)
- Make a new
CHAPTER_X/
directory. - Add
mod.typ
andbibliography_X.yml
toCHAPTER_X/
. - Add
CHAPTER_X/
to the theconvert.sh
script and run it to instance an empty bibliography. This generates abib_CHAPTER_X.typ
file inCHAPTER_X/
. - Work on the manuscript, use the
#mcitation()
function to cite your references.- Run the
convert.sh
to refresh the bibliography when adding new references.
- Run the
- Add the
#mbibliography(biblio)
function at the very end of the chapter, preferably inmod.typ
.
# Usage of parsetyp.py
$ cd rootdirectory/chapters/
$ python3 parsetyp.py CHAPTER_X/
There are several rigids parts of the manuscript :
CHAPTER_X
directory names are unique!bibliography_X.yml
file names are unique! Or else, unique links to the correct bibliography can become ambiguous.
The file structure needs to be respected. Relative imports in typst are still not finetuned and this can make for unrecognised imports of the following structure is not followed :
rootdirectory/
- chapters/
- CHAPTER_X/
mod.typ, bibliography_X.yml
- CHAPTER_Y/
mod.typ, bibliography_Y.yml
- lib/
multi-bibs.typ
rootdirectory/
- chapters/
parsetyp.py # parses mod.typ for data !
convert.sh # convert foo.bib to foo.yml; hayagriva dependency !
- 00_title/
- 01_chapter/
mod.typ # mandatory file per chapter!
bib_01_chapter.typ # generated by parsetyp.py
introduction.typ
methods.typ
results.typ
discussion.typ
01_chapter.yml # bibliography.yml !
- 02_chapter/
...
- 03_chapter/
...
- lib/
multi-bibs.typ # source of the lib !
- output/
main_test.pdf
- src/
fonts/
- Wait until we can implement our own element functions in
Typst
so we can ditch the python script - Implement citations where consecutive numbering goes
1-4
, not1,2,3,4
- Figure out how to make variables more global to avoid pesky import calls in every file?
- Pathing in the generated
biblio.bibyml
is somewhat hardcoded and hopefully I can change this later - Allow less strict requirements for the structuring of the filesystem in the project