When an entry in my bibliography includes the crossref
field, I would like it to print that information as if it were a regular citation in the text, provided the cross-referenced entry is included in the bibliography. Otherwise, it should print the inherited information as it does by default.
I've tried to cobble something together – just for the @incollection
entry type for now – based on answers to similar questions (referenced in annotations in the code below).
First, based on Denis's schematic answer I tried this:
\begin{filecontents}{\jobname.bib}
@incollection{incoll1,
crossref = {coll1},
author = {Ard, Liz},
title = {Befriending Reptiles},
pages = {1--45}}
@incollection{incoll2,
crossref = {coll1},
author = {Keyes, Don},
title = {Asses I've Known},
pages = {342--346}}
@incollection{incoll3,
crossref = {coll2},
author = {Other, A. N.},
title = {Flamingos of the Arctic},
pages = {3--4}}
@collection{coll1,
editor = {Anvil, A. N. and Pond, Lily},
title = {Known Beings},
publisher = {Sheds \& Sons},
address = {Mountain View},
year = 1987}
@collection{coll2,
editor = {Ville, Bourne and Tree, Rown},
title = {Less Known Beings},
publisher = {Sheds \& Sons},
address = {Mountain Pass},
year = 1989}
\end{filecontents}
\documentclass{article}
\usepackage[citestyle=authoryear-comp,bibstyle=authoryear,mergedate=basic,isbn=false,url=false,eprint=false,dashed=true,doi=false,sortcites=true,backend=biber,mincrossrefs=2]{biblatex}
\bibliography{\jobname}
\DeclareBibliographyDriver{incollection}{% adapted from standard.bbx based on answer by Denis at https://tex.stackexchange.com/a/118850/
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{in:}%
\ifentryinbib{\thefield{crossref}}%
{\printfield{editor+others}%
\addspace\mkbibparens{\usebibmacro{citeyear}}}%
{\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\printfield{edition}%
\newunit
\iffieldundef{maintitle}
{\printfield{volume}%
\printfield{part}}
{}%
\newunit
\printfield{volumes}%
\newunit\newblock
\usebibmacro{series+number}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\usebibmacro{publisher+location+date}%
\newunit\newblock
\usebibmacro{chapter+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{isbn}}
{}%
\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}}
\begin{document}
\textcite{incoll1}
\textcite{incoll2}
\textcite{incoll3}
\printbibliography
\end{document}
This does not, unfortunately, get me the full label for the cross-referenced entry: I just get the year in parentheses rather than the author-year label, and I've also managed to temporarily lose the page range etc.:
Based on Paul Stanley's answer addressing a similar question for alpha-style labels (rather than author-year), I also tried this:
\begin{filecontents}{\jobname.bib}
@incollection{incoll1,
crossref = {coll1},
author = {Ard, Liz},
title = {Befriending Reptiles},
pages = {1--45}}
@incollection{incoll2,
crossref = {coll1},
author = {Keyes, Don},
title = {Asses I've Known},
pages = {342--346}}
@incollection{incoll3,
crossref = {coll2},
author = {Other, A. N.},
title = {Flamingos of the Arctic},
pages = {3--4}}
@collection{coll1,
editor = {Anvil, A. N. and Pond, Lily},
title = {Known Beings},
publisher = {Sheds \& Sons},
address = {Mountain View},
year = 1987}
@collection{coll2,
editor = {Ville, Bourne and Tree, Rown},
title = {Less Known Beings},
publisher = {Sheds \& Sons},
address = {Mountain Pass},
year = 1989}
\end{filecontents}
\documentclass{article}
\usepackage[citestyle=authoryear-comp,bibstyle=authoryear,mergedate=basic,isbn=false,url=false,eprint=false,dashed=true,doi=false,sortcites=true,backend=biber,mincrossrefs=2]{biblatex}
\bibliography{\jobname}
\DeclareBibliographyDriver{incollection}{% adapted from standard.bbx based on answer by Denis at https://tex.stackexchange.com/a/118850/
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{in:}%
\ifentryinbib{\thefield{crossref}}%
{\usebibmacro{crossref:label}}%
{\usebibmacro{crossref:collection}}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}}
% modified from Paul Stanley's answer at https://tex.stackexchange.com/a/54844/39222
\newbibmacro{crossref:collection}{%
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\printfield{edition}%
\newunit
\iffieldundef{maintitle}
{\printfield{volume}%
\printfield{part}}
{}%
\newunit
\printfield{volumes}%
\newunit\newblock
\usebibmacro{series+number}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\usebibmacro{publisher+location+date}%
\newunit\newblock
\usebibmacro{chapter+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{isbn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}}
\newbibmacro{crossref:label}{%
\entrydata{\strfield{crossref}}
{\boolfalse{cbx:parens}\usebibmacro{textcite}\ifbool{cbx:parens}{\bibcloseparen}{}}%
\newunit\newblock
\usebibmacro{chapter+pages}%
}
\begin{document}
\textcite{incoll1}
\textcite{incoll2}
\textcite{incoll3}
\printbibliography
\end{document}
Almost certainly I'm not meant to be using the citation macros here. In any case, I get the correct author-year label for one entry but neither author nor year for the other:
How should I be thinking about this? I'm interested in solving the problem, but I'm at least as interested in getting some clue how to think about this kind of problem.
It is still surprising to me that a standard feature of BibTeX is not straightforwardly supported in some way by Biblatex, but I guess this feature somehow got overlooked in the planning process!
Best Answer
Update
This feature is available in the
biblatex-ext
styles with a simple option:citexref
.The implementation of that feature uses an internal
\cite...
command (as explained in the second part of the answer below).Old answer
Those short "in" references are "hard" to implement because they often require a major overhaul of the entire driver. As such a solution will require lots of lines of code, many of them copied directly from
standard.bbx
with just a few additions. There are actually some custom styles that implement something similar,biblatex-chicago
andbiblatex-philosophy
. These styles have already written their own versions of the drivers, so it was only a bit extra work to add the needed macros.We can make use of
\entrydata
like your second example, which would have worked were it not for using the styleauthoryear-comp
(it works fine withauthoryear
), wheretextcite
has to do some complicated stuff.So we define a simpler cite-bibmacro (based on
authoryear.cbx
scite
)and use that
in an
\entrydata
wrapper, inside the curly braces all fields will be filled with the information of the parent entry. Which is crucial if you were to apply an author-title style, there thetitle
of the@incollection
will not coincide with that of the@collection
. It can also help deal with some weird corner cases in other styles.MWE
The approach taken in
biblatex-chicago
is to define a special citation macro called\bibxrefcite
and then just cite thecrossref
'd item as in\bibxrefcite{\thefield{crossref}}
, special care has to be taken here to make sure no cite tracker features interfere with the output (we don't want an "ibid." here, or a page backref to this "citation"). So using standard\cite
is a bad idea, a custom command such as\bibcrefcite
is a good solution.biblatex-philsophy
uses a very similar approach.Our cite macro approach could look like
Where
simplecite
is defined as aboveWith driver
MWE
Both examples above give
Just to show what is possible using the power of
biblatex
we can also condition showing of information that could pertain to the child or parent (a DOI or URL, say) depending on where they belongAgain we have
But now we also have extra eprint and addendum info
collected into one handy macro
In the driver
This setup can in our MWE distinguish between an inherited DOI and a "eigen"-DOI.
The "Keyes" entry inherits the DOI from "Anvil & Pond", but it is not displayed to avoid redundancies, the distinct DOI of "Ard" is correctly reported.