typst / hayagriva

Rusty bibliography management.
Apache License 2.0
320 stars 48 forks source link

APA style does not format correctly with more than two authors (with same year in publications) #199

Open bpkleer opened 1 month ago

bpkleer commented 1 month ago

Description

I'm just new to typst and wanted to use it for a conference paper and stumbled upon an error with the APA style in the citatoion. It is quite common to have the same authors publishing more than one work, therefore, APA style indicates same authors same year with enumerations like Müller et al. (2001a) and Müller et al. (2001b).

This worked fine for me, if there were only two authors, as soon as I added a third author the citation was incorrect. I tested the problem locally (in the webapp it also showed the same bug). An example for reproduction is available on the link.

This is the underlying simple bib-file:

@Article{Citation1,
  author       = {Momo Müller and Sascha Schmidt},
  journaltitle = {Testjournal},
  number       = {1},
  title        = {Testtitle 1},
  pages        = {217--234},
  volume       = {4},
  year         = {2001},
}

@Article{Citation2,
  author       = {Müller, Momo and Schmidt, Sascha},
  journaltitle = {Testjournal},
  title        = {Testtitle 1},
  number       = {1},
  pages        = {217--234},
  volume       = {4},
  year         = {2001},
}

@Article{Citation3,
  author       = {Müller, Momo and Schmidt, Sascha and Pfeffer, Philipp},
  journaltitle = {Testjournal},
  title        = {Testtitle 1},
  number       = {1},
  pages        = {217--234},
  volume       = {4},
  year         = {2001},
}

@Article{Citation4,
  author       = {Müller, Momo and Schmidt, Sascha and Pfeffer, Philipp},
  journaltitle = {Testjournal},
  title        = {Testtitle 1},
  number       = {1},
  pages        = {217--234},
  volume       = {4},
  year         = {2001},
}

According to APA style, two entries with the same authors and year should be enumerated with a, b, etc. If the entry has two authors it works well, if there are three or more it doesn't work.

Two authors case

`@Citation1` => @Citation1

`@Citation2` => @Citation2

This leads correctly to the following format: Captura de Tela 2024-08-07 às 12 55 47

Three authors case

However, if the entry has three (examples @Citation3 and @Citation4) or more authors, the reference shows weird behavior:

`@Citation3` => @Citation4

`@Citation3` => @Citation4

The shown references uses firstnames and from the last author only lastname and does not enumerated the year with 'a'/'b': Captura de Tela 2024-08-07 às 12 56 50

Changing one of the years, the correct format is shown: Captura de Tela 2024-08-07 às 12 58 20

I reproduced the bug also with the #cite() function, which can be assessed in the reprodcution URL.

Since it is quite common having the same

Reproduction URL

https://typst.app/project/wKSJe04nF_coz5Mbd7jjsK

Operating system

No response

Typst version

Enivex commented 1 month ago

This should probably be in the Hayagriva repository

@PgBiel

PgBiel commented 1 month ago

Seems to be related to failing disambiguate_AndreaEg3^1, disambiguate_AndreaEg5^2 and disambiguate_FailWithYearSuffix^3 CSL processor tests:

Test target/haya-cache/test-suite/processor-tests/humans/disambiguate_AndreaEg3.txt failed
Expected:
Smith, Brown & J. Jones (1980a); Smith, Brown & J. Jones (1980b)
Smith, Brown & J. Jones (1980a); Smith, Benson, et al. (1980)
Smith, Brown & J. Jones (1980a); Smith, Brown & A. Jones (1980)

Got:
John Smith, John Brown & Jones (1980); John Smith, John Brown & Jones (1980)
John Smith, John Brown & Jones (1980); John Smith, Benson, et al. (1980)
John Smith, John Brown & Jones (1980); John Smith, John Brown & Jones (1980)

[... other tests omitted ...]

Test target/haya-cache/test-suite/processor-tests/humans/disambiguate_AndreaEg5.txt failed
Expected:
Smith, Brown & J. Jones (1980a); Smith, Brown & J. Jones (1980b)
Smith, Brown & J. Jones (1980a); Smith, Benson, et al. (1980)
Smith, Brown & J. Jones (1980a); Smith, Brown & A. Jones (1980)

Got:
John Smith, John Brown & Jones (1980); John Smith, John Brown & Jones (1980)
John Smith, John Brown & Jones (1980); John Smith, Benson, et al. (1980)
John Smith, John Brown & Jones (1980); John Smith, John Brown & Jones (1980)

[... other tests omitted ...]

Test target/haya-cache/test-suite/processor-tests/humans/disambiguate_FailWithYearSuffix.txt failed
Expected:
(Caritas Europa et al. 2004a)
(Caritas Europa et al. 2004b)

Got:
(Caritas Europa, CCME, COMECE, ICMC, et al. 2004)
(Caritas Europa, CCME, COMECE, ICMC, et al. 2004)