# BibLaTex, Biber and Lyx: how to resolve \bibliographystyle error?

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}
...
\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

1. In Document > Settings > LaTeX Preamble

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

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

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}


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

• 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

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

and I added the bibliography through the GUI like this

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.

Victory! References compiled with Biber, biblatex and Lyx.

\usepackage[backend=biber]{biblatex}
\newcommand*{\MyPath}{/Users/xyz/Desktop/YourPath}

• 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
• 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
• 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
• You will find that your reference reads "John Wiley &amp; Sons", you should check your .bib file, a correct input would be publisher = {John Wiley \& Sons}. – moewe Mar 16 '16 at 15:13