2

I'm making a document that has a bibliography at the end of each section and a global bibliography at the end. Logically, the bibliography at the end of each section should only contain citations that were referenced in that section. The global bibliography should contain every reference that is cited throughout the document. This is my code:

\documentclass[10pt]{article}

\usepackage{bibentry}
\usepackage[sectionbib]{chapterbib}
\usepackage{natbib}

\begin{document}

\bibliographystyle{plainnat}

\begin{cbunit}
\section{something}
First discuss \cite{goossens93}.

\bibliographystyle{plainnat}
\bibliography{mwecitations}
\end{cbunit}


\begin{cbunit}
\section{something else}
Now discuss \cite{rothstein2011unemployment} and \cite{fujita2010economic}.

\bibliographystyle{plainnat}
\bibliography{mwecitations}
\end{cbunit}


\renewcommand{\refname}{Global bibliography}
\bibliography{mwecitations}

\end{document}

This outputs:

Output document from this MWE

The citations file mwecitations.bib is:

@book{goossens93,
    author = "Frank Mittelbach and Michel Goossens  and Johannes Braams and David Carlisle  and Chris Rowley",
    title = "The {LaTeX} Companion",
    year = "1993",
    publisher = "Addison-Wesley",
    address = "Reading, Massachusetts"
}
@article{fujita2010economic,
  title={Economic effects of the unemployment insurance benefit},
  author={Fujita, Shigeru},
  journal={FRB Phil. Business Review},
  volume={4},
  year={2010}
}
@article{rothstein2011unemployment,
  title={Unemployment insurance and job search in the {Great Recession}},
  author={Rothstein, Jesse},
  journal={NBER},
  volume={w17534},
  year={2011}
}

Why are all citations from the entire document included in the bibliography that follows each section? The document should look like this (pardon my less-than-elegant edits).

Desired output from this MWE

I compile these files with Xelatex and Biblatex. From the documentation, I think I'm using cbunit correctly.

Michael A
  • 1,525
  • 2
  • 11
  • 16
  • Imho to get this working chapterbib would need separate files that you \include. You could try bibunits instead, but I would suggest to use biblatex/biber. – Ulrike Fischer Sep 01 '17 at 19:16
  • @UlrikeFischer My interpretation of the documentation is that separate files aren't strictly necessary. From point 3: "Without \include: If you can’t use \include ... , then you can use \begin{cbunit} ... \end{cbunit} (for everything in one file)." Am I interpreting this incorrectly? – Michael A Sep 01 '17 at 19:26
  • Imho the documenation is either wrong or misleading. But why don't you want to use biblatex? It is much more powerful, and such things work with refsegments directly. – Ulrike Fischer Sep 01 '17 at 20:17
  • I just checked a work I have done with separate bibliography... I had to run bibtex in every chapter before runing in the main document. Checked that otherwise doesn't work. I will check it with your code too... may be the chaprers(sections) have to be seperated and just one bib file to be ok – koleygr Sep 01 '17 at 20:35
  • @UlrikeFischer Sorry, I misread your first comment. You're saying that I could just use biblatex/biber/natbib together instead of chapterbib? I have no problems with that solution; I'm just not familiar with how biber works, but I'll look into it. – Michael A Sep 01 '17 at 20:35
  • Don't use natbib with biblatex. – Ulrike Fischer Sep 01 '17 at 20:36
  • Possible duplicate: https://tex.stackexchange.com/a/300144. Note how to combine 'natbib' with 'chapterbib'. – Ross Sep 02 '17 at 04:54
  • @UlrikeFischer I may have to ask another question about biblatex/biber/bibunits. Even the simple examples from the documentation for bibunits don't work for me (the inline citations are blank). It's quite frustrating! – Michael A Sep 02 '17 at 17:14
  • Don't use biblatex together with bibunits. Beside this "don't work" is not a good problem description. Make a new question, show the example you are trying and describe exactly all the compilation steps you are doing. – Ulrike Fischer Sep 02 '17 at 17:46
  • @UlrikeFischer Done. – Michael A Sep 02 '17 at 18:15

1 Answers1

1

Sorry, cbunit grouping doesn't facilitate using bibtex; it is only useful for manually compiled bibliographies. The documentation is rather cryptic on the point, but hints at it.

To use bibtex and have no page breaks between the bib groupings, you should use \cbinput, with with groupings in separate files. Be sure to run it according to the instructions (item 3): use the [draft] option (package or document); run latex; run bibtex on each file that was \cbinput; remove the [draft] option and run latex.

The [draft] option basically uses \include instead of \input so that separate .aux files get generated for bibtex to use.