Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've been looking for a while, but I don't manage to use multiple citation styles with biblatex, depending on different keywords contained in the .bib file.

I already use keywords to sort my bibliography, using \printbibliography[keyword=primary] and \printbibliography[notkeyword=primary].

I would like, the same way, to differentiate primary and secondary sources in the text of my thesis. My goal is to use only \autocite in the body text. Depending on the keyword of the reference (=primary or not), I'd like my primary sources to automatically appear in footnotes (precisely using \footfullcite), and my secondary sources to appear in traditional authoryear style in the body text.

Is there a way to define it so in the preamble? Maybe using categories?

share|improve this question
    
Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. –  egreg May 9 '12 at 15:54
add comment

2 Answers

up vote 4 down vote accepted

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.

share|improve this answer
1  
In fact, there was just a call for beta testers for biblatex 2.0 and biber 1.0. –  jon May 9 '12 at 16:55
    
Yes, I know. But as I wrote, even version 2.0 won't bring this feature. It "only" brings different sorting schemes for different bibliographies. –  Simifilm May 9 '12 at 17:36
2  
In fact this is very hard to implement indeed - how would it work with citations? Which citation style do you use for a key if it's it two bibliographies with different styles (label vs authoryear, for example?) Entry disambiguation becomes almost impossible in such cases too. I doubt this will ever be implemented as a complete style switch - it's better just to redfine some bibliography formatting macros between \printbibliography calls since it's unlikely you would ever want to dramatically switch styles anyway. –  PLK May 10 '12 at 6:06
    
@PLK Well, I found here, because I'd like to switch from numeric to numeric-comp for a particularly long list of references in one cite. I normally don't like the abbreviated numeric but in this case the bracket looks just too ugly. This wouldn't influence the bibliography, just the citation itself. –  Christian Sep 7 '12 at 7:14
add comment

Without in any way disagreeing with the answer that has been given and accepted, it seems to me that this is possible (though clunkily), if one assumes that all that one is really trying to do is, as the question asks, to allow \autocite to act as \footfullcite in relation to primary sources, and \parencite in relation to secondary ones. In other words, he wasn't really asking for two completely different citation styles, but simply for the use of variants (\footfullcite vs \parencite) perfectly proper to an author-year system which would be selected automatically by \autocite.

One might think that would be easy. But the difficulty is this. When a citation command declared with \DeclareCiteCommand starts up, it executes some precode. But that can't be used to decide whether to put a citation in a footnote or parentheses because at that point one can't "see" the data, which only becomes available as the citation's loopcode is executed, by which time it's too late! The solution to this I came up with involves defining a new command, not using the (proper) \DeclareCiteCommand method, which first runs a sort of "dummy" citation which just examines the citation data, and then pumps its arguments back into either \parencite or \footfullcite (for that purpose, since I'm terrible with optional arguments, I used xparse).

There are several bad things about this, as it stands. First, it's evading the proper interface for declaring cite commands, which is a problem for autocite. Secondly, it's not clever about punctuation or spacing: \footcite needs to close up space before the citation and move punctuation after it so it comes before. \parencite really needs to respect space before it, and to move at least some punctuation that is before it so it comes afterwards. Since the revised version doesn't move punctuation, the user still sometimes needs to know whether it's going to be primary or secondary data that gets cited, to get the positioning exactly right. At which point one asks: why not just do the whole thing explicitly? Lastly, there's a real problem knowing how to handle a single citation that contains both primary and secondary literature. I suspect the best solution would be to put it in a footnote, but with a full citation only for primary literature and a short citation for secondary literature. That could, actually, be done by redefining \footcite, but for present purposes I haven't bothered.

I daresay my approach is a poor one, and if I understood how \DeclareCiteCommand worked internally it might be possible to find a way to allow the precode part to peek at least at the first citation and take decisions accordingly. If that could be done then one wouldn't need to bypass the proper method for declaring citation commands, though some of the other problems would still be pretty difficult, I think.

\documentclass{article}
\begin{filecontents}{\jobname.bib}
@book{primary,
  author = {Ancient, Albert},
  title  = {A Primary Source},
  date   = {1556},
  keywords = {primary},
  publisher = {Vetus Libris Emptor},
  location  = {Leiden},
}
@book{secondary,
 author  = {Modern, Mark},
 title   = {A Secondary Work},
 date    = {2012},
 keywords= {secondary},
 publisher = {Recentissima Societas},
 location = {New York},
}
\end{filecontents}

\usepackage[backend=biber, style=authoryear]{biblatex}
\usepackage{xparse}

\makeatletter
\newtoggle{filtered@primary}\togglefalse{filtered@primary}

\DeclareDocumentCommand \filterandcite { o o m }{%
  \filteredcite{#3}%
  \IfNoValueTF{#2}
    {\IfNoValueTF{#1}
        {\iftoggle{filtered@primary}
          {\unspace\footfullcite{#3}}
          {\space\parencite{#3}}}
        {\iftoggle{filtered@primary}
          {\footfullcite[#1]{#3}}
          {\space\parencite[#1]{#3}}}}
    {\iftoggle{filtered@primary}
          {\footfullcite[#1][#2]{#3}}
          {\space\parencite[#1][#2]{#3}}}}

\DeclareCiteCommand{filteredcite}
  {\unspace}
  {\ifkeyword{primary}
   {\global\toggletrue{filtered@primary}}
   {\global\togglefalse{filtered@primary}}}
  {}
\makeatother

\renewcommand*\autocite\filterandcite

\addbibresource{\jobname.bib}

\begin{document}

It is possible to have a system which will use keywords to decide
whether to put a source in a footnote wil a full citation, if it is
primary,\autocite{primary} or in the text with a label if it is
secondary\autocite{secondary}.

However: it's not a very robust system, because (a) it doesn't move
punctuation intelligently---so you still need to keep track in your
own mind of what is in the citation.\autocite{secondary} (A more
intelligent system would move that full stop past the citation.) And,
because it is redefining \verb|\autocite| outside \texttt{Biblatex}'s
dedicated mechanisms, it doesn't play well with \verb|\autocites|: as
can be seen here \autocites[10]{primary}[11]{secondary}. Finally---and
unavoidably---it's liable to `do the wrong thing' if an automatic
citation contains both primary and secondary
sources\autocite{primary,secondary} (though it's not clear exactly
what would be the `right thing' in these circumstances).

\printbibliography[title={Primary Sources}, keyword=primary]

\printbibliography[title={Secondary Sources}, keyword=secondary]

\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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