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...

  • 1
    date fields need a bit more infrastructure if you want to have all the comfort that biblatex offers, have a look at my answer to How can I create entirely new data types with BibLaTeX/Biber? where we also deal with date fields. – moewe Jan 17 '16 at 14:23
  • Thanks @moewe that works, except I'd like to support date ranges, ie seriesdate = {1854/1899} should render as 1854–1899 like \printdate does. It currently renders as just the first year. Tried editing your minimal example with some ranges for testing to no avail. – meide Jan 17 '16 at 16:14
  • I will have a look then, hang on. – moewe Jan 17 '16 at 16:24
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

| improve this answer | |

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.