Can I use variables in .bib?

Hello @Ariel and welcome!
I moved your post to the Questions category :smiley:. Please edit your topic’s title to be a question, and add relevant tags.

Two things for bib variables:

  • You need to escape the delimiters, e.g., `, (or any other for that matter, as long as you change your detection in Typst
  • You can use eval

image

test.bib

@article{Test2025,
  author = {Author},
  title = {\$Area(x^2+y^2<1)=pi\$},
  year = 2025, 
}

test.typ

Notice I scope the show rule to avoid it causing issues elsewhere.

@Test2025
#let Area = "Area"
#{
    show regex(`\$(.*)\.text): it => {
      eval(it.text.slice(1, -1), mode: "math", scope: (
        Area: $Area$,
      ))
    }
    bibliography("test.bib")
}