I have a template which I need to use different code to achieve the same behaviour in different versions
here my bib file
@article{test2024,
title = {Recent Advances in Something Important},
author = {Test, John A. and Example, Jane B.},
journal = {Journal of Important Things},
year = {2024},
volume = {42},
number = {1},
pages = {123--145},
publisher = {Academic Publishers}
}
@book{test1999,
title = {Classic Book on Important Topics},
author = {Test, Robert C.},
year = {1999},
publisher = {Classic Publishing House},
address = {New York},
edition = {2nd}
}
Code that should work
#let spacing = 0.65em
#set page(
paper: "a4",
margin: (x: 2.5cm, y: 2.5cm),
)
#set heading(numbering: "1.")
// Bibliography settings
#set bibliography(
title: "References",
style: "ieee",
)
// Configure bibliography spacing based on Typst version
#if sys.version >= version(0, 12, 0) {
show bibliography: set par(spacing: spacing, leading: spacing)
} else {
show bibliography: set block(spacing: spacing)
}
= Introduction
This is a sample document demonstrating bibliography settings in Typst. Here's a citation to a something @test2024 and another reference @test1999.
Some more text here to show the spacing...
= Conclusion
The bibliography will appear below with custom spacing and styling.
// Define bibliography data in YAML format
#bibliography("bibliography.bib")
but it work only if I apply it directly outside of #if - is this issue of scope of #if
?
#show bibliography: set par(spacing: spacing, leading: spacing)
I was able to solve similar problem with using if clause options, but I am not so sure anymore :(
// Set space between paragraphs
if sys.version >= version(0,12,0) {
set par(spacing: spacing)
} else {
show par: set block(spacing: spacing)
}