15

What I want is the following:
I have a tex file with several \sections, each with their own bibliography at the end and their own bib file. In every section several entries of the bib file are \cited BUT I also show all local bibliography entries at the end of each section.
At the end of the file is a global bibliography that shows all entries of all local bibliographies.

I already tried different packages, e.g. bibunitsand chapterbib (Link to both can be found here). The problem is not to generate multiple bibliographies in one document, but the labeling.

The label of a local bibliography entry has to be the same as the one in the global bibliography. The packages I tried do show me local and global bibliographies, but use different labels. The last part is puzzling to me, because the bibunits documentation talks about an option labelstoglobalaux that should do just that.
As a sidenote, I use a modified plainnat.bst with alpha.bst labels, i.e. entries are labeled with initial of author name and year and entries with the same author and year get an character added to the label. (In the MWE I use alpha.bst) I do not want numbered labels.

This is my MWE with the bibunit package:

\documentclass{article}  
\usepackage[utf8]{inputenc} % Umlaut etc.  
\usepackage{amssymb}  
\usepackage{hyperref} % Link  
\usepackage[labelstoglobalaux,globalcitecopy]{bibunits} % seperate bibliographies  

\begin{document}  
\nocite{*} % to cite global bibliography

% local bibliographies
\begin{bibunit}[alpha]
\nocite{*}
\putbib[biblio-test1]
\end{bibunit}

\begin{bibunit}[alpha]
\nocite{*}
\putbib[biblio-test2]
\end{bibunit}

% global bibliography
\bibliographystyle{alpha}
\bibliography{biblio-test_all}

\end{document}

and the three bib files

biblio-test1:

@phdthesis{222,
    author = {Author, Frank},
    title = {{A long title: Number 2}},
    school = {University T},
    year = {2011},
    pages = {III, 193},
    type={Dissertation},
    }

@phdthesis{333,
    author = {Author, Frank},
    title = {{A long title: number 3}},
    school = {University T},
    year = {2011},
    pages = {93},
    type={Dissertation},
    }

@inproceedings{123,
    author = {Bauthor, Bauth and Cauthor, Cauth},
    title = {{This is the title}},
    series = {A lovely series},
    volume = {109},
    booktitle = {A Long booktitel},
    editor = {Editor, Ed and Beditor, Bed},
    publisher = {Big Publisher},
    address = {City},
    year = {2010},
    pages = {746--851},
    }

biblio-test2:

