In line citation with as citekey for easier latex conversion
Hi,
I want to create a custom citation style, where the in line citation are expressed using the citation key. In the "search by example" it provide many examples, however, I am not sure how to reference bibtex citation key.
The result should look like " as mentioned by \cite{somekey}"
Thank you,
Amin
I want to create a custom citation style, where the in line citation are expressed using the citation key. In the "search by example" it provide many examples, however, I am not sure how to reference bibtex citation key.
The result should look like " as mentioned by \cite{somekey}"
Thank you,
Amin
I am also very interested in what OP is asking about. I made a post here about it: https://github.com/ZotPlus/zotero-better-bibtex/issues/455
bwiernik, can you please give some more specific information because I can't find what you are referring to on the BBT website. I think the goal should be to create a Zotero Style in CSL so one can easily switch between say APA, and BIB citation key. Just the press of a button to go from (Author, 2016) to \autocite{Author_2016} and back again!
Here is the text of the github post:
Hello all,
I would like to discuss a possibility for BBT which I hope will be of interest to a few people out there. My sincere apologies if posting here is not the correct way to go about this, but I saw a note saying to leave any ideas in the issue tracker.
I would like very much to be able to call the citation key defined by BBT in an in-line citation using the Word (or other) plugin. I write my documents using Word and then use pandoc to convert the docx to a tex file, which pandoc does beautifully. I then drop this converted tex output into one of my latex templates. The only thing left for me to do is manually change all of the (Author, 2016) in-line citations to \autocite{author_2016} or \autocite*{author_2016} so biblatex and hyperref can do their thing. I think it is possible to use the Zotero CSL Editor to make a citation style that will give me the desired output, so I won't have to manually type the autocite commands anymore.
Using the CSL editor, I see that it is relatively straightforward to change the prefix and suffix of an in-line citation. This can be \autocite{ for the prefix and } for the suffix. Now all that's left is to call the citation key set by BBT in the middle! Obviously, the full solution here would require the prefix to be \autocite* when the author name is suppressed in the Zotero Word add-in, and page/section/chapter numbers should also show ( eg. \autocite*[1]{author_2016} ). The astrix should be set by using the suppress author command, and the page number should format as shown by just typing the page number in the Word plugin popup. Citation keys for citations with more than one source should be separated by commas, as biblatex requires. It seems like a bit of a task when I think about it, but I'm really hoping that this project could see some progress, as it would I think make some real strides toward the fastest Word-->LaTex conversion possible. Once complete, a few versions of what I've outlined above could be added to the Zotero citation repository (for people who use cite commands beside autocite).
The most basic question that I need to know the answer to to get started is how to call the "Citation Key" field generated by BBT in the CSL editor, so the key will show in an in-line citation in Word. I believe this is a "macro," correct? What is the macro name so I can call it in the CSL editor?
The rest of the workflow is pretty straightforward. Just export the biblatex to a .bib file as usual, copy the pandoc generated latex into a template, and compile. The result is a fully typeset document with about zero conversion work!
Anyway, I'm not a programming whiz, but I'm willing to learn, so if anyone finds this an interesting possibility and is willing to help me, I'm sure it would be of great use to quite a few people, who work/collaborate in Word, and then typeset with LaTeX and BBT. Thanks everyone!
bwiernik, I'm pretty sure, is just referring to BBT's ability to allow drag&drop citekeys on shift+drag
* Monkey-patch CSL.Engine.prototype.getCitationLabel to return the citation key. Doable, but tricky, as I am not even close to understanding how citeproc hangs together internally. Probably allows detection of author-suppression. Oddly enough, the current implementation looks like it's hard-wired for author-year citation style, which more likely than not means I misunderstand either how it's called or what it does.
* Monkey-patch (replace, really), the CSL.Output.Formats.prototype.rtf."@cite/entry" (since the Word plugin support hard-codes the rtf formatter; BTW, this entry is specified twice in Zotero, so it could be random which is picked). Fairly easy to do; I already have a markdown formatter that accesses the BBT cite keys. There may be enough information to infer author-suppression, but I think at the point the formatter is involved, citeproc has already done most of the work and is likely to have discarded information that specifies this clearly.
* Inject (through monkey-patching, natch) the citation key into an existing CSL variable, e.g. citation-number. Obvious downside: you lose the legitimate use of an existing CSL variable. Upside: all the rest can probably be handled much more cleanly by creating a new CSL style built on the assumption of availability of this variable. And the CSL style ought to be able to do author suppression cleanly.
Thoughts, preferences?
Thanks so much, these are all great ideas. Honestly, the third option sounds closest to what I envisioned, although you are clearly more qualified than me to judge if this is the most feasible way. The benefit of clean author suppression is a big plus here.
I get that there is a downside in the loss of an existing CSL variable, but, if you think about it, do we really lose any practical value by losing the variable citation-number, for example? I don't see any use cases for this citation style that would require the use of CSL variables besides the one we are monkey-patching with the citation key. Does that seem fair? We really just want the two alternate prefixes: "\autocite{" and "\autocite*{" for author suppression, one suffix "}" The page number is a bit trickier given its required position, but it at least needs its own prefix and suffix "[" and "]" and to have its location changed to between the word autocite and the "{" or the "*" and the "{". I imagine an existing citation style which included the addition of "p." and "chap." etc. could be borrowed for that aspect of the formatting.
Please let me know if there's anything I can help with! As I said, I'm willing to learn. Thanks so much for your interest in this. I know I'm not the only one who would love to have this!
I was thinking about two possibilities, of which I am not sure which would be best overall. The first is to do as I have been suggesting, which is read the BBT set citekeys and just use them as variables in the citation style -- and I assume that is what you're thinking of doing. The other would be to tap into the way that Zotero generates citekeys itself (if BBT is not installed). I don't know how it works in Zotero, but obviously it has the ability to generate citekeys (as it does when you export a collection to a .bib). Perhaps this solution would be better in some way because it wouldn't require the use of BBT? Personally, I like BBT and I like to see my citekeys in Zotero, so I prefer a solution which uses the BBT citekeys. Just a thought though, in case this was actually a preferable solution - or easier to implement for some reason.
* Re-implementing the BBT key generator means you're re-creating half of BBT. I have no objections, but I don't think you want to go all that baroque if you want to go BBT-less.
* Even the Zotero citekeys cannot be easily recreated inside itemToCSLJSON (which is the place where I think this should happen) since Zotero citekeys are export-session-unique, not globally unique, and itemToCSLJSON isn't aware of the session it is used in.
What I could do (what I am halfway done with) is a run-time (aka monkey) patch that simply replaces the citation-label with the BBT citekey after itemToCSLJSON is done. It's a 3-line job, but I'm running into an unrelated error right now that I need to fix first.
Since this is without a doubt the easiest thing for me to do, I vote option #3, and proceed with the discussion at https://github.com/ZotPlus/zotero-better-bibtex/issues/455.
Can't help you with the CSL though. That is some deep voodoo right there.
Synced URIs look like this:
Peronsal Library http://zotero.org/users/2433/items/8E9SXCK7
Group: http://zotero.org/groups/487712/items/IEUTG9XC
Where, obviously, the numbers in the middle are the user/group ID and the code at the end the item key.
* http://zotero.org/users/<library ID>/items/<reference key>
means item in personal library; I can see whether it has been synced (because it will have a number instead of "local"), but all I need to know to resolve this item is that it's in library 0/null/1/you know what I mean.
* http://zotero.org/groups/<library ID>/items/<reference key>
means item in group library, and in this case I need that ID to look up the reference.
If that's right, I hope to make some progress on the CSL editing to make a viable citation style for the repository. I think it would be relatively straightforward to make several variants, for people who use different cite commands. If anyone is watching this thread and can offer help in this regard, please join in. I think most users would not be concerned about defining bibliography styles for these citation styles, as those will be defined in the tex code. The main goal is jut the in-line citations. Is there any particular style that might be best to start with as a base? I would think any style that supports page/section/chapter abbreviations should work fine.
WRT how this was implemented: I wrap the Zotero function that usually converts Zotero references to their CSL equivalent; I let it do it's thing, and just add my citation key to the result after its done. Source code is the nine lines starting at https://github.com/ZotPlus/zotero-better-bibtex/blob/455/chrome/content/zotero-better-bibtex/zotero-better-bibtex.coffee#L867. One of the simpler ones as far as monkey-patching goes.
As far as creating CSL styles go, braver souls than me will have to be involved.