Go to page:

Search:   Help



LyX documentation


Shared groups



Categories: Bibliography, Biblatex
<< | Page list | >>

How to use biblatex with LyX (or How to fool biblatex and LyX in order to let them cooperate)

What is biblatex?

It follows a completely new approach insofar as biblatex reimplements almost everything on the LaTeX side. It originally used bibtex for for pre-processing but now biber is the preferred pre-processor for biblatex. Please refer to this page for more information.

Using biblatex with LyX

LyX doesn't provide native support for biblatex yet. However, it is possible to use it with some effort, as described here. Note that you will need at least version 0.7 of biblatex.

Note that the first step is only necessary if you want to use an author-year style (and thus need the different citations styles that are provided in the citation dialog).

  1. Create a version of your LyX layout file with biblatex support (which means: you can use the "styles" in the citation dialog, without loading natbib or jurabib, which would clash with biblatex). This is done as follows:
    • With LyX 1.6.0 and newer:
      • Put the file biblatex.module in the layouts folder in your user directory (Help→About LyX tells you where you can find this directory; in the latest versions of OSX the correct layouts folder is in the applications folder).
      • Run Tools→Reconfigure, restart LyX and select the module "Biblatex-citation-styles" from Document→Settings→Modules.
    • With older versions of LyX:
      • Create a new layout file in your user directory (Help→About LyX tells you where you can find this directory). Let's say, for example, that you want to use the article class with biblatex. Create a new file "bblarticle.layout" with the following content:
      #% Do not delete the line below; configure depends on this
      #  \DeclareLaTeXClass[article]{article (with biblatex)}
      Format 4
      # Load the article class
      Input article.layout
      # this is biblatex actually
      Provides natbib	1
      • Run Edit→Reconfigure, restart LyX and select the class "article (with biblatex)" from Document→Settings→Class.
      • If you use another class than article, replace "article" with the name of your class both in the file name and in the file itself (all occurences).
  2. In the document preamble (Document→Settings→LaTeX Preamble), load biblatex manually. If you want to use an author-year style (and thus use the above module/layout addition), you have to use the package option "natbib=true". So, for instance:
    For a numeric or alpha-numeric style, you just need something like:
    For the backend option, see below the section on using biber. Please refer to the biblatex documentation for further options.
    Note: If you use XeTeX with the polyglossia language package, you will need to manually load the polyglossia package in the preamble just before the above call to biblatex, and set the default language, as follows:

    Otherwise, you'll get LaTeX errors of the following kind:
    ! Undefined control sequence.
    <argument> blx@lng@\bbl@main@language
  3. Load your bibliography database in the preamble:
    \addbibresource{<name of bib-file with .bib-extension>}
    (you might also use the deprectaed command \bibliography{<name of bib-file without .bib-extension>})
    • Note that the bib file must either be located in your texmf tree, or you must enter an absolute path in the command above (e.g. \addbibresource{/Users/me/Documents/bibdesk/Dissertation.bib} on the Mac, \addbibresource{/home/myname/documents/dissertation/Dissertation.bib} on Linux, \addbibresource{C:/Documents and Settings/My Name/Documents/Dissertation/Dissertation.bib} on Windows). If you put the file in the texmf tree, do not forget to run "texhash" in the terminal to tell LaTeX where to find the new file unless you put it in your personal directory.
    • Multiple databases must be loaded by multiple \addbibresource commands (or separated by commas, if you use the deprecated \bibliography command instead).
  4. In the document, insert the BibTeX inset (Insert→List/TOC→BibTeX Bibliography... ) in a LyX note or comment, such that LyX finds the citations, but no \bibliography command is output to LaTeX. It does not matter which style you chose here, so you can stick with "plain". However, in order to use the citation dialog, you'll have to choose the correct databases (i.e. those you loaded above in item (3)).
  5. In the document, enter \printbibliography in ERT (TeX mode) at the point in the text where the bibliography is to occur.

Using biber (or bibtex8) instead of bibtex

The biblatex manual strongly advises to use biber or at least bibtex8 instead of the traditional bibtex to process the data, because the capacities of traditional bibtex are too limited for biblatex, which needs a lot of resources. Indeed, the best choice is biber, a bibliography processor written in Perl and specifically designed for biblatex as a bibtex replacement. Biber has no resource limits, it can deal with unicode any many other encodings, and it provides some extra hooks that allow biblatex to perform some complex tasks. Even though biblatex still can be used with bibtex8 and even traditional bibtex, some complex things only work with biber. So unless you have strong reasons, you should really use biber when using biblatex.

If you want to use biblatex with classic bibtex nonetheless, you must pass the option backend=bibtex to the \usepackage[...]{biblatex} command (see previous section).

To change from bibtex to biber, go to LyX→Preferences→Settings→Output→LaTeX and change the bibtex command from bibtex to biber (you can also input biber options, if you need them). Also note that you should pass the option backend=biber (instead of backend=bibtex) to the \usepackage[...]{biblatex} call if you use biber, although this is not strictly necessary anymore in recent biblatex releases which default to biber if you do not pass the backend option at all.

To change from bibtex to bibtex8 instead, go to LyX→Preferences→Settings→Output→LaTeX and change the bibtex command from bibtex to bibtex8 --wolfgang --csfile latin9.csf or something similar. Please refer to the biblatex manual, section 2.4.2 (BibTeX capacity issues) for further explanations on the --wolfgang switch, and to section 2.4.3 (BibTeX sorting and encoding issues) for explanations on the --csfile switch, which need to be adapted to your bib file encoding. Also note that you will need to pass the option backend=bibtex8 (instead of backend=bibtex) to the \usepackage[...]{biblatex} call if you use bibtex8.

Known problems

  • If biber doesn't work or stops working suddenly (with or without an error being reported) resulting in the failure of citations and / or bibliography, you may get it going (again) by following the instructions from this blog post or this stackexchange entry.
    In short, you need to delete an invalid temporary cache folder which irritates biber. You can find out the par cache by checking either by inserting biber --cache in a terminal window or by inspecting Document→LaTeX Log→BibTeX (watch out for an error message looking like this: data source /some/path/par-<some number>/cache-<some number>/[...]/recode_data.xml not found; the folder to delete is the one starting with cache-).
  • Recent biber versions only work with LyX 1.6.10 and LyX 2.0 onwards. Older versions of LyX will not start biber, since it uses different auxiliary files which are not recognized by these versions of LyX.
    If biber is not started with those recent versions of LyX, try if \typeout{File: \jobname.bcf} in your preamble solves this issue. See this thread and in particular this and this post for details.

Further information

Bibliography Biblatex

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2015-04-22 09:37 CEST