LyZ: LyX plugin for Zotero

LyZ is a plugin for Zotero, which is intended to make working with LyX/Zotero more pleasant.

Features

  • Inserting citations to LyX from Zotero.
  • BibTeX database automatically updated when citation is inserted.
  • BibTeX database can be updated when the references in Zotero are modified.Get Zotero
  • Custom BibTeX key format.
  • Unique BibTeX key check.
  • Custom BibTeX translators.
  • Synchronization of BibTex keys between LyX document, BibTeX database and LyZ.
  • Editing of master/child documents (the same BibTeX database) and multiple documents (different BibTeX database for each document).
  • Persistent association of LyX documents and BibTeX databases.
  • Support for group cooperation.

Installation and Settings

  1. LyZ works with Zotero 2.0 and later.
  2. Install LyZ  from Firefox Addons and restart Firefox.
  3. Open LyX and set LyXServer path (in LyX go to menu, Tools > Preferences... > Paths and set LyXServer pipe to): Windows users can use the default path setting in LyZ, i.e. “\\.\pipe\lyxpipe”. Linux and Mac users can use e.g. “~/.lyxpipe” and change the LyZ settings accordingly.
  4. By default all characters are escaped, e.g. š becomes \v{s}. Set extensions.lyz.use_utf8 to true in about:config to avoid escaping (in case you need to use non-latin scripts such as Chinese).
  5. Open document in LyX.

Adding and inserting citations

  1. Open Zotero, select citation and either from LyZ menu or from context menu (right click on the citation) do “Cite in LyX”.
  2. When you try to insert citation into a new document (i.e. document unknown to LyZ) you have to select BibTeX database. You will be asked to either create a new database or choose a database you have created before (by LyZ). Type the database name (*.bib extension is automatically added if you don’t provide it) and press OK. The citation is added into the BibTeX database you have just created and inserted into the LyX document. Your citation should appear in LyX document now.
  3. Insert the BibTeX database into LyX document. See BibTeX and LyX.
  4. Insert additional citations, new ones from Zotero, previously added citation can be either inserted through the LyX interface or from Zotero.
  5. If you modify the reference information in Zotero, use “Update BibTeX” from LyZ menu to update the BibTeX database.

