Karakas Online

5.19.2. Bibliography with RefDB

You don't need to care about a bibliography.sgml file if you use RefDB - the lyxtox file will create it automatically with the help of RefDB, totally transparently to you. All you need is install and set up RefDB (see Section 3.11 and Section 4.13 respectively), and set the following variables in lyxtox:

Note that this name must contain a dot at the end, because lyxtox will create, the file ${REFDB_style}dsl.

Example: for REFDB_style="J.Biol.Chem.", lyxtox will automatically create (through RefDB) the file J.Biol.Chem.dsl, i.e. the “dsl” ending is appended without any extra dot. The default value is “J.Biol.Chem.”, one of the two standard styles shipped with RefDB, and should get you starting. See How to manage bibliography styles for more details on bibliography styles in RefDB.

The only thing that remains is... cite of course!

Citing with RefDB in LyX is a bit tricky, since LyX does not allow citing the way RefDB is expecting it: with a role attribute with the value “REFDB” in the SGML citation code. Of course, we could use a pure SGML environment as in Section 5.19.1 and write:

<para>
Consult <citation role="XXXX"><xref linkend="KARAKAS1992"></citation> 
for more details on neural learning rules.
</para>

each time we want to cite something. But there is a better way: RefDB can create that SGML code automatically, if it finds something like:

<para>
Consult <citation role="XXXX">"KARAKAS1992"</citation> 
for more details on neural learning rules.
</para>

in the SGML file. But how can we convince LyX to output something like the above for each citation when it exports our file to SGML?

The solution I found to this is:

  1. Export all the bibliographic entries you plan to use in a file, say refdb.ris (see Section 4.13 on how to do this).

  2. Use the awkscr_cit AWK script to create a new LyX file from refdb.ris:

    awkscr_cit refdb.ris > citlabels.lyx
    

    The citlabels.lyx file is a LyX file containing only labels, one for each bibliographic entry in refdb.ris. The labels have the prefix "cit:" to distinguish them from true labels. To stay with the above example, the bibliographic entry with ID “KARAKAS1992” will produce a label “cit:KARAKAS1992” in the citlabels.lyx file created by awkscr_cit.

  3. Open the citlabels.lyx file in LyX, together with your document.

  4. To cite an entry, you (mis)use the “Insert Cross-Reference” feature of LyX: from the LyX menu, choose “Insert -> Cross Reference”. In the upcoming dialog box there is a drop-down list field called “Buffer”. The Buffer serves as the source of the labels you want to reference. Usually, “Buffer” is set to the current file. You change this to “citlabels.lyx” by clicking on the dropdown field and choosing the citlabels.lyx file. Now you are presented with all labels of citlabels.lyx. Choose the label containing the ID of the RefDB bibliographic entry you want to cite. In our example, you choose “cit:KARAKAS1992”, if you want to cite the entry with ID “KARAKAS1992”.

That's all! Don't worry about that “cit:” prefix, sedscr takes care about it. For every cross-reference to a label of the form “cit:IDsome”, sedscr will create a citation of the form:

<citation role="REFDB">"IDsome"</citation>

in the exported SGML file. Then, lyxtox will call the aproppriate RefDB tools to transform this citation to

<citation role="REFDB"><xref linkend="IDsome"></citation>

or some more complex form according to the bibliographic style in use. Again, you don't have to worry about this procedure. Just create the citlabels.lyx file as shown above and insert cross-references to its labels in place of your citations. You don't have to bother about SGML code and you can't get the ID's wrong since you get a list of all available labels in citlabels.lyx to choose from. On the other hand, you can't get anything but “simple” citations this way, but at the moment I can live with that. See Section 7.1.10 for a detailed explanation of what lyxtox and RefDB do for you in the background to produce correctly formatted citations and a correctly formatted Reference List.

More elaborate solutions (using a citlabels.lyx file containing two or more labels for each bibliographic ID, each one with a different prefix, serving different citation purposes, "simple" or "complex" ones) are possible, but my hope is that this work will convince the LyX development team to incorporate RefDB directly in LyX in a future version. In the meantime, the method presented works fine - here and now.cool

Last updated Mon Sep 24 01:19:25 CEST 2007 Permalink: http://www.karakas-online.de/mySGML/lyx-bibliography-with-refdb.html All contents © 2002-2007 Chris Karakas