Code Monkey home page Code Monkey logo

multi-bibs's Introduction

Multi-bibs

A typst library to make multiple bibliographies in a single document.

DISCLAIMER : rudimentary, but functional!

Plugin

//! 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).

Docs

//! Function signatures :
// manual citation function
#mcitation(references: array<string>, biblio: dict)

// manual bibliography function
#mbibliography(biblio: dict)

Usage

  1. Make a new CHAPTER_X/ directory.
  2. Add mod.typ and bibliography_X.yml to CHAPTER_X/.
  3. Add CHAPTER_X/ to the the convert.sh script and run it to instance an empty bibliography. This generates a bib_CHAPTER_X.typ file in CHAPTER_X/.
  4. Work on the manuscript, use the #mcitation() function to cite your references.
    • Run the convert.sh to refresh the bibliography when adding new references.
  5. Add the #mbibliography(biblio) function at the very end of the chapter, preferably in mod.typ.
# Usage of parsetyp.py
$ cd rootdirectory/chapters/
$ python3 parsetyp.py CHAPTER_X/

Restrictions!

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

Filestructure example

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/

TODO

  • 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, not 1,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

multi-bibs's People

Contributors

jrihon avatar

Stargazers

Y. Xu avatar  avatar AYOUB EL MHAMDI avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.