Custom BibTeX keys

  1. Custom BibTeX keys can be set in LyZ > Settings dialog.
  2. The default format is “author year title”. Good alternative for the use with natbib package is format “zotero”, which will produce “human unreadable” BibTeX keys. It consists of library ID and zotero item key, e.g. 0_XXXXX. Format keyword “zoteroShort” will produce only XXXXX, which can be used when exporting from OOo.
  3. Key formats can be composed from keywords “author”, “year”, “title”, “zotero” and separators such as “_” (the following characters should be safe to use: a-z, 0-9!$&*+-.:;<>?[]^`|), e.g. “author year title”, which will produce authoryeartitle BibTeX key, e.g. tichy1988thefoundations. If you prefer the default format used in Zotero BibTeX export (tichy_thefoundations_1988), change the pattern to “author _ title _ year”. The keywords and any separating characters have to be separated by space. Characters in citekeys are escaped and unsafe characters are removed conforming to /[^a-z0-9\!\$\&\*\+\-\.\/\:\;\<\>\?\[\]\^\_\`\|]+/g.
  4. If you use custom BibTeX translator and want to use the cite keys generated in the translator, go to LyZ > Setting and switch creation of cite keys off.

Update BibTeX

Menu command “Update BibTex” will update BibTeX database of the active LyX document. Whatever changes made in Zotero will be reflected in the update, including BibTeX keys if the BibTeX key format or the relevant information (first author, title, year) have been changed.

When a single BibTeX database is shared among several authors, e.g. using version control system such as SVN and CVS, LyZ database is updated from local working copy of BibTeX database.

Only current LyX document will be updated. Multiple document update is implemented, but seems unreliable. Needs more testing…

Synchronization between LyX/BibTeX/LyZ

When Zotero reference is changed, BibTeX database as well as the LyX document can be updated. This is useful when nice BibTeX keys are used, such as ‘author year title’ and e.g. the title or the first author’s surname has been modified, which will result in modification of the BibTeX key. When the “Update BibTeX” is run, you should select to update the LyX document in case your modifications to Zotero references might affect your BibTeX keys. Before the update, a backup of the active LyX document is made (extension *.lyz). LyZ will save, close and then reopen your document.

Notes on usage

  1. Credits: Lyz is inspired by Lytero, which I wanted to improve, but ended up starting from scratch. Hence the new name. Thanks to Dan Stillman and mronkko at zotero.org forum. Justin Wood for BOM and escaping suggestions and donation!
  2. Always modify your references in Zotero. If you modify the BibTeX database manually or using other software, LyZ will overwrite all the changes when you run “Update BibTeX“.
  3. Keep your Zotero items unique. LyZ does not make an attempt to identify duplicates, they will be treated as different items and unique BibTeX keys will be created.
  4. When working with master/child documents in LyX, you will have to specify the BibTeX database for each child document. This will be the same file as specified for the master document. Unfortunately LyZ has no way of knowing the relationship between documents, so it has to be done manually.
  5. Old writing projects can be deleted from LyZ menu. When the record of BibTeX database is deleted, all associated LyX document records are also deleted. When LyX document is deleted, associated BibTeX database will remain untouched as it may be used by another document. The actual file won’t be deleted.
  6. BibTeX database is uniformly exported to UTF8 and all characters are escaped. Exporting to doesn’t seem to have any advantages. When your references contain extra characters such as the degree symbol, add \usepackage{textcomp} to your preamble.
  7. URLs in bibliography. Use bibliography style that can handle URLs, such as apalike, or add \usepackage{url} to your preamble.
  8. LyZ stores the information about documents and BibTeX databases in lyz.sqlite in the Zotero folder. If you backup Zotero with some synchronization application, you will notice the new file.
  9. When working with non-latin scripts such as Chinese, set extensions.lyz.use_utf8 to true in about:config to avoid escaping.

Source code

Please explore at https://github.com/willsALMANJ/lyz.

Problems, Ideas, Requests

Please follow these tips to find out the source of your problem:

  1. Run Lyx in debugging mode from commandline by (Linux and Mac users change accordingly)

    lyx.exe -dbg lyxserver

    Useful messages should appear whenever you send some command from Lyz. A useful message will contain words like ERROR, undefined etc.

  2. To send a command from Lyz, you simply use one of the functions, e.g. “Cite in Lyx” or use command line, viz. http://wiki.lyx.org/LyX/LyXServer.
  3. Also you can use a variant of the last version of Lyz, which has additional menu item “Test…”. This will allow you to send single commands to Lyx. Currently Lyz uses the following commands (code in the parentheses indicates usage):
    • server-get-filename (server-get-filename)
    • citation-insert (citation-insert:LYZ:author2010title)
    • buffer-next (buffer-next)
    • server-get-xy (server-get-xy)
    • buffer-write (buffer-write)
    • buffer-close (buffer-close)
    • file-open (file-open:path, where path is the response from server-get-filename)

    All functions Lyz has are patched together using these commands. The most trouble some seems to be the server-get-filename.

  4. Extract useful information from Firefox’s Error Console and from commandline where you ran lyx.exe -dbg lyxserver and send it to me or even better file a bug, ask a question or submit a request at https://github.com/willsALMANJ/lyz

 

When Zotero reference is changed, BibTeX database as well as the LyX document can be updated. This is useful when nice BibTeX keys is used, such as ‘author year title’ and e.g. the title or the first author’s surname has been modified.

192 comments to LyZ: LyX plugin for Zotero

  • Christoph

    oh, forgot some important information …
    i am using lyz 2.1 with zotero 2.1.8 on
    firefox 4.01 (windows).

  • greg

    Hi,

    can you add a

    before the right-click menu overlay of ‘Cite in LyX’?
    I think that more clean because it separates the LyZ options from the other stuff especially when additional zotero extensions are installed…

    Thanks for the great plugin!

  • greg

    yes, thanks! :)

    I have another more complicated request: I always find it annoying that lyz inserts the citation in a certain style, namely
    Tyson et al. (2005)
    and not (Tyson et al. 2005) or (2005). Would it be possible to use the last citation style used by the lyx ‘insert citation’ dialog? Lyx saves this style and will automatically use this one the next time you open the ‘insert citation’ dialog.
    I am not sure whether that is possible but I think it would be pretty useful…

    Thanks again!

  • Petr

    Unfortunately, I don’t think that is possible (see http://www.lyx.org/trac/browser/lyx-devel/trunk/src/LyXAction.cpp). I think this request appeared here before. I would, however, be happy to be proven wrong.

  • Lucas

    This is a great integration. I´m moving from Word+Zotero to Lyx+Zotero (and would not move to Lyx if there was no Zotero integration). I´m using Windows 7, and the latest Firefox and Zotero. I´ve installed LyX2.0, and LxZ.

    But I´m not able to do step 3 of Installation and Settings. Probably I did not understand the instructions. So can someone explain this step “for dummies” like me?

    First I did not find the indicated path:
    “Tools > Preferences… > Inputs > Paths and set LyXServer path” is not available in LyX2.0. There is no “Inputs” option, or I could not find it.
    I tryed with:
    “Tools > Preferences> LyXServer pipe and set \\.\pipe\lyxpipe ”
    is this the correct place?

    also is “\\.\pipe\lyxpipepipe\lyxpipe” literaly what I should write or I should replace the beggining (“\\.\”) with the program path? (I tryed to look for some “pipe” folder in my computer but did not find it).

    I would appreciate some any hints on this.
    thank you
    Lucas

    • Petr

      Hi Lucas,
      yes it’s LyxServer pipe and you cannot find the path on your computer, it’s not really a file. You just insert “\\.\pipe\lyxpipe”, restart Lyx and you should be set 😉
      Cheers
      Petr

  • Mike

    LyZ was working beautifully and then I updated to LyX 2.01 and it seemed to stop inserting citations.

    Did I fail to do something after updating or is the new version a problem?

  • greg

    Hi, I just tried 2.1.4 with Zotero Standalone but it’s not working for me. LyZ installed but I can’t see the lyz button. Zotero Standalone b2.1 on Mac OS 10.7.1.

    Thanks!

  • Petr

    Thanks Greg. I assume that you can see LyZ enabled in the Addons, right? I don’t have an access to Mac. So far I’ve been able to try only 64bit linux version of Zotero Standalone and it works just fine. There doesn’t seem to be anything special, at least Zotero docs don’t mention it.
    So at this moment, I’m afraid I can’t do much. I’ll post here if there’s some progress. I might get a chance to be around Mac next month.

  • greg

    Just to let you know: It works now after redownloading and reinstalling three or four times. I don’t know what was going wrong… Thanks for the great plugin!

  • greg

    actually, there is still a problem. LyZ does not generate correct citation keys. When I use author-year-title in the settings, LyZ generates citation keys like ‘author-year-title2′. When I don’t let LyZ generate citation keys, everything seems to work…

    • Petr

      Hi greg, can you please check which BibTex traslator you are using? See Lyz settings “Export format (translator)”. Can confirm this behaviour with several citations? I append number after the bibtex key when there are two or more similar keys generated. Thanks

  • greg

    Hi, there is only one available, which is ‘BibTeX’. And yes, this seems to occur with all citations.

    Thanks!

    • Petr

      Ah sorry, there is only one unless you add other manually. It occurred to me that you write you are using “author-year-title”. There have to be spaces between the elements of the bibtex key. Is that the problem?

  • greg

    yes, that was the problem. I was thinking that the default key used to be „author-year-title“ but apparently I was wrong.

    Thanks!

  • Petr

    Splendid! Sorry I didn’t spot it earlier.

  • ingolf

    I love this addon. It makes my live so much easier. Here is an idea that would make it even better. Currently, it’s kind of difficult to arrange the lyx and the zotero window so that I can easily cite. Why not have a particular LyZ citation window as a features implemented in zotero? For example, take the ‘Item select window’ (e.g. opens when you add a related item), keep that window open until the user closes it and insert a citation when the user double clicks an item. Maybe that is too much but does the code already exists in Zotero…

    In any case, thanks for the great plugin!

    • Petr

      Thanks a lot :)
      Not sure what you mean by “particular Lyz citation window as feature in zotero”? What is “related item”? Do you mean window with items already in lyx document?

  • ingolf

    no, I mean a FF window with all zotero item that allows the user to more easily pick zotero items and cite them. When you go to ‘Related’ of any zotero item and add an item, you will see a window with all zotero item from which you can pick one. I thought such as window would make it easier to cite zotero items in lyx because it is less cluttered and citing with double clicking an item would be possible…

  • Petr

    I see. I still don’t understand what you mean by “related”.
    There has been a suggestion to implement keyboard shotcuts which would make citing easier. I was simply putting it off, because of lack of time.
    Lately I was thinking about something like you suggest, except that it would be more of an autocompletion, just like the new default Zotero input in Word or OOo.

  • Mike Sleutel

    First off: Lyz is absolutely great, this is the best thing since sliced bread! I do have a tiny comment I hope you could help me with. I use Lyx 2.0.1, Lyz 2.1.4 and Zotero (previously 2.1.10 but I get the same result with standalone 3.0b2.1) on Windows.

    When I insert an in-text citation in Lyx using Lyz and if I directly after that insert a second other citation without changing the cursor location in Lyx, the two citations are not grouped (e.g. [zhang2006crystal][yoshizaki2006impurityinduced]). To generate correct in-text citations they need to be grouped (e.g. [zhang2006crystal, yoshizaki2006impurityinduced]). If they are not grouped then Lyx doesn’t generate a seperator while typesetting or shortens them when I have more than 3 citations (e.g. 14-19 in stead of 14,15,16,17,18,19). Any suggestions?

    • Petr

      Hi Mike,
      Thanks. There are two ways how to achieve grouped citations:
      1. use CTRL and select more citations in Zotero, then cite. The citations will be grouped. I tend to have materials that get cited together grouped in subfolders in Zotero, so this works most of the time.
      2. insert one by one, then in LyX click on the first citation, which will open the citation dialog and add the other citations from LyX. Then delete the individual citation which are left right after your new grouped citation.

      I thought about “automatic grouping” when citing one by one, but I didn’t implement it in the end because the method #1 works most of the time for me 😉

  • Hi Petr,

    Will Lyz work with the newly released Zotero 3.0? I love the plugin, but am worried about upgrading to the newest zotero.

    Thanks!

    Tomek

    • Petr

      Hi, I’ve been neglecting LyZ for a while, but 3.0 seems to work just fine. There haven’t been any changes in the Zotero code, so nothing should be broken. I’ve just tested with Standalone and all seems to work. But in any case exercise caution, backup your zotero folder and test first 😉

  • I have Firefox installed, but I mainly use Google Chrome. I’m using Zotero Standalone on Windows. Will LyZ work even when Firefox isn’t open? If not, can I install the necessary part of Firefox as a daemon?

  • Joscha

    Hi Petr, here is a small bug that affects both your LyZ and my zotfile plugin. When you start FF everything works fine. However, when you now close the FF Window and then reopen it without shutting down the application, I am unable to open the LyZ settings window. Maybe this only affects Mac OS because you can close all FF windows without quitting the application but it’s easy to reproduce that below is the message from the error console.
    I tried a couple of things but was unable to fix it in zotfile. Would be good to know if you come up with a solution.

    Error: Zotero is undefined
    Source File: chrome://lyz/content/lyz.js
    Line: 264

    • Petr

      Hello again,
      I don’t know anything about Macs. I am curious, if Zotero works fine. I assume it does. So I would look into their code. I am planning LyZ overhaul soon so I will put this on my todo list, but I don’t have an access to a Mac, so not sure what I can do about it. But I’ll have a look!
      Take care
      Petr

Leave a Reply to roey angel Cancel reply