jabref icon indicating copy to clipboard operation
jabref copied to clipboard

Openoffice / Libreoffice bibliography order

Open antalk2 opened this issue 5 years ago • 12 comments

JabRef version JabRef 5.3--2021-05-24--59fb185

  • [x] Mandatory: I have tested the latest development version from http://builds.jabref.org/main and the problem persists

  • Create Smith2x.bib with two entries with (author year title)

    • Smith 2000 Alpha
    • Smith 2000 Beta
  • Start a new document

  • Cite each above, individually, in reverse order.

  • Choose Default Author-year style

  • Refresh (generate bibliography)

Both statements below are true

  • The bibliography is sorted in (author, year, title) order
  • The letters (in 2000a, 2000b, 2000c) are assigned in order of appearance

The problem: now 2000b precedes 2000a in the bibliography.

Probably the bibliography should use (author, year, uniqueLetter, title) order

antalk2 avatar Jun 07 '21 17:06 antalk2

Hello, I would like to work on this issue. Any pointers would be appreciated. Thanks in advance.

gdrosos avatar Jun 19 '21 17:06 gdrosos

Uhh.

  • I put this bug report here as a reminder. The main reason for not solving it right away is that the code is in transition. I reorganized the part handling bibliography and citation mark generation here. Due to the amount of changes had to break it into smaller parts for review: https://github.com/JabRef/jabref/pulls?q=is%3Apr+is%3Aopen+oobranch It was estimated by a maintainer to take at least six weeks to finish the review. (Currently we are at "c" in an "a" to "j" series) In case my version becomes accepted, the change I proposed "use (author, year, uniqueLetter, title) order" seems relatively straightforward: I would probably start here

  • Another reason for the report was: I am not sure what is the expected solution: is what I proposed a universally accepted answer for this case, or maybe something else, or it varies between journals and needs an option in jstyle files. I was hoping someone can add this missing knowledge here.

  • I was just writing a summary of (what did I change, why) here, under The OpenOffice/LibreOffice panel, at the bottom, when I discovered this problem. I also mention some other problems there.

I would suggest to wait with work on the parts affected by the oobranch series. The old code may be gone later, or the new code may be refused or affected by changes requested during review. I am also waiting. In the meantime I started to investigate what is achievable in LibreOffice on the backend part.

antalk2 avatar Jun 20 '21 12:06 antalk2

Could you please try the latest Jabref development-build and check if the issue here still is reproducible? It can be found here: https://builds.jabref.org/main/

In the newest build, the final pull request https://github.com/JabRef/jabref/pull/7795, mainly authored by @antalk2, was merged. There were some changes related to the Open Office (OO) and Libre Office (LO) integration, so just checking if some of the issues to LO/OO are still open or can be put to rest.

(I guess i will check if this bug is reproducible, since Antalk2 is not really active right now.)

ThiloteE avatar Mar 12 '22 17:03 ThiloteE

I can confirm that this problem here still exists. with

JabRef 5.6--2022-03-10--749b6b2 Windows 10 10.0 amd64 Java 17.0.2 JavaFX 17.0.2-ea+3

Short story:

  • I think it is less about the sorting, but more about "The letters (in 2000a, 2000b, 2000c) are assigned in order of appearance".
  • The current sorting method seems to be based on the citation key exported by JabRef

Long story:

Instead of using the citation key exported by JabRef, OpenOffice/LibreOffice (or JabRef?!) uses yet another method to prevent duplicate entries/citations (which is fine, because users usually desire to not print an arbitrary citation key, but rather print bibliographic data, which is formatted and rendered according to the syntax of the citation style). This other method to prevent duplicates results in adding another letter (a, b, c, ...) to the date or year (which may or may not adhere to the specific citation style chose by the user) and thus creates new entry data on top of the citation key. This new entry data will be shown to the user in the OO/LO document both in citations, in-text citations and the bibliography. The sorting however seems to be based on the real citation key, not on this new data.

image

Ideally the bibliographic order in LO/OO should

  • either be based on the new entry data (formatted according to the citation style) and therefore not sorted based on the citation key, but rather sorted according to the citation style --> better option
  • or the new entry data should reflect JabRef's main duplicate prevention method. Currently JabRef prevents duplicates via modification to the citation key. Since it is not desired for the citation key to be printed, new options to add values to entry fields (e.g. author, year, ...) might be needed here. (This solution requires the user to check if the chosen method of duplicate prevention is compatible with the chosen citation style. It also requires for JabRef developers to implement a multitude of duplication prevention mechanisms) --> bad option
  • ...

ThiloteE avatar Mar 13 '22 23:03 ThiloteE

@antalk2 @ThiloteE Does this problem still exist in the latest dev branch? I cannot reproduce it accoding to the steps above

pluto-han avatar Mar 18 '26 17:03 pluto-han

Does this problem still exist in the latest dev branch?

Tested with: https://builds.jabref.org/main/linux-amd64/JabRef-portable_linux.tar.gz

