retorquere / zotero-better-bibtex

Make Zotero effective for us LaTeX holdouts
https://retorque.re/zotero-better-bibtex/
MIT License
5.35k stars 288 forks source link

Support for extra field with manually edited .bib #2825

Closed paolieri closed 7 months ago

paolieri commented 7 months ago

Debug log ID

5E9RPDTE-refs-euc/6.7.173-7

What happened?

Sometimes, I need to make manual changes to the .bib files. I'd like to save these manually edited .bib in a special field; if the field is non-empty, I'd like Better BibTeX to return that field instead of generating an entry from the metadata. Is it already possible to do this with scripting?

retorquere commented 7 months ago

What had you wanted to export for 5E9RPDTE-refs-euc/6.7.173-7?

paolieri commented 7 months ago

Scripts allow .bib fields during the reference generation, right? I'd like to modify the entire final .bib string to replace it with an extra variable (if it has been set). The extra variable is my manually edited bibtex entry.

I'm not sure what this variable should be called, so 5E9RPDTE-refs-euc/6.7.173-7 didn't include it.

retorquere commented 7 months ago

It'd be a lot easier if you could post what you want the final output to look like.

paolieri commented 7 months ago

Apologies! I prepared another debug entry: DI42QWGJ-refs-euc/6.7.173-7

I have an extra field called bib:

image

I would like the output of Export Item... > Format: Better BibTeX to be the value of this field, i.e.,

@inproceedings{DBLP:conf/nips/VaswaniSPUJGKP17,
  author       = {Ashish Vaswani and
                  Noam Shazeer and
                  Niki Parmar and
                  Jakob Uszkoreit and
                  Llion Jones and
                  Aidan N. Gomez and
                  Lukasz Kaiser and
                  Illia Polosukhin},
  editor       = {Isabelle Guyon and
                  Ulrike von Luxburg and
                  Samy Bengio and
                  Hanna M. Wallach and
                  Rob Fergus and
                  S. V. N. Vishwanathan and
                  Roman Garnett},
  title        = {Attention is All you Need},
  booktitle    = {NIPS 2017},
  pages        = {5998--6008},
  year         = {2017}
}

As an alternative to using a field, a solution could be to have a .bib attachment:

image

The generated output would be the content of the attachment (if present).

retorquere commented 7 months ago

There are ways to achieve this output, but not by having BBT export the extra field in the way you showed or an attachment in this way. If you just want the output, you could either:

using standard BBT export:

and export using Better BibTeX. This entry will work in Word etc too.

manual control:

you can control everything manually, I really don't understand how that would be beneficial in your case (also note that Łukasz is replaved by Lukasz in your sample), but here goes: add the following to the extra field :

Citation Key: DBLP:conf/nips/VaswaniSPUJGKP17
tex.author: Ashish Vaswani and Noam Shazeer and Niki Parmar and Jakob Uszkoreit and Llion Jones and Aidan N. Gomez and Lukasz Kaiser and Illia Polosukhin
tex.editor: Isabelle Guyon and Ulrike von Luxburg and Samy Bengio and Hanna M. Wallach and Rob Fergus and S. V. N. Vishwanathan and Roman Garnett
tex.title: Attention is All you Need,
tex.booktitle: NIPS 2017,
tex.pages: 5998--6008
tex.year: 2017

or any combination of these methods.

paolieri commented 7 months ago

Thank you!

I was suggesting a single input (either in the metadata or as an attachment) because I already have the final .bib that I would like to use. With either standard BBT export or "manual control", I would have to edit multiple fields to match the .bib that I have.

As a workaround, I've found that I can: