9

I am writing a collaborative document in which each author edits a main.tex file and provides a <author>.bib file (no \include, no \input ... I know it's not the ideal choice but it was not my decision).

What we are having issues with is that we can't manage to have multiple bibliographies at the end of each chapter (chapterbib requires to use \include, it mention something in the manual to have a single file, but it is not very clear to me how to do it)

A minimal example is like this:

% main.tex
\documentclass[a4paper,11pt,oneside,openright]{book}
\usepackage{natbib}
\usepackage{chapterbib}

\begin{document}
\chapter{Author 1}
\section{author 1 section}
..something
\addcontentsline{toc}{section}{\bibname}
\bibliographystyle{unsrtnat}
\pagestyle{plain}
\bibliography{author_1}

\chapter{Author 2}
\section{author 2 section}
..something
\addcontentsline{toc}{section}{\bibname}
\bibliographystyle{unsrtnat}
\pagestyle{plain}
\bibliography{author_2}

\end{document}

author_1.bib

@article{lagrange1772essai,
  title={Essai sur le probleme des trois corps},
  author={Lagrange, J.L.},
  journal={{\OE}uvres},
  volume={6},
  pages={229--324},
  year={1772}
}

author_2.bib

@article{euler1741solutio,
  title={Solutio problematis ad geometriam situs pertinentis},
  author={Euler, L.},
  journal={Commentarii academiae scientiarum Petropolitanae},
  volume={8},
  pages={128--140},
  year={1741}
}

It might happen that author_1.bib and author_2.bib contain the same reference (with the same id key probably).

Any hint how to do that?

lockstep
  • 250,273

1 Answers1

14

The answer is pretty straightforward when using the biblatex package. It is somehow compatible with natbib, but if you can ditch it all together, it is even better.

With biblatex you can list different bib files to your latex document and assign them to specific section considered for the separate bibliographies (refsections in biblatex terms) with \addbibresource[]{}

\documentclass[a4paper,11pt,oneside,openright]{book}
\usepackage{biblatex}
\addbibresource{author_1}
\addbibresource{author_2}
\begin{document}
\chapter{author 1 section}
\begin{refsection}[author_1]
...
\printbibliography[heading=subbibliography]
\end{refsection}
\chapter{author 2 section}
\begin{refsection}[author_2]
...
\printbibliography[heading=subbibliography]
\end{refsection}
\end{document}

I advise you to read the full doc of biblatex, you can also automatically affect refsection to chapter, part, or section, without having to specify the environment.

Martigan
  • 3,146
  • Damn, you were faster with very same idea:) Why didn't you put \chapter inside refsection? – Crowley Nov 22 '12 at 14:00
  • Hi,thanks for the answer but I get the error "! LaTeX Error: File `logreq.sty' not found." when using the biblatex package.. – lucacerone Nov 22 '12 at 14:30
  • What is your LaTeX distribution and what backend do you use? I've tried it with MikTeX 2.9 full and biber. – Crowley Nov 22 '12 at 14:39
  • I use texlive shipping with Ubuntu and have no idea what a backend is :) – lucacerone Nov 22 '12 at 14:58
  • Firstly, what is the version of your Ubuntu. Secondly, BibLaTeX backend is program that creates your citation list. It is BibTeX or biber. When using BibLaTeX you compile your .tex file with (pdf)latex and then you compile it with backend to create citation database which is used in next latex run. – Crowley Nov 22 '12 at 15:10
  • Hi, sorry it is Ubuntu 12.04 and I use bibtex. So how should I compile the document? Also I have a doubt, I activated the natbib=true option for the package (we have loads of \citeauthor and \citep in the document). Should I keep the \usepackage[options]{natbib} or remove it? Thanks for the help! – lucacerone Nov 22 '12 at 15:49
  • Try not loading natbib via \usepackage. in manual it is said, that natbib is incompatible with BibLaTeX. I understood it that option natbib=true emulates natbib package. For logreq.sty, try to find it in package administrator (i don't know the exact tool and I'm kinda lazy to reboot to Ubuntu) – Crowley Nov 22 '12 at 16:07