1

Consider this MWE (to be run with xelatex, biber, xelatex:

\documentclass{article}
\usepackage[backend=biber]{biblatex-chicago}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{poe1907hemmelighedsfulde,
title = {Hemmelighedsfulde Fortællinger},
author = {Poe, Edgar Allan},
year = {1907},
publisher = {Gyldendal},
}
@inbook{poe1907mysteriet,
title = {Mysteriet Marie Rogêt},
crossref = {poe1907hemmelighedsfulde},
}

@inbook{poe1907guldbillen,
title = {Guldbillen},
crossref = {poe1907hemmelighedsfulde},
}

\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}

The book \citetitle{poe1907hemmelighedsfulde} contains \citetitles{poe1907mysteriet,poe1907guldbillen}.

\end{document}

Is is possible to do something like this instead?

The book \citetitle{poe1907hemmelighedsfulde} contains \citealltitles{poe1907hemmelighedsfulde}.
  • Interesting question: The information which entries crossref poe1907hemmelighedsfulde is not available to biblatex out of the box. Additionally you would not know that all entries that crossref poe1907hemmelighedsfulde are really @inbooks (i.e. chapters/other units of the @book poe1907hemmelighedsfulde), so even if there was such a list, it would have to be filtered. – moewe Sep 29 '18 at 05:08
  • This question is obscure as long as you're not making a list of short story collections ... But when you are, you could really need this functionality. – Kristian Nordestgaard Sep 29 '18 at 06:31

1 Answers1

1

biblatex does not have a list of entries that crossref a particular parent entry. So when we process poe1907hemmelighedsfulde we have no way of knowing its children.

That means that a first step to solving this problem is to obtain its children. This happens in the \AtDataInput below: For each entry with crossref the list \knblx@crossrefs@<refsection>@for@<entrykey> will contain its children. The fact that this happens on a biblatex level in \AtDataInput implies a very important limitation: Children are only detected if they appear in the .bbl file, i.e. when they are explicitly \cited or if they are added to the .bbl with \nocite. It is unlikely that this limitation could be overcome even if the list of entries were provided by Biber out of the box, since that would require that each entry in the .bib - cited or not - would have to be examined and read (related: Is it possible to add entries to the bibliography based on keyword using Biblatex/Biber and within the document code?).

If you have that list of children, implementing a \citeallcontainedtitles is 'just' a matter of looping over the list and printing the desired information. Since it is not guaranteed in general that a crossref-ing entry has the "in" relationship to its parent, the command as implemented in the MWE checks that this is the case.

\documentclass{article}
\usepackage[backend=biber]{biblatex-chicago}

\makeatletter
\AtDataInput{%
  \iffieldundef{crossref}
    {}
    {\listcsxadd{knblx@crossrefs@\the\c@refsection @for@\thefield{crossref}}{\thefield{entrykey}}}}

% {<loopcode>}{<entrytype> (* applies to all types)}{<entry key>}
\newcommand*{\knlbx@filteredloop}[3]{%
  \edef\knblx@thisentrytype{#2}%
  \entrydata{#3}{%
    \ifstrequal{#2}{*}
      {#1}
      {\expandafter\ifentrytype\expandafter{\knblx@thisentrytype}
         {#1}
         {}}}}

\newbibmacro{citeallcontainedtitles}{%
  \ifcsvoid{knblx@crossrefs@\the\c@refsection @for@\thefield{entrykey}}
    {\blx@nounit}
    {\forlistcsloop
       {\knlbx@filteredloop
          {\usebibmacro{kncite:title}%
           \setunit{\addcomma\space}}
          {in\thefield{entrytype}}}
       {knblx@crossrefs@\the\c@refsection @for@\thefield{entrykey}}}}

\newbibmacro{kncite:title}{%
  \ifciteindex
    {\indexfield{indextitle}}
    {}%
  \printfield[citetitle]{labeltitle}}
\makeatother

\DeclareCiteCommand{\citeallcontainedtitles}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeallcontainedtitles}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{poe1907hemmelighedsfulde,
  title     = {Hemmelighedsfulde Fortællinger},
  author    = {Poe, Edgar Allan},
  year      = {1907},
  publisher = {Gyldendal},
}
@inbook{poe1907mysteriet,
  title    = {Mysteriet Marie Rogêt},
  crossref = {poe1907hemmelighedsfulde},
}
@inbook{poe1907guldbillen,
  title    = {Guldbillen},
  crossref = {poe1907hemmelighedsfulde},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\nocite{*}

\begin{document}
The book \citetitle{poe1907hemmelighedsfulde} contains \citeallcontainedtitles{poe1907hemmelighedsfulde}.
\end{document}

The book Hemmelighedsfulde Fortællinger contains “Guldbillen,” “Mysteriet Marie Rogêt.”

moewe
  • 175,683
  • Phew! I'm surprised this stuff is not trivial! – Kristian Nordestgaard Sep 29 '18 at 07:39
  • @KristianNordestgaard To be honest the code is probably a bit more complicated than necessary for your specific situation (I'm thinking about the type check here). It often is the case that certain things are complicated because no one thought about implementing them and no one asked for them yet. Feel free to open a feature request at https://github.com/plk/biblatex/issues if you think some of this should be supported natively. – moewe Sep 29 '18 at 07:49
  • I'll keep that in mind, but it may be an obscure request. – Kristian Nordestgaard Sep 29 '18 at 17:17