How can I get the title of a book I cite?

Hello! I was writing a personal journal and I wanted to sometimes cite a certain document by its title (I have my bibliography in a hayagrvia YAML file) instead of the normal chicago style I use.
I think this is an interesting way of using a single source of truth to get metadata of a work into documents, e.g. the year of publication, authors or whatever you want.

However, after inspecting the ref and cite elements I haven’t figured out if that’s even possible to do. Has someone done this? Or knows how to do it?

1 Like

Hello @aberges,

Welcome to the forum. I suggest you have a look at How do I use a Hayagriva .yaml bibliography file with a Typst .typ document? first and perhaps come back with an example of what you would like if you can’t find your answer?

I would also have a look at pergamon – Typst Universe as it offers some flexibility.

Thank you for the previous suggestions. I think I need to clarify exactly what output I am aiming for, as I might have used the wrong terminology.

I have a bib.yaml entry like this:

harrypotter:
  title: Harry Potter and the Philosopher's Stone
  author: J.K.Rowling
  year: 1997

In my document, I am using the chicago-author-date style. When I write:

bla bla bla @harrypotter bla

It currently renders the standard citation format:

bla bla bla (Rowling, 1997) bla

However, my goal is to have the citation render the title of the work directly in the text, like this:

bla bla bla Harry Potter and the Philosopher’s Stone bla

Essentially, I want to “extract” the title field from the bibliography entry to use it as a noun in the sentence itself, rather than having Typst generate the parenthetical citation. Is there a way to access the title property of @harrypotter directly? Note that this is only for entries I choose to render this way, otherwise the citation should work as it is.

1 Like

No it doesn’t, it throws an error because type field is missing.

#let bib = ```yaml
harrypotter:
  title: Harry Potter and the Philosopher's Stone
  author: J.K.Rowling
  year: 1997
```.text

#bibliography(bytes(bib))

Moreover, year is not a non-existing field, and it will not render as “1997”, but as “n.d.”, because date is empty.

#set bibliography(style: "chicago-author-date")

#let bib = ```yaml
other:
  type: article
  author: Author
  title: Title
  date: 1970
harrypotter:
  type: book
  title: Harry Potter and the Philosopher's Stone
  author: J.K.Rowling
  date: 1997
```.text

#let cite-title(key) = {
  if type(key) == label { key = str(key) }
  yaml(bytes(bib)).at(key).title
  // For smart quotes.
  // eval(mode: "markup", yaml(bytes(bib)).at(key).title)
}

Lorem ipsum dolor @other sit amet, qui minim labore adipisicing
#cite-title(<harrypotter>) minim sint cillum sint consectetur cupidatat.

#bibliography(bytes(bib))

2 Likes

Typst uses Hayagriva for the bibliography which internally uses CSL. The documentation cite explains that it is possible to define a custom style just for the citation with style. The following solution uses a custom in-text CSL style to only display the title:

#let my-csl = bytes(```
<!-- put this into a .csl file -->
<?xml version="1.0" encoding="UTF-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" version="1.0" class="in-text">
  <info>
    <id>d1a68c61-1da2-415a-b5a2-1a825824f899</id>
    <title>Title Only</title>
    <updated>2026-04-20T13:55:00+00:00</updated>
  </info>
  <citation>
    <layout>
      <text variable="title"/>
    </layout>
  </citation>
</style>
```.text)

#let my-bib = bytes(```
# your .bib file
harrypotter:
    type: Book
    title: Harry Potter and the Philosopher's Stone
    author: Rowling, J.K.
    date: 1997
```.text)

// default
@harrypotter

// custom
#cite(<harrypotter>, style: my-csl)

// or like this
#let cite-title = cite.with(style: my-csl)
#cite-title(<harrypotter>)

#bibliography(my-bib, style: "chicago-author-date")

3 Likes