typst / typst/typst

Show bibliography only when there are citations in the document

Open
#2,794 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bibliography feature request
Dominant language
Rust
Stars
56.1k
Forks
1.7k
Avg merge
3d 10h
Merged PRs (30d)
22

Description

Description

It would be great to skip the printing the bibliography section if the paper’s text has no references (“citations”) to the catalogued works.

At the moment this can be achieved using locate.

  locate(loc => if bib != none and query(ref.where(element: none), loc).len() > 0 {
    bibliography(bib)
  })

It would be nice to have native support from the compiler. Or is the suggested approach the recommended one?

For more context see the discord thread. Thanks for those who provided input and the solution above.

Use Case

I am using the same template for different files, some of which I do not make any citations. However, an empty bibliography section is printed nevertheless.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing bibliography and citation handling, using the issue's locate, bibliography, and query(ref.where(...)) example as the behavioral reference. Determine how native support should detect whether citations exist, then add coverage showing that an uncited document omits the bibliography while cited documents still print it.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.