33

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?

  • 1
    You could modify lockstep's excellent solution to this similar problem... – Seamus Jun 8 '11 at 13:29
52

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:

  • Thanks @henriqe, that was the spot on answer I was looking for. now I just have to style splitbib an it's done. – Johnny_Bit Jun 8 '11 at 15:24
  • 2
    ok @johnny_bit, but i really suggest you consider using biblatex! – henrique Jun 8 '11 at 16:25
  • Are you sure this work? I'm using biblatex, added keywords = {keyword1} to my bib file, and then tired printing \printbibliography[keyword=keyword1]. Nothing happened, even after deleting auxiliary files and running everything again. I still got Keyword 'keyword1' not found on line.... error – user19502 Jul 1 '13 at 15:09
  • 1
    @user19502 You can find a lot of sample documents for biblatex usage online or on your computer already in the Tex tree at texmf/doc/latex/biblatex/examples. They should all work without any error messages; if you get error messages the problem is quite probably on your side. – matth Jul 1 '13 at 15:20
  • 5
    @user19502, I'm pretty positive it works. Perhaps you've mispelled the entry field (a very common mistake I do), since the field is keywords and the command option keyword? – henrique Jul 1 '13 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.