I am writing my thesis in LyX. It's a collection with 3 separate .bib files with jab ref. I inserted the three bib file in three different places. But the pdf output seem to only use the first bib file at all three different places.
I can merge the bib file into one. I am just curious if there is a way to avoid doing that.
2 Answers
This assumes you have already set up your LyX document to use biblatex (with Biber). Please see the LyX wiki for more.
In short you will have to have
- Biber set up (No Bibliography is printed and citations shown bibtex key) via "Document→Settings→Bibliography" or "Tools→Preferences→Output→LaTeX"
Call
biblatexin the preamble. Go to "Document→Settings→LaTeX Preamble" and loadbiblatexwith all the needed options\usepackage[style=authoryear,backend=biber,refsection=section]{biblatex}for example
Add your
.bibfile to the preamble. Go to "Document→Settings→LaTeX Preamble" and add a call to\addbibresource{full/path/of/your/bib/file}. Note that you will have to give an absolute path, relative paths are only supported for files in the local texmf tree.If you want a per-chapter bibliography, all you need to do is to add the
refsectionoption to thebiblatexcall in "Document→Settings→LaTeX Preamble".Insert a BibTeX bibliography "Insert→List/TOC→BibTeX Bibliography..." in a note (see BibLaTex, Biber and Lyx: how to resolve \bibliographystyle error?), but still using the correct database. This is to make sure that LyX finds the citations.
Add
\printbibliographyin an ERT block.
If you want a per-section bibliography, call biblatex in the preamble with
\usepackage[style=authoryear,backend=biber,refsection=section]{biblatex}
The document then is straightforward. Each section will be in its own refsection.
You will need one \printbibliography in the ERT block for each chapter
gives
Manual refsections are as easy as well. You just need to make sure to not call biblatex with anything other than refsection=none (not giving the argument is equivalent to refsection=none), that is important since refsections cannot be nested.
You will just have to insert \newrefsection and \begin{refsection}...\end{refsection}in ERT blocks in the appropriate places.
gives
-
Thanks a lot for the detailed answer. I did every step. But there still seem to be some errors. It says package biblatex error: nested refsection environment. I used \begin{refsection} at the beginning of chapter one,ended that refsection at the end of chapter one. and used \newrefsection at chapter 2. – Yan Song Mar 11 '16 at 18:21
-
1@YanSong If you use
refsection=sectionas in the first example there is no need for manual refsections. Everything will be done per\section(or\chapterif you chooserefsection=chapter.) Otherwise I would need to see what you are doing. You can't have\begin{refsection}\newrefsection\end{refsection}. – moewe Mar 11 '16 at 18:33 -
Ok. I figured out what's wrong. Since I used refsection in the preamble, I don't need to manually set it again. I removed the begin refsection and the document is compiling. But the output pdf does not have any citations shown at all now. – Yan Song Mar 11 '16 at 18:34
-
@YanSong Can you compile a normal
biblatexexample without problems, i.e. is LyX set up correctly to deal withbiblatexand Biber? – moewe Mar 11 '16 at 18:37 -
-
I checked everything. I chose biber as generator, added \usepackage[style=authoryear,backend=biber,refsection=section]{biblatex}, and \addbibresource{full/path/of/mybib/file}, added the bib file in a note and put printbibliography in an ERT block. I ran out of idea where could possibly go wrong. – Yan Song Mar 11 '16 at 19:28
-
I normally wouldn't ask for extra help after reading such detailed answer. But I already spend a day on this. And I still could not figure out what's wrong. Is it possible for you to take a look at the files? – Yan Song Mar 11 '16 at 19:33
-
@YanSong Please check the detailed description in the LYX wiki again https://wiki.lyx.org/BibTeX/Biblatex Read also http://tex.stackexchange.com/q/286706/35864 (some of the point ins the answer don't apply to you because you use LyX, but other points are still valid). Try to get the log for the minimal example run "Document -> LaTeX log" on the top you can choose between the LaTeX and BibTeX log, check both carefully, the BibTeX/BIber log is more interesting. You can also try to run a minimal example not from LyX but with TeX directly. – moewe Mar 12 '16 at 06:41
-
I am able to compile the file now. The only problem is the citation is shown but the bibliography is not shown. I checked the logs and found two types of error message. The first one is in bibtex WARN - Invalid or undefined BibTeX entry key in file 'C:\Users\KPRINC~1\AppData\Local\Temp\yNpW4oambX\ref_all.bib_7896.utf8', skipping ... The second type is LaTeX Warning: Citation 'Yip2008' on page 16 undefined on input line 261. I used absolute path for the bib file in the latex preamble. I am not sure why lyx could not locate the file. – Yan Song Mar 14 '16 at 21:08
You can add all three files in the one place. In the dialogue box just keep clicking on the "add" button, even though there's one already there. But then you get a single bibliography typeset into your document. Is that what you want? Having three different bibliography sections might be more complicated.
- 1,263
-
I was hoping to get three different bibliography sections. This is a essay based thesis so it makes more sense to have a reference section for each paper. – Yan Song Mar 11 '16 at 15:33




;-). Have you read the links in my comment there? Can you answer the questions in the comment (i.e. do you want to usebiblatex, etc.)? – moewe Mar 11 '16 at 16:17\refsections? Are you prepared to usebiblatexas your tag suggests? – moewe Mar 11 '16 at 16:22biblatexin your document (see https://wiki.lyx.org/BibTeX/Biblatex). I will write an answer shortly. – moewe Mar 11 '16 at 16:45