getting bibtex keys when using Writer2LaTeX on a Zotero/OpenOffice document

Hi,

Has anyone found a workflow for using Writer2LaTeX on an OpenOffice.org odt document with Zotero citations? I'd like to turn the odt file into a LaTeX document with citation keys that match the bibtex keys I use in LyX (where I also use Zotero).

What Writer2LaTeX gives me now is just stuff like


\label{ref:ZOTEROITEMsorttruecitationItemsurihttpzoteroorggroups23258itemsVQT5RPTURNDi5Ug45XVK3}(Nordahl,
S�rlie, Manger, \& Tveit, 2007)
  • OK so I unzipped the odt file and found that the xml contains something like

    <text:reference-mark-start text:name="ZOTERO_ITEM {"sort":true,"citationItems":[{"uri":["http://zotero.org/groups/23258/items/VQT5RPTU"]}]} RNDsvJ507erEH"/>
    (Nordahl, Sørlie, Manger, & Tveit, 2007)<text:reference-mark-end text:name="ZOTERO_ITEM {"sort":true,"citationItems":[{"uri":["http://zotero.org/groups/23258/items/VQT5RPTU"]}]} RNDsvJ507erEH"/>

    and when I use LyZ to cite in LyX with "zotero" as the bibtex key, I get

    260548_VQT5RPTU

    as the bibtex key. Now, VQT5RPTU should be extractable (by Writer2LaTeX) from the reference-marks XML (the URI ends in that), but 260548? Where does LyZ get that from? Another item I cited with LyZ got a 0 and then the reference-marks URI.

    I guess I could run a script on both the bibtex and the LyX file to strip those initial numbers before running bibtex, but that seems rather hacky :-/
  • OK so I added a feature request (https://blueprints.launchpad.net/lyz/+spec/writer2latex) for LyZ to give a bibtex key that writer2latex will be able to use, and another to the writer2latex team to parse Zotero reference-marks.

    In an ideal world, the Zotero UI would show a persistent "bibtex" field, and ensure uniqueness for this, while putting it into the reference-marks XML; but I guess something like that requires more work than just getting LyZ to output VQT5RPTU instead of 260548_VQT5RPTU.
  • The part before the underscore looks like the library ID -- it's not very well documented (or at all documented), but each Zotero item has a stable ID, which is made of two pieces -- a library ID and an item ID. There's some discussion of this at http://forums.zotero.org/discussion/8306/testing-zoteroselect/ . A library ID of 0 is (iirc) supposed to be reserved for items that have not been synced, but I seem to get it pretty often.
  • each Zotero item has a stable ID, which is made of two pieces -- a library ID and an item ID.
    (Doesn't really matter, but just for future reference, it's a library ID and an item key, not item ID. Item ID is a non-stable, numeric identifier unique to local clients.)
    A library ID of 0 is (iirc) supposed to be reserved for items that have not been synced, but I seem to get it pretty often.
    libraryID of 0 means your personal library, as opposed to a group library. Personal libraries on the server do have associated library IDs, but the local items aren't currently updated on sync.
  • edited August 15, 2010
    Hmm, so I guess a single item key could potentially appear in different entries in different libraries. Ie. my personal library could have an entry with 0_VQT5RPTU, my shared library1 have 260548_VQT5RPTU, my shared library2 845062_VQT5RPTU (where the three have different titles, authors etc.)? (Although I presume the probability would be rather low…)

    Is there any way to find the Library ID from the odt xml? I see the number in the URI doesn't match with the library ID :-(
  • A key could in theory appear in multiple libraries, though it's sufficiently improbable that, for example, we haven't yet updated Zotero's local storage to account for it. But for new code it would be best not to make the assumption that a key is unique.
    Is there any way to find the Library ID from the odt xml? I see the number in the URI doesn't match with the library ID
    At present, not that I can think of. libraryID != userID. But we should be offering a server API method to do that conversion, or at least returning the libraryID in an API request.
  • Would it be possible for the OOo-plugin to annotate the odt with the libraryID somehow? (Like an "optional field".)
  • edited November 1, 2010
    OK so I gave up waiting for replies from the LyZ and writer2latex authors =P

    The patched http://github.com/unhammer/lyz will give LyZ a new citekey format "writer2latex" that outputs only the ItemID (object key).

    http://github.com/unhammer/writer2latex is a version of writer2latex that reads Zotero reference-marks and outputs LaTeX \cite commands.

    I haven't tested with multiple authors yet, and LyX doesn't seem to be able to parse \cite[prefix][]{citekey} (ie. using empty suffix in order to only have prefix), but I'll be continuing to work on this as I really need it this fall...
  • Henrik Just recently released a development snapshot of Writer2LaTeX that parses Zotero references =D See http://forums.zotero.org/discussion/14995/writer2latex-now-supports-zotero-references/ for how to use it.
Sign In or Register to comment.