typst / typst

A new markup-based typesetting system that is powerful and easy to learn.
https://typst.app
Apache License 2.0
32.79k stars 880 forks source link

Missing volume in american-physics-society citation #2643

Closed mpmdean closed 10 months ago

mpmdean commented 10 months ago

Description

Citing using the american-physics-society style appears to have a bug that the volume={47}, field does not appear.

main.typ is

Citing a paper such as @Einstein1935can does not show the volume field.

#bibliography("refs.bib",
style: "american-physics-society")

ref.bib is

@article{Einstein1935can,
  title={Can Quantum-Mechanical Description of Physical Reality Be Considered Complete?},
  author={Einstein, A. and Podolsky, B. and Rosen, N.},
  journal={Phys. Rev.},
  volume={47},
  pages={777--780},
  year={1935},
  doi={10.1103/PhysRev.47.777}
}

This produces a document with a missing volume field. I reproduced this in the typst.app and in a fresh brew install on my mac locally.

Screenshot 2023-11-10 at 2 23 25 PM

Reproduction URL

No response

Operating system

No response

Typst version

mpmdean commented 10 months ago

Having checked this a bit more, it seems to be a bigger issue. It appears that typst never seems to include the volume even in the most standard test I can devise.

If I download basic.yml from https://github.com/typst/hayagriva/tree/main/tests/data

and produce a bibliography as below. It also misses the volume. I would say that the #bibliography function has a bug that will stop it from being useful for pretty much all scientific users?

I really like typst, and appreciate the work done on it to date, so I hope this can be addressed

@kinetics

#bibliography("basic.yml")

Screenshot 2023-11-14 at 7 16 32 PM

zepinglee commented 10 months ago

It seems that the volume is stored in the article's parent but hayagriva retrieves directly from the entry and gets none.

https://github.com/typst/hayagriva/blob/062e5fdd02616e5d49ab7b1b81bb4893bf4e0dda/src/csl/taxonomy.rs#L194

            NumberVariable::Volume => self.volume().map(MaybeTyped::to_cow),

If I change this line to the following code and the volume is printed out as expected.

            NumberVariable::Volume => self
                .get_container()
                .and_then(|e| e.volume())
                .map(MaybeTyped::to_cow),
$ cargo run --features=cli -- test.bib cite --csl american-physics-society.csl
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/hayagriva test.bib cite --csl american-physics-society.csl`
[1]
A. Einstein, B. Podolsky, and N. Rosen, Can Quantum-Mechanical Description of Physical Reality Be Considered Complete?, Phys. Rev. 47, 777 (1935)
mpmdean commented 10 months ago

Thanks a lot @zepinglee !

This looks like a quite simple, but very valuable thing to get fixed soon.

mpmdean commented 10 months ago

I believe this was solved here.