What is the best way create a bibliography for separate sections within a document? I am using biblatex
.
[Tex/LaTex] Section bibliographies
biblatexsubdividing
Related Solutions
Use \nocite
to "cite" the publications in the order you want.
\documentclass{article}
\usepackage[sorting=none]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
}
@misc{C03,
keywords = {pub},
author = {Cuthor, C.},
year = {2003},
title = {Charlie},
}
@misc{Z00,
keywords = {pub},
author = {Zuthor, Z.},
year = {2000},
title = {Zulu},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
Some text \autocite{B02,A01}.
\nocite{Z00,C03}
\printbibliography[title={Reference list},notkeyword=pub]
\printbibliography[title={List of publications},keyword=pub]
\end{document}
Assuming that the categories are indicated in the usera
field, the following document demonstrates how you can meet requirements 1, 2 and 4.
\documentclass{article}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[backend=biber,style=numeric,defernumbers,sorting=ydnt]{biblatex}
\usepackage{hyperref}
\makeatletter
% Store value passed to category option for \printbibliography
\apptocmd{\blx@key@category}{\edef\bbx@thecategory{\detokenize{#1}}}{}{}
% Initialize category counters
\def\bbx@initcategory#1{\csnumgdef{bbx@count@#1}{0}}
\forlistloop{\bbx@initcategory}{\blx@categories}
% Increment category counters
\def\bbx@countcategory#1{%
\iffieldequalstr{usera}{#1}
{\csnumgdef{bbx@count@#1}{\csuse{bbx@count@#1}+1}%
\addtocategory{#1}{\thefield{entrykey}}%
\listbreak}
{}}
\AtDataInput{\forlistloop{\bbx@countcategory}{\blx@categories}}
% Print labelnumber as actual number, plus item total, minus one
\newrobustcmd*{\mkbibdesc}[1]{%
\ifcitation
{\number\numexpr\csuse{bbx@count@\thefield{usera}}+1-#1\relax}
{\number\numexpr\csuse{bbx@count@\bbx@thecategory}+1-#1\relax}}
\makeatother
\DeclareFieldFormat{labelnumber}{\mkbibdesc{#1}}
\begin{filecontents}{test.bib}
@Periodical{jcg,
title = {Computers and Graphics},
issuetitle = {Semantic {3D} Media and Content},
volume = {35},
number = {4},
year = {2011},
issn = {0097-8493}}
@Article{sarfraz,
author = {M. Sarfraz and M. F. A. Razzak},
title = {An algorithm for automatic capturing of the font outlines},
journal = {Computers and Graphics},
volume = {26},
number = {5},
pages = {795--804},
year = {2002},
issn = {0097-8493},
doi = {10.1016/S0097-8493(02)00134-6}}
\end{filecontents}
\addbibresource{biblatex-examples.bib}
\addbibresource{test.bib}
\DeclareBibliographyCategory{primary}
\DeclareBibliographyCategory{secondary}
\defbibheading{bibliography}{\section*{Bibliography}}
\defbibheading{primary}{\subsection*{Primary references}}
\defbibheading{secondary}{\subsection*{Secondary references}}
\begin{document}
Filler text \parencite{companion,cms,sarfraz,nussbaum}.
\printbibheading
\printbibliography[heading=primary,category=primary,prefixnumbers={P}]
Filler text \parencite{ctan}.
\printbibliography[heading=secondary,category=secondary,prefixnumbers={S}]
Filler text \parencite{jcg}.\par\pagebreak
Filler text.
\end{document}
Thanks to a previous answer from PLK, requirement 3 can be supported with biber. The following sourcemap
adds the data needed in the usera
field. Just save this in a separate file called biber.conf
.
<?xml version="1.0" encoding="UTF-8"?>
<config>
<sourcemap>
<maps datatype="bibtex" bmap_overwrite="1">
<map>
<per_datasource>biblatex-examples.bib</per_datasource>
<map_step map_field_set="USERA" map_field_value="primary"/>
</map>
<map>
<per_datasource>test.bib</per_datasource>
<map_step map_field_set="USERA" map_field_value="secondary"/>
</map>
</maps>
</sourcemap>
</config>
Some caveats:
The new format typically needs an extra
latex
run to get the label numbers right, even if biblatex doesn't tell you to "rerun LaTeX".The new format will generally screw up citation labels with the
sortcites=true
orstyle=numeric-comp
option settings, unless all citation lists are limited to a single category. The citation list in the sample document, for example, doesn't meet this condition.
Best Answer
Please refer to Section 3.10.3 Multiple Bibliographies of the biblatex documentation. The basic idea is to use the
refsection
environment for each bibliographical unit and the\printbibliography
command inside eachrefsection
environment. Notice that you will have to compile (through bibTeX, for example) the auxiliary.aux
files that will be created for everyrefsection
environment.Here's an schematic document (
test.tex
) to produce a bibliography for each chapter:the database
biblio.bib
:You need to compile the example in the following way: