4

I want to learn to use biper and biblatex in Lyx. This is how I would do it in LaTeX traditionally with biblatex and biber

\documentclass[12pt,a4paper,oneside,pdftex]{report}
\usepackage[backend=biber]{biblatex}
\addbibresource{minCuts.bib}
...
\printbibliography
\end{document}

The error is apparently originating from the \bibliographystyle command and biblatex package getting mixed, by this. But I have no \bibliographystyle command in Preamble so they should not be mixed unless Lyx is somehow importing the \bibliographystyle.

How to resolve the biblioraphystyle error in Lyx with Biber and Biblatex?


Settings by the instructions here and Error

  1. Document > Settings > Bibliography > Biber

enter image description here

  1. In Document > Settings > LaTeX Preamble

enter image description here

  1. Insert > List / TOC > BibTeX Bibliography...

enter image description here

enter image description here

  1. Package biblatex Error : '\bibliographystyle' invalid.

enter image description here

6

When adding a BibTeX bibliography via Insert --> List/ToC --> BibTeX bibliography you need to put this into a comment (Insert --> Note --> Comment) or LyX note (Insert --> Note --> LyX note). If not, \bibliography and \bibliographystyle will be active in the generated LaTeX code and that is incompatible with biblatex. To quote the wiki page you refer to:

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.

(Emphasis mine.)

Note that it is not really required to insert the BibTeX bibliography, but it makes things much easier at it makes LyX aware of your .bib file, and you can therefore add citations via the GUI. If you don't do this I think you need to use TeX code boxes/ERTs (Ctrl/Cmd + L) and add e.g. \autocite{dude2015} as code.


So to quickly repeat the instructions from the wiki:

  1. In Document --> Settings --> LaTeX preamble add

    \usepackage[style=authoryear]{biblatex}
    \addbibresource{/path/to/bibfile.bib} 
    

    close the settings.

  2. Do Insert --> Note --> Comment followed by Insert --> List/ToC --> BibTeX bibliography. Find your .bib file.

  3. Move the cursor outside the Comment inset. Add a TeX code inset (Cmd/Ctrl + L) and write \printbibliography here.

    (A TeX code inset is often called an ERT, for "evil red text".)

It might look like

enter image description here

  • What is BibTeX inset? Is it \printbibliography with Insert>Note>Lyx note ---> CMD+L inside the note ----> \printbibliography inside the note and CMD+L environment (ERT env)? – hhh Mar 16 '16 at 14:28
  • @hhh It says in the text quoted what a BibTeX inset is ... It's what you get when you do Insert --> List/ToC --> BibTeX bibliograpy. Don't put the ERT with \printbibliography inside the note, that must be outside. – Torbjørn T. Mar 16 '16 at 14:33
1

Last error still remaining as highligted in the chat here: the citations not getting compiled, why? (Detected but not compiled)

Document > LaTeX Log: error revealed

enter image description here

enter image description here

and I added the bibliography through the GUI like this

enter image description here

where I selected the bib file.

Solution

Thanks to moeve, use absolute paths even though the bib file in the same folder as the Lyx file unless some special textmf folder.

enter image description here

Victory! References compiled with Biber, biblatex and Lyx.

enter image description here

\usepackage[backend=biber]{biblatex}
\newcommand*{\MyPath}{/Users/xyz/Desktop/YourPath}
\addbibresource{\MyPath/minCuts.bib}
\addbibresource{\MyPath/minCuts2.bib}
...

where by the below macro, you don't need to repeat yourself.

Big thank you to moewe and Torbjorn T.

  • 1
    If the citations are not resolved you can check the logs, especially the Biber log, you can find it under Document -> LaTeX log, choose BibTeX in the drop-down menu (see tex.stackexchange.com/q/15179/35864). Have a look at point 4 in wiki.lyx.org/BibTeX/Biblatex, you cannot use relative paths, the .bib file must either reside in the texmf tree or it the path must be given in full. – moewe Mar 16 '16 at 14:45
  • 1
    It doesn't matter how you added the .bib file in the LyX database GUI. The GUI approach is just for LyX's GUI citation features. As the Wiki clearly states in point 4 the .bib file given in \addbibresource must either reside in a texmf folder or the path must be given in full. – moewe Mar 16 '16 at 15:06
  • 1
    With LyX it is not enough to have the .bib file in the same folder (this is contrary to normal LaTeX where it usually is enough). See here for an explanation of local texmf. But you can always just give the entire path to your .bib file and you will be sorted. – moewe Mar 16 '16 at 15:09
  • 1
    You will find that your reference reads "John Wiley & Sons", you should check your .bib file, a correct input would be publisher = {John Wiley \& Sons}. – moewe Mar 16 '16 at 15:13
  • 1
    LyX 2.2 will have BIBINPUTS path set to the local directory, and BibLaTeX/biber will work without specifying the absolute path. There's a hack in point 4 of the wiki page, it's been applied in the "two simple examples" on the same page. – PhilipPirrip Mar 16 '16 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.