[Tex/LaTex] Sectioning bibliography by type of referred item

biblatexbibliographiesbibtexsortingsubdividing

My promoteur has a very unusual requirement: the bibliography needs to be sorted first by specific type of referred item, next by author and by year of publication.

I managed to get this custom sorting done by using makebst and manually editing the .bst, but now there is even greater problem for me: the bibliography itself must be sectioned, so it should look something like this:


Sources

Aahn, A. 2008, whatever dude

Aahn, A. 2009, whatever dude, really

Dictionaries

Encyclopeadia of everythinga, 1999

Wikipaedia, 2000-today

Articles

Aahn, B. and Boss, C., 1889 This issue is not to our concern, good man

Other Materia

Bactera, E.C., 1987, How we totally not-wiped the whole earth.


Can this be done automagically with bibtex? Or do I have to edit the generated file manually?

Best Answer

There are several ways to have separate bibliographies by type of items cited. I'll describe here some of them, namely:

BibTeX

There are several, more or less complicated solutions to separate bibliographies by type with bibtex, but that's not "automagicly" at all...

Using splitbib

You can do that with the splitbib package, you have to define a bibliographic category and manually add the corresponding itens to it, something like this:

\begin{category}[A]{First category}
\SBentries{entry1,entry4}
\end{category}

Here's a MWE:

\documentclass{article}
\usepackage{splitbib}
\begin{category}[A]{First category}
  \SBentries{article-minimal,article-full}
\end{category}
\begin{category}[B]{Second category}
  \SBentries{book-minimal,book-full}
\end{category}
\begin{document}
\cite{article-minimal,article-full,book-minimal,book-full}
\bibliography{xampl.bib}
\bibliographystyle{plain}
\end{document}

splitbib example

Check splitbib documentation for more details.

Using bibtopic

As with splitbib, bibtopic aims at other possible usages besides separate bibliographies by type.

Since it requires separate databases for each bibliography section, it is more indicated when you already them as such (i.e., separate .bib files for each kind of item).

The usage is basically, e.g.:

\begin{btSect}{books}
\section{References from books}
\btPrintCited     % for cited references
\btPrintNotCited  % for references not cited
\end{btSect}

Here's a MWE:

\documentclass{article}
\usepackage{bibtopic}
\begin{filecontents}{books.bib}
@BOOK{book-minimal,
   author = {Donald E. Knuth},
   title = {Seminumerical Algorithms},
   publisher = {Addison-Wesley},
   year = {1981},
}
@BOOK{book-full,
   author = {Donald E. Knuth},
   title = {Seminumerical Algorithms},
   volume = 2,
   series = {The Art of Computer Programming},
   publisher = {Addison-Wesley},
   address = {Reading, Massachusetts},
   edition = {Second},
   month = {10~} # jan,
   year = {1981},
}
\end{filecontents}
\begin{filecontents}{articles.bib}
@ARTICLE{article-minimal,
   author = {L[eslie] A. Aamport},
   title = {The Gnats and Gnus Document Preparation System},
   journal = {\mbox{G-Animal's} Journal},
   year = 1986,
}
@ARTICLE{article-full,
   author = {L[eslie] A. Aamport},
   title = {The Gnats and Gnus Document Preparation System},
   journal = {\mbox{G-Animal's} Journal},
   year = 1986,
   volume = 41,
   number = 7,
   pages = {73+},
   month = jul,
   note = {This is a full ARTICLE entry},
}
@ARTICLE{article-notcited,
   author = {L[eslie] A. Aamport},
   title = {The Gnus and Gnats Document Preparation System},
   pages = "73+",
   journal = {\mbox{G-Animal's} Journal},
   year = 1987,
   volume = 42,
   number = 8,
   month = jul,
}
\end{filecontents}
\begin{document}
\bibliographystyle{alpha}
\section{Testing}
Let’s cite all the books: \cite{book-minimal,book-full}; and articles:
\cite{article-minimal,article-full}.
\begin{btSect}{books}
\section{References from books}
\btPrintCited
\end{btSect}
\begin{btSect}[plain]{articles}
\section{References from articles}
\btPrintCited
\section{Articles not cited}
\btPrintNotCited
\end{btSect}
\end{document}

bibtopic example

Notice that bibtopic requires a bibtex pass for each section, so you should compile it with

latex <file>
bibtex <file>1
bibtex <file>2
...
bibtex <file>n
latex <file>
latex <file>

Check bibtopic documentation for more details.

Using multibib

As with splitbib, and bibtopic, multibib aims at other possible usages besides separate bibliographies by type.

It does not require separate databases, but it creates a special citation command for each type of item you define in the preamble.

The basic usage is to create a new citation type in the preamble with:

\newcites{mytype}{A Header for your special bibliographic type(s)}

And then cite the entries that should be considered in the new type with a \cite<newcites-arg> command, e.g. \citemytype.

Here's a MWE:

\documentclass{article}
\usepackage{multibib}
\newcites{book}{Books}
\begin{document}
\citebook{book-full,book-minimal}

\cite{article-minimal,article-full}
\bibliographystylebook{alpha}
\bibliographybook{xampl}
\renewcommand{\refname}{Other References}
\bibliographystyle{plain}
\bibliography{xampl}
\end{document}

multibib example

Notice that (as with bibtopic) it requires special bibtex passes:

latex <file>
bibtex <file>
bibtex <mytype>
latex <file>
latex <file>

Check multibibdocumentation for more details.

Using biblatex

You can do this quite "automagicly" with the biblatex package! The usage is as simple as:

\printbibliography[type=book]
\printbibliography[type=collection]
\printbibliography[type=thesis]

or by adding a keywords field to your bib entry, and splitting it the bibliography with

\printbibliography[keyword=keyword1]
\printbibliography[keyword=keyword2]

or by creating categories like with the splitbib package, with something like

\DeclareBibliographyCategory{<category>}
\addtocategory{<category>}{<key>}

Here's a MWE using the first mentioned option:

\documentclass{article}
\usepackage[style=numeric]{biblatex}
\addbibresource{xampl.bib}
\begin{document}
\cite{article-minimal,article-full,book-minimal,book-full}
\printbibliography[type=article,title={Articles}]
\printbibliography[type=book,title={Books}]
\end{document}

biblatex example

Check biblatex documentation for more information.

To move to biblatex, I suggest you read the following questions: