wshanks / lyz

LyZ is a plugin for Zotero, which is intended to make working with LyX/Zotero more pleasant.
GNU General Public License v3.0
108 stars 13 forks source link

BibTeX keys do not match Zotero default format #9

Closed huldash closed 5 years ago

huldash commented 10 years ago

Hi,

I am using Lyz with an existing BibTeX database generated by exporting my Zotero library to BibTeX. I changed the Lyz setting for the BibTeX keys to author title year to match the Zotero default format and avoid duplicates in my bibliography. The problem is that Lyz includes the first two words in the title part of the key while Zotero only includes one word. So Zotero would write the key in your example as "tichy_foundations_1988", not "tichy_thefoundations_1988". Is there a way to make Lyz print the keys exactly like Zotero does?

Thank you, Hulda

wshanks commented 10 years ago

I believe that it is not possible at the moment. It would be good to have. Let me verify what you want. Are you selecting some number of items or a collection in Zotero, right-clicking and choosing "Export selected items/collection" and then choosing the BibTeX format? And using the author_title_year format in LyZ would match the cite keys generated by Zotero if the title were a single word?

If so, then Zotero's BibTeX translator will need to compared with the createCiteKey() function in chrome/content/lyz/lyz.js for differences. I guess the simplest solution might be to make a new keyword for LyZ that just generates the Zotero cite key. A new Zotero title keyword could also be created (I don't want to change the current title keyword to maintain backwards compatibility), but the author keyword would also need to be checked for corner cases where LyZ and Zotero differ.

Looking at the LyZ function, it looks like it uses two words when the first word is short. Do the cite keys for items with long first words agree with Zotero for you?

Just checking -- I have a backlog of enhancements that I want to implement for my Zotero add-ons. How much would it help you out to have a quick fix for this issue?

huldash commented 10 years ago

You have understood the problem correctly. The cite keys do match for items with long first words in the title. However, I discovered another mismatch since yesterday. Zotero replaces missing information in the cite key with four question marks ("tichyfoundations????") while Lyz leaves the field empty ("tichythefoundations").

I am currently only using Lyz for the convenience of the "Cite in Lyx" command. I will just stop using it and cite the conventional way in Lyx until you get around to this issue. Please let me know when you do.

Thanks, Hulda

bewantbe commented 5 years ago

It seems that there is a simpler solution.

Lyz plugin actually got a full (vanilla) BibTex item from Zotero BibTeX translator (id=9cb70025-a888-4a29-a210-93ec52da40d4) which should be the same as the (written) bibtex file https://github.com/willsALMANJ/lyz/blob/6330629181dfb923022eb9fd063585a7703b3674/addon/chrome/content/lyz/lyz.js#L786

Then the author year and title are parsed in https://github.com/willsALMANJ/lyz/blob/6330629181dfb923022eb9fd063585a7703b3674/addon/chrome/content/lyz/lyz.js#L902

Instead of trying to match the Zotero BibTeX translator, we can directly use the key in the original BibTex item. https://github.com/willsALMANJ/lyz/blob/6330629181dfb923022eb9fd063585a7703b3674/addon/chrome/content/lyz/lyz.js#L908

See the pull request (https://github.com/willsALMANJ/lyz/pull/28) for details.

wshanks commented 5 years ago

Closing in favor of #29. Unfortunate it took four years to realize that this feature already existed.