helm-bibtex icon indicating copy to clipboard operation
helm-bibtex copied to clipboard

insert reference + biblatex

Open jmburgos opened this issue 6 years ago • 6 comments

Hi Titus, I have a (hopefully) small request. When using the "Insert reference" option, I do not get the journal title. For example, from this entry

@article{Adamczyk2013,
  author       = {Adamczyk, Joanna},
  journaltitle = {Ecological Questions},
  pages	       = {9--23},
  title	       = {The Effect of Scaling Methods on the Calculation of Environmental Indices},
  volume       = 17,
  year	       = 2013,
}

I get this reference:

- Adamczyk, J. (2013). The effect of scaling methods on the calculation of environmental
  indices. , 17(), 9–23.

I think this is because my bib file is in biblatex format, and therefore the label for the field with the journal name is "journaltitle". The same information is in the "journal" field in a bibtex file.

Would it be possible to tell helm-bibtex to use the "journaltitle" field if the "journal" field is not there?

Many thanks,

Julian

jmburgos avatar Dec 12 '17 10:12 jmburgos

Hm, any idea why biblatex is using a different field for this? We added a fix for the date field which biblatex uses instead of year, but the code for this is littered all over the place. Not great. I'm afraid we need a more general solution for dealing with bibtex-biblatex inconsistencies. In the meantime you could perhaps switch back to using journal?

tmalsburg avatar Dec 13 '17 11:12 tmalsburg

I do not know why the field has a different name. I learned that biblatex keeps "journal" as an alias for "journaltitle", precisely for compatibility with bibtex. But emac's bibtex mode (which I use to keep my bib file) complains if you use journal instead of journaltitle. I rather not change field names in my very large file, in any case. So do not worry about this issue if the fix is messy. It is only a minor annoyance.

jmburgos avatar Dec 18 '17 10:12 jmburgos

We added a fix for the date field which biblatex uses instead of year, but the code for this is littered all over the place.

My own workaround looks something like this:

(defun annobib-apa-format-reference (key)
  "Adapted from `bibtex-completion-apa-format-reference`.

Returns a plain text reference in APA format for the
publication specified by KEY."
  (let*
      ((entry (bibtex-completion-get-entry key))
       (ref (pcase (downcase (bibtex-completion-get-value "=type=" entry)))))
    ;; APA Citation Format
    ("article"
     (s-format
      "${author} (${date}). ${title}. ${journaltitle}, ${volume}(${number}), ${pages}.${doi}"
      'bibtex-completion-apa-get-value entry))
    (_
     (s-format
      "${author} (${year}). ${title}."
      'bibtex-completion-apa-get-value entry))
    
(setq ref (replace-regexp-in-string "\\([.?!]\\)\\." "\\1" ref)); Avoid sequences of punctuation marks.
(setq ref (replace-regexp-in-string "[{}]" "" ref)) ;; Remove braces.
))

Note that all year field indicators must also be changed to date, presently with no option to choose the year part from the date-string (as far as I know, but I might be wrong).

Another issue is this: for the thesis reference type, BibTeX uses phdthesis and mastersthesis to differentiate between the two, while BibLaTeX just makes do with thesis with phd and ma indicated in the type field.

Can there be a separate biblatex-completion for biblatex users? Or some other way to make citing with biblatex more user-friendly?

sati-bodhi avatar Oct 23 '20 06:10 sati-bodhi

Another issue is this: for the thesis reference type, BibTeX uses phdthesis and mastersthesis to differentiate between the two, while BibLaTeX just makes do with thesis with phd and ma indicated in the type field.

I don't understand what the issue is specifically. Could you please elaborate?

Can there be a separate biblatex-completion for biblatex users? Or some other way to make citing with biblatex more user-friendly?

Of course there could be, but I don't think that's the way to go. One reason is that there would be a ton of code duplication and high maintenance cost. Another reason: To my knowledge many people have messy bibliographies with both styles mixed, in which case neither of the two versions of bibtex-completion would do the job. For a clean solution I suppose there would need to be a way to abstract away from the specific fields but this would require the addition of a lot of new infrastructure.

tmalsburg avatar Nov 16 '20 16:11 tmalsburg

You can just customise bibtex-biblatex-entry-alist: replace journaltitle with journal in the required fields as it is an alias anyway, so that C-c C-c -- bibtex-clean-entry won't complain about missing required fields. Then the helm-bibtex insert formatted reference won't be missing the journal title.

ghost avatar Apr 01 '21 21:04 ghost

Thanks, @ledohod. Learned something.

tmalsburg avatar Apr 08 '21 17:04 tmalsburg