This is now implemented in Biber 0.9.8. Here is how to deal with your question. Given the sample file:
\begin{filecontents}{\jobname-primary.bib}
@BOOK{hectic,
AUTHOR = {Henry Hectic},
TITLE = {How Horticulturalists Howl},
PUBLISHER = {Honorary Books: Henage},
YEAR = {2000}
}
\end{filecontents}
\begin{filecontents}{\jobname-secondary.bib}
@BOOK{flutter,
AUTHOR = {Frederick Flutter},
TITLE = {Fraternising with Flowers},
PUBLISHER = {Frippery Pamphlets: Folkestone},
YEAR = {1995}
}
\end{filecontents}
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber,style=authoryear]{biblatex}
\usepackage{csquotes}
\addbibresource{\jobname-primary.bib}
\addbibresource{\jobname-secondary.bib}
\begin{document}
Some citations: \cite{hectic}, \cite{flutter}.
\printbibliography[title=Primary Sources, keyword=primary]
\printbibliography[title=Secondary Sources, keyword=secondary]
\end{document}
You can automatically add the correct keywords to your data as Biber
reads it by using the following biber.conf file:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<sourcemap>
<maps datatype="bibtex" bmap_overwrite="1">
<map>
<per_datasource>test-primary.bib</per_datasource>
<map_step map_field_set="KEYWORDS" map_field_value="primary"/>
</map>
<map>
<per_datasource>test-secondary.bib</per_datasource>
<map_step map_field_set="KEYWORDS" map_field_value="secondary"/>
</map>
</maps>
</sourcemap>
</config>
This will add the necessary keywords based on the datasource names. If
you already had a KEYWORD field in your datasources which you wanted to
keep, you could use the match/replace functionality instead:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<sourcemap>
<maps datatype="bibtex" map_overwrite="1">
<map>
<per_datasource>test-primary.bib</per_datasource>
<map_step map_field_source="KEYWORDS" map_match="^" map_replace="primary,"/>
</map>
<map>
<per_datasource>test-secondary.bib</per_datasource>
<map_step map_field_source="KEYWORDS" map_match="^" map_replace="secondary,"/>
</map>
</maps>
</sourcemap>
</config>
The Biber manual has been updated in 0.9.8 with documentation of the
config file format and has more examples. The format of the user
config file is a major change from 0.9.6 (and some changes also from 0.9.7) as the older format was a bit
of a mess and couldn't be extended to cope with situations like this
due to inherent limitations of the format itself. I opted for a real
XML format for flexibility. You can also validate your config file now
by passing the --validate_config
option to Biber.
EDIT: Since biber 1.3, you there is an "append" mode for setting values in sourcemaps so it's easier like this, which deals with entries with or without an existing KEYWORDS field when you want to keep any existing values:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<sourcemap>
<maps datatype="bibtex" bmap_overwrite="1">
<map>
<per_datasource>test-primary.bib</per_datasource>
<map_step map_field_set="KEYWORDS" map_field_value="primary" map_append="1"/>
</map>
<map>
<per_datasource>test-secondary.bib</per_datasource>
<map_step map_field_set="KEYWORDS" map_field_value="secondary" map_append="1"/>
</map>
</maps>
</sourcemap>
</config>
Here is the same thing using the biblatex macro interface which you can put directly in your document:
\DeclareSourcemap{
\maps[datatype=bibtex, overwrite]{
\map{
\perdatasource{test-primary.bib}
\step[fieldset=KEYWORDS, fieldvalue=primary, append]
}
\map{
\perdatasource{test-secondary.bib}
\step[fieldset=KEYWORDS, fieldvalue=secondary, append]
}
}
}
As I wrote in the comment it's not possible to use a bibenvironment
for your purpose, since bibenvironments
are ment to format the bibliography list.
Also biblatex doesn't provide an implemented solution to mix different bibliography styles (as far as I know), so you have to try to find a way on your own to achieve what you want.
My solution:
- Choose a default bibliography style (
authoryear
in your case)
- Create drivers and macros which will differ from the default bibliography style (bibdriver for
article
and author
-macro in your case)
- Create and implement a toggle, with which you can switch between the default bibliography style and your new macros.
This solution will (adapted) also work for more than 2 bibliography styles.
However, the weak point is, you have to take care of every difference to your default bibliography style – and in the case you want to change your default bibliography style you have to start over...
Here is your updated and commented MWE. I've deleted a lot of unnecessary (for our issue) macros / packages. It should show you the idea of my solution.
In addition to the MWE you may modify the new macros and also set up a sorting
option in the \printbibliography
command etc.
\documentclass[a4paper,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[main=french,english]{babel}
\usepackage{csquotes}
\usepackage[T1]{fontenc}
\usepackage[top=2.5cm, bottom=2.5cm, right=2cm, left=2cm, headheight = 20pt]{geometry}
\usepackage{xspace}
\usepackage{setspace}
\usepackage[hidelinks]{hyperref}
\usepackage[language=auto,backend=biber,sorting=nyt,bibstyle=authoryear,citestyle=authortitle-icomp]{biblatex}
\usepackage{etoolbox}%added
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{test,
author = {Author, A.},
date = {2011-06-12},
title = {Some relevant article},
journal = {Test journal},
keywords = {primaires_articles},
},
@incollection{mhone_crossroads_1992,
title = {The Political Economy of Malawi - An Overview},
chapter = {1},
author = {Guy Mhone},
year = {1992},
booktitle = {Malawi At The Crossroads. The Post-Colonial Political Economy},
publisher = {\textsc{SAPES} Books},
address = {Harare},
pages = {1--34},
keywords = {malawi_histoire},
},
@article{momba_peasant_1985,
author = {Momba, Jotham C.},
title = {Peasant differentiation and rural party politics in colonial Zambia},
journal = {Journal of Southern African Studies},
volume = {11},
number = {2},
pages = {281-294},
year = {1985},
keywords = {malawi_histoire},
},
\end{filecontents}
%new toggle
\newtoggle{blx@bibdriver@article:journalyear}%new toggle to set which driver is to use
\togglefalse{blx@bibdriver@article:journalyear}
% Put editor string in parentheses
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
% Obtenir le nom de l'éditeur pour les @incollection entre le 'in' et le titre
\renewbibmacro*{in:}{%
\printtext{\bibstring{in}\intitlepunct}%
\ifentrytype{article}{}{}%
\ifentrytype{incollection}{%
\ifnameundef{bookauthor}
{\ifnameundef{editor}
{\printnames{translator}%
\setunit{\addcomma\space}%
\usebibmacro{translator+othersstrg}%
\clearname{translator}}
{\printnames{editor}%
\setunit{\addcomma\space}%
\usebibmacro{editor+othersstrg}%
\clearname{editor}}}
{\ifnamesequal{author}{bookauthor}
{}
{\printnames{bookauthor}%
\clearname{bookauthor}}}}%
\newunit\newblock}
% mettre entre parenthèses le numéro de la revue dans un volume en comportant plusieurs
\renewbibmacro*{volume+number+eid}{%
\printfield{volume}%
\setunit*{\addnbspace}%
\printfield{number}%
\setunit{\addcomma\space}%
\printfield{eid}}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}
%redefine author-macro so it only prints the year in the default bibdriver
\renewbibmacro*{author}{%also modified
\ifboolexpr{
test \ifuseauthor
and
not test {\ifnameundef{author}}
}
{\usebibmacro{bbx:dashcheck}
{\bibnamedash}
{\usebibmacro{bbx:savehash}%
\printnames{author}%
\iffieldundef{authortype}
{\setunit{\addspace}}
{\setunit{\addcomma\space}}}%
\iffieldundef{authortype}
{}
{\usebibmacro{authorstrg}%
\setunit{\addspace}}}%
{\global\undef\bbx@lasthash
\usebibmacro{labeltitle}%
\setunit*{\addspace}}%
\iftoggle{blx@bibdriver@article:journalyear}{}{%added
\usebibmacro{date+extrayear}}}%modified
%new bibdriver for article in the second bibliography
\newbibmacro*{article:journalyear}{%modified bibdriver for article
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{journal+issuetitle}%
\newunit
\usebibmacro{date+extrayear}
\newunit
\usebibmacro{title}%
\newunit
\usebibmacro{author/translator+others}%
\newunit
\usebibmacro{note+pages}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}}
%redeclare the existing bibdriver for article
\DeclareBibliographyDriver{article}{%from standard.bbx
\iftoggle{blx@bibdriver@article:journalyear}{\usebibmacro{article:journalyear}}{%added
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{bytranslator+others}%
\newunit\newblock
\printfield{version}%
\newunit\newblock
\usebibmacro{in:}%
\usebibmacro{journal+issuetitle}%
\newunit
\usebibmacro{byeditor+others}%
\newunit
\usebibmacro{note+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{issn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}}
}
\bibliography{\jobname}
\begin{document}
\nocite{*}
\printbibliography[keyword=malawi_histoire,heading=subbibliography,title={Malawi: histoire sociale}]
\toggletrue{blx@bibdriver@article:journalyear}
\printbibliography[keyword=primaires_articles,heading=subbibliography,title={Artiles de presse et revues}]
\printbibliography[type=article,heading=subbibliography,title={All articles}]
\end{document}
OUTPUT:
Best Answer
Very short answer: this is simply not possible at the moment.
biblatex
doesn't support multiple styles in one document.biblatex 2.0
which is due soon will support multiple sorting schemes, but that's it for the moment.Maybe a feature request is in order here.