In short: yes. (Assuming that the link above is the dev branch). Choosing JStyles / Author-year, inserting as in the original report reproduces the "2000b followed by 2000a" problem in References.

I am not up-to-date with the CSL styles implementation, please correct me if I am mistaken.

It seems, that the currently selected style being a CSL style or a JStyle decides the format of the entry that is visible in the LibreOffice Writer "Navigator" panel under "References".

CSL and JStyle handling is "disconnected": Depending on the current style either only CSL-style references, or only JStyle references are recognized. Only those recognized are updated in the text and used in the References section.

Using a CSL style (APA Style 7th edition (no initials)) does not reproduce the "2000b followed by 2000a" problem. Instead, it produces "(Smith, 2000) and (Smith, 2000)" in the text, resulting in indistinguishable parenthesized citations for different sources. A different, but wrong answer to the same problem.

Attachments:

smith.bib.txt The .bib file (with .txt extension added to be able to upload).

document.odt Test document. (After document-v3.pdf)

document-v1.pdf Step 1: cited two references, switched to JStyles / Author-year. Failed to update citations in the text and to use them in "References"

document-v2.pdf Step 2: inserted the same references again, under the JStyle selected. Reproduced the original problem.

document-v3.pdf Step 3: switched to a CSL style. (APA Style 7th edition (no initials)). Update refreshed the CSL-style citations in the text (not the JStyle ones). The two refreshed citations in the text are not distinguishable, both are "(Smith, 2000)", despite corresponding to different sources.

antalk2 avatar Mar 18 '26 19:03 antalk2

@subhramit You have some more insights right now

Siedlerchr avatar Mar 18 '26 19:03 Siedlerchr

@antalk2 Thank you for the detailed information!

Using a CSL style (APA Style 7th edition (no initials)) does not reproduce the "2000b followed by 2000a" problem. Instead, it produces "(Smith, 2000) and (Smith, 2000)" in the text, resulting in indistinguishable parenthesized citations for different sources. A different, but wrong answer to the same problem.

Yes, I was using CSL style to reproduce the issue and also encoutered "(Smith, 2000) and (Smith, 2000)" problem, which explained why I could not reproduce it. Using JStyle does reproduce the original problem.

CSL and JStyle handling is "disconnected": Depending on the current style either only CSL-style references, or only JStyle references are recognized. Only those recognized are updated in the text and used in the References section.

JabRef currently does not support auto-transform from JStyle foramt to CSL format and back (@subhramit pls correct me if I am mistaken). One must re-cite all entries again with the new style, then refresh the bibliography.


A possible workaround (From the community) is to introduce a unified format for all style types, together with a parser and rederer. Thus CSL and JStyle can switch seamlessly. Based on the new foramt, we can also optimise bibliography order processing logic.

pluto-han avatar Mar 18 '26 22:03 pluto-han

A kind of workaround is to use the jabref libre office converter extension (it's a separate repo). That can convert this by making it plaintext.

Csl is rendered individually for each entry, not sure how we handle this disambiguation

Siedlerchr avatar Mar 18 '26 23:03 Siedlerchr

A little dig in the code:

For CSL:

CSL is rendered individually for each entry as https://github.com/JabRef/jabref/issues/7805#issuecomment-4086165393 said. It calls citation generation methods directly using the passed-in entries without checking existing citations in the document, which causes duplication of "(Smith, 2000)". https://github.com/JabRef/jabref/blob/18f1d8cc07bd842793a4e1078f75a4a746c856c0/jablib/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java#L95-L99

For JStyle:

Letters are assigned in order of appearance, but the bibliography order is determined by Author-Year-Title sorting. -> cause the problem in this issue https://github.com/JabRef/jabref/blob/18f1d8cc07bd842793a4e1078f75a4a746c856c0/jablib/src/main/java/org/jabref/logic/openoffice/style/OOProcessAuthorYearMarkers.java#L126-L130

pluto-han avatar Mar 19 '26 01:03 pluto-han

JabRef currently does not support auto-transform from JStyle foramt to CSL format and back (@subhramit pls correct me if I am mistaken). One must re-cite all entries again with the new style, then refresh the bibliography.

Correct

subhramit avatar Mar 19 '26 06:03 subhramit

resulting in indistinguishable parenthesized citations for different sources. A different, but wrong answer to the same problem.

There is a small caveat to this statement - objectively as JabRef "citations", they are distinguishable, albeit internally, because of their citation keys differing (smith2000:alpha vs smith2000:beta) (and thus their reference marks differing). Hence, we are able to produce distinct bibliographic entries:

Image

Your analysis of the code is correct - and yes, theoretically, CSL should indeed distinguish between them when inserting citations. we, however, don't get that out-of-the-box via the library we are using. Given that we have a way to both identify their similarity (same author, year) and difference (different title/reference mark), a quick solution would be to use a map when parsing existing references in the document (or while citing) to check for occurrences of the same (author, year) pair and then render them differently based on their citation key - which will always be unique.

subhramit avatar Mar 19 '26 06:03 subhramit