0

I need to selectively retrieve titles from references using biblatex, based on the entry type.

That is, for article, incollection, inbook, and similar entry types describing a smaller item published within a larger one, I want the title of the book or journal in which the work appeared (ie the booktitle or journal field), rather than the title of the article itself. For books and other monographs I just want the normal title.

I can see from the biblatex doc how to selectively print references by entry type, but I can't see how you get the entry type from an individual key. Is there something like \getentrytype{<key>} that will return the string 'article', 'incollection, 'book', etc, so that I can then make LaTeX decide programmatically which field to retrieve?

1 Answer 1

1

One way to do that if you don't need the normal behaviour of labeltitle (so this idea is probably a non-starter with author-title-based styles) would be to reconfigure labeltitle resolution so that you get back the desired type of title

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

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

\DeclareLabeltitle[article]{%
  \field{journaltitle}
}

\DeclareLabeltitle[inbook,incollection,inproceedings]{%
  \field{booktitle}
  \field{maintitle}
}

\DeclareFieldFormat*{citetitle}{\mkbibemph{#1}}

\addbibresource{biblatex-examples.bib}


\begin{document}
\citetitle{sigfridsson}

\citetitle{worman}

\citetitle{nussbaum}

\citetitle{geer}

\citetitle{pines}

\printbibliography
\end{document}

Journal of Computational Chemistry//Cast of Character//Aristotle’s ‘De Motu Animalium’//Earl, Saint, Bishop, Skald – and Music//Studies in Medieval Jewish History and Literature


If the labeltitle solution does not work for you, you will have to roll a manual version of that approach.

The following implements a \petercitetitle that usually prints the title field, but can be configured to print a different field for on a per-type basis.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

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

\DeclareFieldFormat*{petercitetitle}{\mkbibemph{#1}}

\DeclareCiteCommand{\petercitetitle}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifbibmacroundef{peter:citetitle:\strfield{entrytype}}
     {\printfield[petercitetitle]{title}}
     {\usebibmacro*{peter:citetitle:\strfield{entrytype}}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}


% you can define exceptions to printing 'title'
% for type <type> by defining a bibmacro called
% 'peter:citetitle:<type>'
% the macros usually have the same structure, so this
% could be packed up into a macro

\newbibmacro*{peter:citetitle:article}{%
  \printfield[petercitetitle]{journaltitle}}

\newbibmacro*{peter:citetitle:inbook}{%
  \printfield[petercitetitle]{booktitle}}

\letbibmacro*{peter:citetitle:incollection}{peter:citetitle:inbook}
\letbibmacro*{peter:citetitle:inproceedings}{peter:citetitle:inbook}

\addbibresource{biblatex-examples.bib}


\begin{document}
\petercitetitle{sigfridsson}

\petercitetitle{worman}

\petercitetitle{nussbaum}

\petercitetitle{geer}

\petercitetitle{pines}

\printbibliography
\end{document}

Journal of Computational Chemistry//The Cast of Character//Aristotle’s ‘De Motu Animalium’//Earl, Saint, Bishop, Skald – and Music//Studies in Medieval Jewish History and Literature

Here \strfield{entrykey} is similar to what your \getentrytype{<key>} would do (except it always applies to the current <key>, you can't easily extract the entry type of an entry that is not currently being processed, you'd have to switch over to that entry with \entrydata).

1
  • I'm experimenting with the options. Many thanks for this. May 14, 2020 at 23:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .