6

I've written my own entry types & bibliography driver as per my previous question. I'd like entries to have two sets of dates (a seriesdate and a "normal" date), and have them both formatted exactly as \printdate does.

The seriesdate field is declared like so:

\DeclareDatamodelFields[type=field, datatype=date]{
    seriesdate}

However, using \printfield{seriesdate} outputs an empty string. Presumably, I'll have to tell biblatex how to output the field, possibly using \DeclareFieldFormat but I'm unsure how...

meide
  • 1,165

1 Answers1

9

If you want to have a new date-type field you do not only need to ask for the date field, but also for the corresponding datepart fields. You also need to define the new entry types and specify which fields are allowed for these types.

The command \printseriesdate can be used for pretty printing our new seriesdate.

Full MWE (adapted from your answer to Biblatex: Citing complex nested unpublished sources)

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@archivalsource{Test,
    title = {Test Source},
    contains = {ITEM1 and ITEM2}}

@archivalitem{ITEM1,
    title = {Transcript},
    author = {J. Doe},
    date = {1920-04-03},}

@archivalitem{ITEM2,
    title = {Report},
    author = {J. Moe},
    seriesdate = {1900-01-01/1900-06-06},}
\end{filecontents*}


\begin{filecontents*}{archival.dbx}
\DeclareDatamodelEntrytypes{
  archivalsource,
  archivalitem}
\DeclareDatamodelFields[type=list, datatype=literal]{
  contains}
\DeclareDatamodelFields[type=field, datatype=date, skipout]{
  seriesdate}
\DeclareDatamodelEntryfields[archivalsource]{
  title,
  contains,
  seriesdate,
  seriesday,
  seriesendday,
  seriesendhour,
  seriesendminute,
  seriesendmonth,
  seriesendseason,
  seriesendsecond,
  seriesendtimezone,
  seriesendyear,
  serieshour,
  seriesminute,
  seriesmonth,
  seriesseason,
  seriessecond,
  seriestimezone,
  seriesyear}
\DeclareDatamodelEntryfields[archivalitem]{
  author,
  title,
  seriesdate,
  seriesday,
  seriesendday,
  seriesendhour,
  seriesendminute,
  seriesendmonth,
  seriesendseason,
  seriesendsecond,
  seriesendtimezone,
  seriesendyear,
  serieshour,
  seriesminute,
  seriesmonth,
  seriesseason,
  seriessecond,
  seriestimezone,
  seriesyear}
\end{filecontents*}

\documentclass[british]{article}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[datamodel=archival, backend=biber]{biblatex}
\usepackage{hyperref}
\addbibresource{\jobname.bib}


\DeclareBibliographyDriver{archivalitem}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printnames{author}%
  \setunit{\addspace\textendash\space}%
  \printfield{title}%
  \setunit{\addspace}%
  \printseriesdate
  \usebibmacro{finentry}}

\DeclareListFormat{contains}{
  \item \entrydata{#1}{\usedriver{}{\thefield{entrytype}}}
}

\DeclareBibliographyDriver{archivalsource}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printfield{title}%
  \setunit{\addperiod\space}%
  \printtext{Contains:}%
  \begin{enumerate}%
  \printlist{contains}%
  \end{enumerate}%
  \iflistundef{contains}{\finentry}{}}

\begin{document}
\nocite{*}

\printbibliography
\end{document}

example output

moewe
  • 175,683