crsh / citr

RStudio Addin to Insert Markdown Citations
Other
408 stars 46 forks source link

citr writing separate bibtex reference entry, halting r latex output #21

Closed koliajaykr closed 6 years ago

koliajaykr commented 6 years ago

When I'm adding a new reference and trying to cite it using citr, below is the screen-shot of error I'm using zotero standalone 5 with firefox connector. screenshot from 2017-12-04 22-22-13

crsh commented 6 years ago

Hi Ajay, as the error says, something in your bibliography is not compatible with natbib. This may be due to the information that is contained in one of your references (in Zotero) or due to the information that is exported. I would need to see the .bib-file to get a better understanding of what's going on.

koliajaykr commented 6 years ago

PFA book.bib.tar.gz

crsh commented 6 years ago

Thanks. There are a lot of references in that file. Any idea, which one is causing the problem?

koliajaykr commented 6 years ago

@retorquere

koliajaykr commented 6 years ago

Process is I add a new reference in zotero standalone 5 + better bibtex, then using citr to cite the new reference. I updated the bib file in citr. Then I inserted the new reference in the r file. When I click ctrl+shit+b to run the r file. Then in console citr comes up with this:

Listening on http://127.0.0.1:4961
Writing 1 Bibtex entries ... OK
Results written to file '/home/ajay/thesis-ajay-10mbph04/book.bib'

After this I check manually the bib file in my R working dir. I found that citr is removing the commas from the author entry from the new added reference. author = {Erik Cohen},

it should be like this author = {Cohen, Erik}, And R halt the latex output. I hope that this screen-shot you may found helpful.

**Now what I'm forced to do is:

  1. add reference in zotero
  2. manually transfer bib file, after every zotero update in bib.file, for R doc
  3. then citr is working perfectly**
retorquere commented 6 years ago

I see that I've been hailed, but I don't really know what I could add here. I don't know how bbt is involved (auto-export? Pull export?) nor how the bbt-generated output is tripping up citr.

{Lastname, Firstname} is the same as {Firstname Lastname} as far as bibtex is concerned.

crsh commented 6 years ago

First, as Emiliano has pointed out, both formats of the author field are valid.

The exported entry uses the date instead of the year field and that seems to be tripping up natbib (although I cannot reproduce the problem on my computer). Could you confirm that your document compiles when you replace date by year in the last entry?

From other discussions I have found on this, you may have to change your BBT exporter to BibTeX instead of BibLaTeX. (@retorquere, BBT is involved as a means to access the Zotero database via http).

koliajaykr commented 6 years ago

I'm already exporting bib file as bibtex. It seems that @retorquere found a bug and working on it. I'll let you know if it is solved. And I'll try your suggestion too.

retorquere commented 6 years ago

BBT doesn't export date fields for BibTeX exports.

retorquere commented 6 years ago

And there's no empty line before HornerConsumerBehaviourTourism2007 -- this is probably a BBT file looking at the structure, but it also appears to have been edited.

retorquere commented 6 years ago

@crsh access in what way? What is being requested? A bib file, the groups? BBT has several HTTP-enabled APIs.

retorquere commented 6 years ago

@ak-koli the problem I'm looking into (assuming you mean https://github.com/retorquere/zotero-better-bibtex/issues/834) won't affect whether date is being output.

koliajaykr commented 6 years ago

@retorquere , happily agree with you.

crsh commented 6 years ago

@retorquere The current access method is via http://localhost:23119/better-bibtex/library?library.biblatex. I read the provided BibTeX-file into R and write the selected entries into the local BibTeX-file. Looking at some of my files it looks like the R function I use for this may have changed its default behavior.

@ak-koli Can you confirm that natbib works if you change the date field to year?

retorquere commented 6 years ago

@crsh try http://localhost:23119/better-bibtex/library?library.bibtex if you want bibtex.

retorquere commented 6 years ago

To elaborate, http://localhost:23119/better-bibtex/library?library.biblatex doesn't grab a BibTeX file, it grabs a BibLaTeX file. The file extension determines what you get.

koliajaykr commented 6 years ago

@crsh , no offence, but this issue is solved now. Thanks both of you @crsh and @retorquere .

retorquere commented 6 years ago

I know I ought to stay out of it, and I honestly don't mean this in a patronizing way, but just in case you're not a native English speaker and not wholly familiar with the contemporary use of "no offense intended"; the phrase "no offense" has sort of drifted off to come to mean "this will likely offend you, but I don't think you should complain about it". I really don't see anything anyone could take offense at, but the use of the phrase in this way may cause some to seek offense - precisely the opposite of what it was meant to do.

Not saying @crsh would take it this way. No offense intended at either of you :)

koliajaykr commented 6 years ago

Thank you @retorquere

crsh commented 6 years ago

Thanks @retorquere, indeed. This raises an interesting point. What's the more appropriate default to use bibtex or biblatex. I hadn't anticipated that switching the R Markdown citation backend to natbib would cause problems. I figured that biblatex is more flexible and would be more appropriate but now I'm thinking bibtex may be more appropriate because it's compatible with natbib. I will definitely add an option to change this default behavior but I wonder if I should default to bibtex instead.

@ak-koli did you fix the problem by editing the .bib-file? That's probably not a sustainable solution because it may be necessary every time a new reference is inserted. Another approach would be to switch to using biblatex instead of natbib, no?

retorquere commented 6 years ago

On general principle, you should only use bibtex (and by extension, natbib) if you are forced to. Any time you can, use biblatex. Bibtex cannot do a whole lot of things that biblatex was created to solve.

koliajaykr commented 6 years ago

Yes, @crsh , this problem was solved here #834 with help of @retorquere . Sorry, I did not use your suggestion because the error was solved.