2

I am trying to use the date field of an entry in a bib file for another entry. The idea is that I am using another source to date the entry (which is itself undated) and I want to avoid duplicating data.

Biblatex provides a simple way to use a field from another entry in a bib file with the \entrydata{entry_key}{\thefield{field}} command.

Although it works well for fields like title and although using the \printdate command also works if used for example in a title field (\entrydata{entry_key}{\prindate}), using \entrydata{entry_key}{\thefield{date}} in a date field doesn't work.

I am guessing it has to do with the nature of the date field which is not a simple string, but after having empirically tried every command I could think of in the biblatex manual, nothing works.

Additionally, the date field I want to use will come in YYYY-MM-DD form: I'd like the full date to be retained for sorting purposes but only the year to be printed.

Any help would be much appreciated.

MWE:

\documentclass{article}
\usepackage{biblatex} 
\usepackage{filecontents}
\begin{filecontents}{sources.bib}

@article{testart1,
    title           = {First Article Title},
    journaltitle    = {Something Times},
    date            = {1964-02-01},
    }

@article{testart2,
    title           = {\entrydata{testart1}{\thefield{title}}},% using the title of testart1 entry, working
    journaltitle    = {Another Times},
    date            = {1975-05-10},
    }

@video{testvid,
    title           = {A Film Title},
    editor          = {Doe, John},
    date            = {},% should use date field from testart1 entry, not working with \thefield{date}
    }

\end{filecontents}

\addbibresource{sources.bib}

\begin{document} 

Lorem.

\nocite{*}
\printbibliography 

\end{document}
  • 3
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Feb 15 '15 at 16:31
  • 3
    I'm not entirely sure whether I understood what you want to do. It seems much easier to just give the date than use this convoluted method. Plus, I don't think \entrydata was intended to be used in the .bib file. The fact that it works for titles and such is due to biblatex (or rather Biber) copying these fields verbosely and pasting them to the bibliography where the commands are expanded; the date field, however is actually consumed by Biber at a a point where the expression \entrydata{entry_key}{\thefield{date}} is in a way utterly meaningless and cannot be expanded. – moewe Feb 15 '15 at 16:46
  • Without an actually use-case or an MWE it is hard to say, but there might be ways using data inheritance or source-mapping to do what you want. – moewe Feb 15 '15 at 16:50
  • Thanks for your answer and for pointing that I might be on the wrong track with \entrydata. The idea might sound weird but it actually makes sense. Of course, for a single entry, just writing the correct date in the date field would be easier but I need to do this on a larger scale. I've a got a large number of entries that have no precise dates (just YYYY, no MM-DD) and that I need to date more finely, based on when they were first discussed in print. Think for example of movies that would need to be sorted by actual release dates, not just years. – syntax Feb 15 '15 at 17:28
  • 2
    @syntax - an MWE isn't absolutely mandatory. However, among other things, providing an MWE tends to dramatically raise the odds that one or more readers will understand what exactly you're trying to achieve. Of course, you can always hope that a biblatex-savvy clairvoyant will come along... – Mico Feb 15 '15 at 17:42
2

Found a simple solution:

To use the date field of another bib entry, one just needs to add a crossref field to the destination entry containing the key of another entry (source entry).

Using crossref has a side effect, it populates the destination entry with unnecessary fields from the source entry if those fields are not already defined (a common occurence if the source and destination entries are of different types). This is easily prevented by using \DeclareDataInheritance. For example:

\DeclareDataInheritance{article}{music}{% source entry type / destination entry type
    \inherit{date}{date}% field we want to use
    \noinherit{entrysubtype}% fields we don't want to use
    \noinherit{author}
    \noinherit{title}
    \noinherit{subtitle}
    \noinherit{journaltitle}
    \noinherit{pages}
}

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.