ajlyon, the Zotero.Utilities.cleanTags(..) worked. I have tried it with only one note, but it should be fine with multiple notes. This will hold me until I have more time to get it precisely right, so very much thanks.
how do you register new .js translators with the export command?
Can't you just replace the existing BibTeX.js and restart Firefox? Otherwise, save the new file to the translators directory and change the translatorID to a new UUID, then restart.
This discussion should probably have moved to zotero-dev some time ago, but in short: the the types are a bitfield; 1 is import, 2 is export, 4 is web, 8 is search. The UUID is, well, a UUID. See http://en.wikipedia.org/wiki/UUID -- you can get one here (and many other places!)
In particular, the handling of HTML in note fields that you describe is not good. If you can propose a nice way of doing it in a LateX-y manner, please submit a patch to zotero-dev and we'll see about getting it into the main release.
A problem I had recently with zotero exports as a .bib file was that special characters were not translated correctly so that LaTex could display them correctly. If the title field contained gamma, the .bib file would also have gamma, not $\gamma$. If the title field contained $\gamma$, the .bib file would have $\textbackslash gamma$. This was frustrating.
I produced a .sed script for post-processing of the zotero generated .bib file:
s/alpha/{$\\alpha$}/g
s/beta/{$\\beta$}/g
s/gamma/{$\\gamma$}/g
s/epsilon/{$\\epsilon$}/g
s/{a}/{\\"a}/g
s/{o}/{\\"o}/g
s/{AlCl3}/Al{C}l{$_3$}/
s/Br-1)x/Br{$^{-1})_x$}/g
s/NH3/NH{$_3$}/g
s/H2O/{H$_2$O}/g
My process was
(1) export library from zotero
(2) run the script on the zotero generated .bib file to produce a good .bib file that LaTex can read.
If I added a bunch of new references to my zotero library, it was easy to re-export and modify the new .bib file.
This got the job done, but I'm not sure if it was the most elegant solution.
If the title field contained gamma, the .bib file would also have gamma, not $\gamma$.
Change the character set on export to use something other than UTF-8 (such as ISO-8859-1) & Zotero will have LaTeX transliterations for all of the entities in your sed script and more.
I'm using another very simple method for combining zoteros functions with latex now:
In the Zotero style repository[1] there is an "Bibtex generic citation style"[2] which inserts the bibtex key in the document when holding shift. After installing it you probably have to edit the Zotero settings in Zotero -> Preferences -> Styles to ensure that Zotero is using this style. (I had to restart my Browser to make it work)
Did anyone have a recent problem with this drag and drop solution? I recently updated zotero to V 2.1.1 and the drag and drop stopped working (doesnt drop the key on the text).
I like Zotero. It does so many things right, starting with the basic idea that reference management should be built into a web browser. So I would love to start using Zotero. <rant> But the lack of proper bibtex import/export is a cold showstopper. I have years of citations in bibtex form, and LaTeX documents that cite those references using the existing citation keys. If I switch to Zotero I lose the ability to update those documents, because the cite keys don't survive import/export. That is simply intolerable, to the point that I'm astonished that such an obvious problem still exists in Zotero. It basically makes it impossible to switch to Zotero from bibtex-based reference management. Personally I don't care about what cite keys zotero assigns to new references, but I absolutely cannot switch until such time as Zotero preserves my existing cite keys through the import/export process. </rant>
@izahn: What you need is a mapping of your local BibTeX keys to Zotero item identifiers. That data doesn't need to be stored in Zotero, and probably shouldn't be (since the Zotero items might be used by others who apply different local keys to the same items).
Your personal mapping should reside on your local system, and would be used either to adjust the keys in data re-exported from Zotero for ordinary BibTeX processing or, if direct access to Zotero is implemented by a BibTeX tool at some point, to remap keys on the fly in LaTeX code called by a one-line header added to your existing documents.
That data doesn't need to be stored in Zotero, and probably shouldn't be (since the Zotero items might be used by others who apply different local keys to the same items).
Zotero does store other information about records that are user-specific (tags, notes, extra, etc.). I think the medium term plans are to include a way to store local IDs, no?
Fair point; but having local IDs that sync to a shared group would surely call for an uncommon degree of solicitude among group members, unless you had a field- or record-level permissions model.
The local ID being discussed is a citation label, which could be used as a BibTeX key, but could also be used for author trigraph (AMS) styles. The latter case is not user data, but it also will depend on the styles and therefore the label forms the group members use.
I found some more info on another forum. You can modify the BibTex.js style to provide functionality that lets you drop a \cite{} directly into a document.
I have the latest version of Zotero installed and this works for me.
Create a new style
1) Browse to your styles directory 2) Make a copy of BibTeX.js. 3) Rename the copy to BibTexCiteKeyOnly.js 4) open the file in a text editor
Make the style unique
5) replace the last character in the "translatorID" with a different character 6) change the "label" to "BibTexCiteKeyOnly"
Replace "function doExport()"
5) Jump to the last function: function doExport() 6) Delete the entire function 7) Replace with the following code:
function doExport() { //Zotero.write("% BibTeX export generated by Zotero "+Zotero.Utilities.getVersion()); // to make sure the BOM gets ignored var first = true; var citekeys = new Object(); var item; while(item = Zotero.nextItem()) { // determine type var type = zotero2bibtexTypeMap[item.itemType]; if (typeof(type) == "function") { type = type(item); } if(!type) type = "misc";
// create a unique citation key var citekey = buildCiteKey(item, citekeys);
Big thanks sleework, this was excatly what I was looking for. Now I just have to get my LaTeX to stop giving me citation undefined warnings and I'll be golden.
Sleework, the code needs to be changed if one has multiple citations. Here are my modifications:
function doExport() {
//Zotero.write("% BibTeX export generated by Zotero "+Zotero.Utilities.getVersion());
// to make sure the BOM gets ignored
var first = true;
var citekeys = new Object();
var item;
Zotero.write("\\cite{");
while(item = Zotero.nextItem()) {
// determine type
var type = zotero2bibtexTypeMap[item.itemType];
if (typeof(type) == "function") { type = type(item); }
if(!type) type = "misc";
// create a unique citation key
var citekey = buildCiteKey(item, citekeys);
depends on what you call smoothly. There are lots of people working successfully with Zotero and LaTeX. A commonly used tool to help that workflow is
https://github.com/ZotPlus/zotero-better-bibtex/
No one mention texstudio? It is free and popular. Jabref's pushing citation feature is great. If zotero can support push citation to common latex editor, then I don't have to use jabref
You can use Better BibTeX addon (https://github.com/retorquere/zotero-better-bibtex), which adds automatic export and many other neat features for LaTeX users. I completely ditched Jabref from my workflow and use LaTeX editor (VSCode with LaTeX Workshop extension) directly with exported BIB file from Zotero without any problems.
how do you register new .js translators with the export command?
It should show up automatically.
I produced a .sed script for post-processing of the zotero generated .bib file:
s/alpha/{$\\alpha$}/g
s/beta/{$\\beta$}/g
s/gamma/{$\\gamma$}/g
s/epsilon/{$\\epsilon$}/g
s/{a}/{\\"a}/g
s/{o}/{\\"o}/g
s/{AlCl3}/Al{C}l{$_3$}/
s/Br-1)x/Br{$^{-1})_x$}/g
s/NH3/NH{$_3$}/g
s/H2O/{H$_2$O}/g
My process was
(1) export library from zotero
(2) run the script on the zotero generated .bib file to produce a good .bib file that LaTex can read.
If I added a bunch of new references to my zotero library, it was easy to re-export and modify the new .bib file.
This got the job done, but I'm not sure if it was the most elegant solution.
In the Zotero style repository[1] there is an "Bibtex generic citation style"[2] which inserts the bibtex key in the document when holding shift. After installing it you probably have to edit the Zotero settings in Zotero -> Preferences -> Styles to ensure that Zotero is using this style. (I had to restart my Browser to make it work)
1. http://www.zotero.org/styles
2. http://www.zotero.org/styles/bibtex/dev?install=1
Thanks!
http://ubuntuforums.org/showthread.php?t=1710667
Thanks
<rant>
But the lack of proper bibtex import/export is a cold showstopper. I have years of citations in bibtex form, and LaTeX documents that cite those references using the existing citation keys. If I switch to Zotero I lose the ability to update those documents, because the cite keys don't survive import/export. That is simply intolerable, to the point that I'm astonished that such an obvious problem still exists in Zotero. It basically makes it impossible to switch to Zotero from bibtex-based reference management. Personally I don't care about what cite keys zotero assigns to new references, but I absolutely cannot switch until such time as Zotero preserves my existing cite keys through the import/export process.
</rant>
What value is a rant like this really? Next time take a breath before posting.
Your personal mapping should reside on your local system, and would be used either to adjust the keys in data re-exported from Zotero for ordinary BibTeX processing or, if direct access to Zotero is implemented by a BibTeX tool at some point, to remap keys on the fly in LaTeX code called by a one-line header added to your existing documents.
I have the latest version of Zotero installed and this works for me.
Create a new style
1) Browse to your styles directory2) Make a copy of BibTeX.js.
3) Rename the copy to BibTexCiteKeyOnly.js
4) open the file in a text editor
Make the style unique
5) replace the last character in the "translatorID" with a different character6) change the "label" to "BibTexCiteKeyOnly"
Replace "function doExport()"
5) Jump to the last function: function doExport()6) Delete the entire function
7) Replace with the following code:
function doExport() {
//Zotero.write("% BibTeX export generated by Zotero "+Zotero.Utilities.getVersion());
// to make sure the BOM gets ignored
var first = true;
var citekeys = new Object();
var item;
while(item = Zotero.nextItem()) {
// determine type
var type = zotero2bibtexTypeMap[item.itemType];
if (typeof(type) == "function") { type = type(item); }
if(!type) type = "misc";
// create a unique citation key
var citekey = buildCiteKey(item, citekeys);
// write citation key
Zotero.write("\\cite{"+citekey);
first = false;
Zotero.write("}");
}
}
8) Save the new file and restart Firefox
9) Within the export preferences set the style you just created
Exporting the Citation
Now you can drop your citations directly into latex. Hold down shift and click+drag the desired citation to your document.Hopefully this helps.
Cheers!
function doExport() {
//Zotero.write("% BibTeX export generated by Zotero "+Zotero.Utilities.getVersion());
// to make sure the BOM gets ignored
var first = true;
var citekeys = new Object();
var item;
Zotero.write("\\cite{");
while(item = Zotero.nextItem()) {
// determine type
var type = zotero2bibtexTypeMap[item.itemType];
if (typeof(type) == "function") { type = type(item); }
if(!type) type = "misc";
// create a unique citation key
var citekey = buildCiteKey(item, citekeys);
// write citation key
if(first == true) {Zotero.write(citekey);}
else { Zotero.write(","+citekey);}
first = false;
}
Zotero.write("}");
}
Cheers!
https://github.com/ZotPlus/zotero-better-bibtex/
You can use Better BibTeX addon (https://github.com/retorquere/zotero-better-bibtex), which adds automatic export and many other neat features for LaTeX users. I completely ditched Jabref from my workflow and use LaTeX editor (VSCode with LaTeX Workshop extension) directly with exported BIB file from Zotero without any problems.