@book{573,
    author = {Name, N.},
    title = {{An introduction to something interesting}},
    pages = {9},
    publisher = {Big important company},
    address = {Hillcity},
    year = {2005},
    series = {Lecture notes},
    volume = {27/2005},
    url = {http://www.google.com/doodles/},
    }


@phdthesis{222,
    author = {Author, Frank},
    title = {{A long title: Number 2}},
    school = {University T},
    year = {2011},
    pages = {III, 193},
    type={Dissertation},
    }

@phdthesis{111,
    author = {Author, Frank},
    title = {{A long title: Number 1}},
    school = {University T},
    year = {2011},
    pages = {978},
    type={Dissertation},
    }

@phdthesis{233,
    author = {Author, Frank},
    title = {{Some other title}},
    school = {University T},
    year = {2009},
    pages = {3},
    type={Dissertation},
    }

biblio-test_all contains entries of biblio-test1 and biblio-test2 without additional entries.

What I get in the end: Three bibliographies with local labels each, e.g. entry222 is in one bibliograhy [Aut11a] in another [Aut11b].

Help, or ideas will be much appreciated!

EDIT 1: I compile

  • latex biblio-test
  • bibtex biblio-test (to get the global bibliographie)
  • bibtex bu1
  • bibtex bu2
  • latex biblio-test
  • latex biblio-test

EDIT 2: I have several bib files, because the bib files are generated for every \section through a program and have up to one hundred entries each.
I could put them in one files and call every section bibliography using \nocite{...} and I could then write a script that copies every section bibliography entry into \nocite. However, I tried using only one bib file and call those entries I need with \nocite*{...}. But: The labeling is still not global*. So until now, I haven't found a reason not to use seperate files.

*When I then cite entries in a bibunit, the global label is used in the citation, but the local one is used in the bibliography.

3
  • Welcome to TeX.SE! Thanks for posting a detailed MWE. Quick question: Why do you have separate bib files for each sectioning unit? By forcing BibTeX to deal with several bib files, it can't figure out that some of the entries in the various bib files are repeated.
    – Mico
    Mar 29, 2012 at 13:35
  • Thanks for the welcome! Answered question in entry, because I thought it would be important for all.
    – JJB
    Mar 29, 2012 at 15:12
  • Would you also work with biblatex? Apr 9, 2012 at 9:25

2 Answers 2

10

Here's a biblatex solution that satisfies your main requirement -- a combination of local bibliographies and a global one, with congruent local/global entry labels. However, instead of individual .bib files for each section I use a global file including special keywords fields to indicate an entry's affiliation with one or several sections.

\documentclass{article}

\usepackage[style=alphabetic]{biblatex}

\defbibheading{subbibforsec}[\refname\ for section~\thesection]{%
    \subsection*{#1}}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
  keywords = {foo,bar},
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@misc{B02x,
  keywords = {foo},
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
@misc{B02y,
  keywords = {bar},
  author = {Buthor, B.},
  year = {2002},
  title = {Bravissimo},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\nocite{*}

\begin{document}

\section{Foo}

Some text \autocite{B02x}.

\printbibliography[heading=subbibforsec,keyword=foo]

\section{Bar}

Some text \autocite{B02y}.

\printbibliography[heading=subbibforsec,keyword=bar]

\printbibliography

\end{document}

enter image description here

1
  • 1
    biblatex improved since the time of this anwer. See an easier solution below.
    – ebosi
    Sep 9, 2017 at 21:38
7

biblatex improved since lockstep wrote their answer. Here is another solution that doesn't requires you to modify your .bib file.


Short answer

Create a refsegment for each part of you document you want a separate bibliography of. Then, \printbibliography and restrict it to the relevant segment using the [segment=<# of the relevant segment>] option. Omit the [segment=<#>] option to print the full bibliography. Using refsegments instead of refsection ensure you to have consistent/unique labels across the various parts of your document.

To create refsegments, use either \begin{refsegment}...\end{refsegment}, \newrefsegment (that ends previous segment (if needed) and start a new one), or biblatex's refsegment=<part/chapter/section/subsection> global option (which inputs a \newrefsegment every part/chapter/...). See MWE below.


Long answer

Instead of using refsections (as shown in most examples on TeX.SE), the 'trick' is to use refsegments. They are intended exactly for this purpose. Indeed, as explained in biblatex documentation (§3.7.5 Bibliography Segments - bold added):

The difference between a refsection and a refsegment environment is that the former creates labels which are local to the environment whereas the latter provides a target for the segment filter of \printbibliography without affecting the labels. They will be unique across the entire document.

(In other words: it does automatically what lockstep was doing manually)

How to create refsegments?

To create refsegments, you have three solutions:

  • Delimit the relevant part using a refsegment environment (\begin{refsegment}...\end{refsegment}),
  • (If needed: end the previous segment and) Start a new segment with \newrefsegment,
  • or automatically start a new refsegment for each part/chapter/section/subsection using biblatex's refsegment global option (\usepackage[refsegment=]{biblatex}).

How to print a local bibliography?

To print a local bibliography, you should use the segment=<#> option, where # represent the current number of the segment (0 if no segment has already been started, 1 after the first \newrefsegment, 2 after the second, etc. ... or \therefsegment to print current refsegment):

\printbibliography[segment=1]

How to print a global bibliography?

You just have to omit the segment=<#> option (i.e. simply \printbibliography).


MWE

enter image description here

\documentclass{article}

    \usepackage[%
        style=alphabetic,
        refsegment=section,%<-- starts a new refsegment at each \section
    ]{biblatex}
        \defbibheading{subbibforsec}[\refname\ for section~\thesection]{\subsection*{#1}}

    \usepackage{filecontents}
        \begin{filecontents}{\jobname.bib}
            @misc{A01,
              author = {Author, A.},
              year = {2001},
              title = {Alpha},
            }
            @misc{B02x,
              author = {Buthor, B.},
              year = {2002},
              title = {Bravo},
            }
            @misc{B02y,
              author = {Buthor, B.},
              year = {2002},
              title = {Bravissimo},
            }
        \end{filecontents}
        \addbibresource{\jobname.bib}

\begin{document}
    \section{Foo}
        Some text \cite{A01,B02x}.
        \printbibliography[%
            heading=subbibforsec,
            segment=\therefsegment,%<-- restrict the bibliography to the current segment
        ]

    \section{Bar}
        Some text \cite{B02y}.
        \printbibliography[%
            heading=subbibforsec,
            segment=2,%<-- restrict the bibliography to the current segment
        ]

    \printbibliography
\end{document}
2
  • 3
    You can use \therefsegment to access the number of the current refsegment. So you can use \printbibliography[heading=subbibforsec, segment=\therefsegment] instead of giving the number explicitly.
    – moewe
    Sep 11, 2017 at 11:20
  • @moewe thanks. It seems I was too lazy to look for the automated version of it, but your solution is indeed much more graceful.
    – ebosi
    Sep 11, 2017 at 20:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .