2

It is common in references to indicate an attributed field by putting it into brackets. If a book comes with no date printed, but we happen to know the date (so it is not "uncertain", nor "circa"), we can indicate that by putting the date within brackets.

I'd like to do that with biblatex's data annotation feature.

I've tried to do so using \DeclareFieldFormat{date} (there is a \DeclareFieldFormat{urldate} in biblatex.def suggesting this as a possibility), but the conditionals for annotations are not recognized within this scope, even though it is a formatting directive. How then could I use the data annotation to put a date into brackets?

I know I could always use year = {[1933]},. But the question here is how to do so with biblatex's data annotation facilities (thus keeping biblatex's advanced date features).

A MWE:

\documentclass{article}

\usepackage[style=authoryear]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{gillies,
  author       = {Gillies, Alexander},
  title        = {Herder and the Preparation of {Goethe's} Idea of World Literature},
  journaltitle = {Publications of the English Goethe Society},
  date         = {1933},
  date+an      = {=attributed},
  series       = {newseries},
  volume       = {9},
  volume+an    = {=attributed},
  pages        = {46-67},
}
\end{filecontents}

\addbibresource{\jobname.bib}

% This works, but affects all dates
\DeclareFieldFormat{date}{\mkbibbrackets{#1}}
\DeclareFieldFormat{labeldate}{\mkbibbrackets{#1}}

% This doesn't work, for the conditional is not recognized
%\DeclareFieldFormat{date}{\iffieldannotation{attributed}{\mkbibbrackets{#1}}{#1}}
%\DeclareFieldFormat{labeldate}{\iffieldannotation{attributed}{\mkbibbrackets{#1}}{#1}}

% It works with the conditional for volume, for example
\DeclareFieldFormat[article]{volume}{\iffieldannotation{attributed}{\mkbibbrackets{#1}}{#1}}

\begin{document}

\autocite{gillies}

\printbibliography

\end{document}
2

date fields are a bit special. Within \DeclateFieldFormat{date} biblatex does not know which date field it is processing (that is because the date is not printed via \printfield{date} and indeed for biblatex there is no field date at all, the field format date is just used with \printtext), so you can't use \iffieldannotation because that command relies on detecting the field currently being processed. biblatex also needs to resolve labeldate which adds another layer of complexity.

\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{gillies,
  author       = {Gillies, Alexander},
  title        = {Herder and the Preparation of {Goethe's} Idea of World Literature},
  journaltitle = {Publications of the English Goethe Society},
  date         = {1933},
  date+an      = {=attributed},
  series       = {newseries},
  volume       = {9},
  pages        = {46-67},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\makeatletter
\newcommand*{\ifdateannotation}[2]{%
  \def\blx@tempa{#1}%
  \ifcsundef{abx@field@\blx@tempa source}
    {}%
    {\letcs\blx@tempa{abx@field@\blx@tempa source}%
     \edef\blx@tempa{\blx@tempa date}}%
  \ifinlistcs{#2}{abx@annotation@field@\blx@tempa}}
\makeatother

\DeclareFieldFormat{date}{\ifdateannotation{date}{attributed}{\mkbibbrackets{#1}}{#1}}
\DeclareFieldFormat{labeldate}{\ifdateannotation{labeldate}{attributed}{\mkbibbrackets{#1}}{#1}}

\begin{document}
\autocite{gillies}
\printbibliography
\end{document}

enter image description here

  • moewe, Wow!! I've spent several hours yesterday digging the code trying to figure a point of entrance to do this. And I didn't get even close! Thank you very very much! – gusbrs Jan 16 '18 at 15:04
  • moewe, would you mind if I made a feature request out of this one? I do think it deserves. – gusbrs Jan 22 '18 at 22:05
  • 1
    @gusbrs Sure, go ahead and open a feature request if you think it can be useful. – moewe Jan 23 '18 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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