JabRef / jabref

Graphical Java application for managing BibTeX and biblatex (.bib) databases
https://devdocs.jabref.org
MIT License
3.64k stars 2.59k forks source link

Organisations in the bibliography not in alphabetical order #11725

Open 772 opened 2 months ago

772 commented 2 months ago

JabRef version

5.15 (latest release)

Operating system

GNU / Linux

Details on version and operating system

Fedora 40

Checked with the latest development build (copy version output from About dialog)

Steps to reproduce the behaviour

  1. Set IsSortByPosition="false"
  2. Use "{Linux Foundation}" as an author.

The bibliography is broken now and not in alphabetical order. Using {}-brackets for organisations was suggested here: https://discourse.jabref.org/t/how-to-enter-corporation-name-in-author-field/2080

Appendix

grafik

Siedlerchr commented 2 months ago

@subhramit This is jstyle but as you are deeper in the topic now can you take a look please?

subhramit commented 2 months ago

@subhramit This is jstyle but as you are deeper in the topic now can you take a look please?

Yeah sure

subhramit commented 2 months ago

As it looks at first sight, the order is overridden because of the curly braces {}. JabRef already stores them in BibTeX format, which has braces around them, so when explicitly added, it becomes {{organization name}}. Instead of "o", the first character to participate in the comparator is then "{".

Solution - we will have to ignore extra braces, if explicitly present. I'll take a look at this.

Temporary workaround - do not use extra braces.

Siedlerchr commented 2 months ago

We have a RemoveEnclosingBracesFormatter that can be used

subhramit commented 2 months ago

image Weirdly enough, I can reproduce with {The Geany contributors} but not {Linux Foundation}. It is as if the issue is occurring in some special case.

772 commented 2 months ago

Luckily, I have dozens of foundations and companies in my LibreOffice document. :) I think this is the pattern:

If {}-braces are used, JabRef takes the last word within the {}-brackets and sorts it like the ASCII-table. This is why "c" from contributors is above all.

{Linux Foundation} will be sorted in a wrong order, too, if you add two authors with "F" in their last name and "Foundation" is between them.

Edit: The best workaround I found so far is to replace each " " with a rare symbol like "℗". Before finishing your document, you can simply replace all "℗" with " " in LibreOffice. grafik

koppor commented 2 months ago

Two thoughts:

ryan-carpenter commented 2 months ago

Solution - we will have to ignore extra braces, if explicitly present. I'll take a look at this.

Remember that the braces may be needed to protect the formatting of organisation names, even if the name is only one word.

ryan-carpenter commented 2 months ago

The best workaround I found so far is to replace each " " with a rare symbol like "℗". Before finishing your document, you can simply replace all "℗" with " " in LibreOffice.

Have you tried using no-break spaces in the organisation names? The~Geany~contributors should make the whole name behave as one word (and retain "The" in citation key).

Also, note that (without no-break spaces) capitalisation matters, at least in citation keys. {Linux Foundation} and {The Geany Contributors} produce "LinuxFoundation" and "GeanyContributors", respectively in the citation key, but {Linux foundation} and {The Geany foundation} produce "Linux" and "Geany". I am not sure if this affects the bibliography.

772 commented 2 months ago

Have you tried using no-break spaces in the organisation names? The~Geany~contributors should make the whole name behave as one word (and retain "The" in citation key).

Yes, it has no effect. When I use The~Geany~contributors or {The~Geany~contributors}, the sorting is always wrong. It looks like the "~" is only affecting the display in the JabRef GUI but not text in the LibreOffice document.