Integration with latex?

2
  • 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.

    It should show up automatically.
  • so type 3 is an export translator I assume, further, I assume UUID is a unique javascript ID?
  • edited January 30, 2011
    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!)
  • thanks ajlyon...I'll go to dev with further questions. But you solved my primary problem. many thanks
  • 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.
  • Thanks. I will try this.
  • 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)

    1. http://www.zotero.org/styles
    2. http://www.zotero.org/styles/bibtex/dev?install=1
  • 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).

    Thanks!
  • encountered the same problem. see discussion on ubuntu forum

    http://ubuntuforums.org/showthread.php?t=1710667
  • Great!, works fine now

    Thanks
  • 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>
  • So use some other app designed specifically for use with BibTeX. And maybe check back in a few months.

    What value is a rant like this really? Next time take a breath before posting.
  • @bdarcus <sarcasm> thanks that's really helpful </sarcasm>.
  • @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.
  • @fbennett: Thank you, that makes very good sense. I'll try the settup you suggest.
  • 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.
  • edited April 30, 2011
    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);

    // 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!
  • These aren't styles, but rather export translators in this case. But the idea is just right.
  • edited December 30, 2011
    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);

    // write citation key
    if(first == true) {Zotero.write(citekey);}
    else { Zotero.write(","+citekey);}
    first = false;

    }
    Zotero.write("}");
    }

    Cheers!
  • So there is still no way to connect smoothly Zotero with LaTex?
  • 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
  • edited January 15, 2018
    @balabi

    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.
  • So all is well with Zotero 5 and Better BibTeX?
Sign In or Register to comment.