สล็อตเว็บตรง

สล็อตเว็บตรง

สล็อตเว็บตรง

สล็อตเว็บตรง

LyZ: LyX plugin for Zotero LyZ: LyX plugin for Zotero « The Joys and Sorrows Of a Life At Sea

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

  • Thanks a lot, at last someone made it! you rock man! Now switching completly to Lyx

  • Scott

    This looks great and I’d love to try Lyz, but it isn’t compatible with my version of Firefox (3.6.2pre). Can you bump the maxVersion from 3.6 to 3.6.* in the .xpi?

    Thanks.

  • Jose

    Congrats! This combo is the best ref man on the market now.
    It.

    A keyboard shortcut to insert refs would make it complete for me.

  • It’s me again. I worked with Lyz pretty well while dealing with English reference. However, today when I tried to cite one Chinese book, there is no response. I set the LyX document as UTF-8. And if I export the bib database in zotero and import it in LyX,it will work well(just in the old way before lyZ’s appearance). Can you help me?

  • Mike

    Hi Petr,

    This is a great tool, I’ve installed it along with LyX and successfully managed to insert my Zotero citations into my paper. I have a couple of questions about modifying the behavior of the bibliography; as I’m a bit of a LyX novice I’m not sure if these issues are a LyX or LyZ matter. Here it goes:

    1) When inserting citations from the BibTeX bibliography into the paper body, there doesn’t seem to be anything keeping the citations in numerical order according to first appearance in the paper. For example, I have a document with only three citations, all from Smith. When I preview with two citations inserted, I can have citations that look like this:

    “…we know this is true, according to Smith [1][2] …”

    but then I can add another reference earlier in the sentence and it will appear as

    “…we know this[3] is true, according to Smith [1][2] …”

    Generally in papers the first paper to be referenced is also the first to appear in the bibliography or references section. I would expect the bibliography to insert the first referenced paper as the first in the references list, so the reference numbers always go in order — i.e., I would expect the numbers to shift such that it looks like

    “…we know this[1] is true, according to Smith [2][3] …”

    noting that the numbers now point to different references. Is getting that ordering right something LyZ controls, or do I need to fiddle in LyX?

    2) If I would like to change the appearance of citations from bracket-enclosed to superscripts, is that a LyZ or LyX matter? i.e., going from [1] to a superscripted ^1.

    3) If you click ‘Update BibTeX’ without saving your LyX document first, when LyZ closes and reopens the LyX file it loses all unsaved changes. I’m not sure if this means that the save-before-backup you mentioned isn’t working in general, or just that my particular installation is bad. Does anyone else have this problem?

    Thanks,
    Mike

  • Petr

    Hi Mike,
    1) LyX issue, you need to change the type of bibliography to e.g. unsrt
    2) this you also have to do in LyX
    3) Thanks, I will repair that.
    Cheers
    Petr

  • Jose

    If you implemented the keyboard shortcut, how do we upgrade? FF doesn’t grap updates to the plugin automatically.

    Also, I cannot get it to work on windows using Lytex (portable lyx). It complains that lyxpipe doesn’t exist. Any idea why?

  • Petr

    Jose,
    I haven’t implemented the keyboard shortcut yet.
    Not sure why FF wouldn’t get the updates. In case you have lower version than that on Addons, just install from there directly. I will take a look at this later.
    Try to start the portable lyx from commandline by “lyx.exe -dbg lyxserver”. I suppose the server might be disabled because of the portable installation. Not something I can help with, sorry.
    Cheers
    Petr

  • This is a nice tool but…
    If it ancounters any alien reference during “Update Bibtex” i eats it – replacing with “undefined” AND replaces it on disk too. I have lerned about .lyz~ backup file too late… !

    It have deleted my whole bibliography in 30p paper. I was a little bit mad… :)

    I have modified the script to guard against this – just skipping over unknown keys and informing about it. Where do you want it to be send? (Maybe just contact me).

    And to others – just do not mix bibliographies for now! Keep it all under zotero/lyz or you will be sorry!

  • ScoBe

    Petr,

    Can I use LyZ to keep my BibTeX file updated for use in other LaTeX authoring software? (in my case Emacs, using org-mode to export to LaTeX and eBib for the bibliography)? I like that LyZ (so it seems) can do an incremental export of the additions and changes to my Zotero library. Of course I’m willing to run LyX in the background. I tried setting the LyX server path in LyZ and LyX to the same value (~/.lyxpipe), but that, it would seem, is not enough.

    And here’s a feature request: the ability to delete some of Zotero’s normally exported BibTeX fields. In my case I like keeping URLs in my database for paper articles, but my BibTeX style uses them if they’re in my .bib file (which don’t want and can’t seem to change). I’d be glad to keep them in Zotero, but omit them from the .bib file. Alternately, LyZ could offer a way to pipe the changes through something like ‘bibtool’ which I could configure to do the transformations. But I suppose this would be hard to do in a cross platform way.

  • Petr

    ScoBe,
    you should be able to do it as long as LyX is running. It’s been a while since I used ebib, so I don’t remember if it watches whether the bibtex file has been modified.
    You would be adding references to the opened LyX document (which you should save and open again later or you will need to relate new document to the original bibtex file). Much better way would be to write a simulation of lyxserver for Emacs (that’s the way Kile works, even though in rather limited way). I might give it a shot since I still use Emacs for everything else, but no promises (certainly not sooner than end of April).
    I was thinking about something like your request. As you say, using bibtool might not play nicely on all platforms.
    I will keep that in mind and try to figure something out soon…

  • Ian

    Very interested in using this – I normally use JabRef / windows and would like to cut out the intermediate stage. My initial experience has been a bit frustrating getting the bibliography format I want -some author-name style like APA would do – but a lot of the combinations of bibtex styles and bibliography settings selected in LyX seem to fail on output. Only basic numbered forms seem to work properly. Maybe this is a LyX-side problem, but it is not obvious to me where the problems lie.

  • Petr

    Ian,
    could you be more specific in what way do the bibliography styles fail? There are two sides that: (1) how the citation appears in the text (your author-name) and (2) how the whole reference gets formatted in the bibliography.
    I assume you have troubles getting (1) right. You can to do this simply in LyX > Document > Settings > Bibliography > Natbib (author-name). If you want “Author (2009)” instead of “(Author 2009)” or any other format you click on the citation, and you change Formatting > Citation style
    Hope this helps
    Petr

  • Ian

    Hi Petr.

    I have zotero LyZ setting to produce [author year title] bibtex keys.

    If I use in LyX: Document > Settings > Bibliography Default
    and for the bibliography style I choose style > unsrt then the PDF is produced with numbered citations and a numbered bibliography OK.

    If I use in LyX: Document > Settings > Bibliography natbib
    and for the bibliography style I choose style > unsrt
    some of the entries in body text of the PDf appear as (author?) [n] but appear in the bibliography OK

    If I try and use apacite latex warns the style is not compatible with natbib.

    If I try and use the plainnat style recommended by latex I get [author, year] citations in the text, and an alphabetical list in the bibliography, but not in APA style and with unwanted hyperlinks to citation sources that run right across the right margin.

    I’ve been messing around to try and solve the APA issue, and updated my miktex packages in the last hour or so. I also switched the document property from Book (AMS) to Book (Koma) and back – I don’t suppose that helped.

    There seems to be a style apalike that is for natbib but I don’t have it in my distribution – maybe I need to install that. Or maybe just stick to a basic style that is working – I can probably live without using APA (though I am planning to write a psychology book, so it would be nice…). I looked at how I set up JabRef in another project I’ve started working on a while back – there I just use the plain citation style and settings > bibliography> default. That gives numbered citations in the text and an alphabetical un-numbered bibliography, which thinking about it now I realise is useless.

    There are clearly things I need to understand better to use this effectively.

    Ian

  • Petr

    OK. I always use apalike2 with natbib, in miktex. I am not sure if it’s part of natbib, but as you say, mixtex has apalike style. That should work too.
    Hope that works
    Petr

  • David

    Thanks for LyZ!

    I’m just starting using LyZ and Zotero for the first time, but I’ve run into a problem. My university requires that for any website I reference, I add the date I accessed it into the bibliography, but LyZ doesn’t include the info in the bibtex file. I suppose it makes sense since bibtex doesn’t have a field for it, but I’ve got around that before by sticking the date accessed into the note field. Actually, with a customised bst file, I think it would be possible to create a new accessed field, but I’m not certain about that.

    To get down to my real question, could you include the date accessed in the output? Or give me some advice on how to do it myself if you don’t have the time?

    David

    • Petr

      Hi,
      Zotero’s field “Extra” is usually exported into bibtex’s note. So you can copy from accessed to extra to achieve what you need.
      Would this be a usable solution?
      Petr

  • David

    That does exactly what I want – thanks! But it would still be nice to automate it somehow. Most of my research is web based, so I need to copy it for each reference.

    I’ve just had a closer look at bibtex, and it seems that fields can be added to the bib file which will be used if the bst specifies them. So my suggestion is that the accessed date be written to a new “accessed” field in the bib file, which will then be there to be used by anyone willing to customize the bst.

    As I said, I’d be happy to try making the coding changes if you’d accept them upstream.

    David

  • Petr

    David,
    These changes would have to be done in Zotero’s sources (I am simply using Zotero’s Bibtex export routines) and that’s beyond my powers 😉 So try to submit a patch to Zotero developers.
    Petr

  • Tom

    Petr,

    I am getting a notice from Firefox with the latest updates >3.6 (on Mac OS Leopard – but I don’t think this makes a difference) that Lyz will no longer work. I don’t want to do the upgrade and risk being not able to use Lyz or go back to the previous version. Do you know what the go is here, any comments? Thanks for your help!

    • Petr

      Tom,
      not sure why the notice appears, but you should be able to upgrade safely. I have no way of testing it, but as long as Zotero works, LyZ should work too. Please let me know if you run into troubles.
      Petr

  • Manuel

    This addon is great!
    Thanks you very much

Leave a Reply to Roey Angel Cancel reply