3

Additionally to the standard required fields biblatex lists in chapter 2.1, I would like to define my own required fields. So e.g. for book where biblatex only requires author, title, year/date I also would like publisher and location to be required and to give a warning if it's not present.

Is it possible to do that with biblatex or biber dependent on the bib type (different required fields for e.g. book, article, ...)?

lockstep
  • 250,273
user2653422
  • 2,333

1 Answers1

3

Following the advise of @moewe I post what I've done to create a custom model specification which adds some simple rules I need for my bibliography.

I've created a custom custom.dbx file in my user texmf folder as it is described in section §4.5.3 of the biblatex documentation. Don't forget to refresh the FNDB e.g. by using the MikTex settings menu. To load this file one way is to add datamodel=custom to the package options of biblatex. The other ways are described in the documentation. Also add --validate_datamodel "%tm" as arguments given to biber. To the data model file I added more constraints to some of the entry types. The constraints will be appended to the already existing ones.

For books and collections I wanted a publisher and location to be mandatory in addition to the already mandatory author, title, year/date. Also if a series is given a number field have to be provided.

\DeclareDatamodelConstraints[book,collection]{
  \constraint[type=mandatory]{
    \constraintfield{publisher}
    \constraintfield{location}
    \constraint[type=conditional]{
        \antecedent[quantifier=all]{
            \constraintfield{series}
        }
        \consequent[quantifier=all]{
            \constraintfield{number}
        }
    }
  }
}

For incollections and inproceedings pages should be given so I've added:

\DeclareDatamodelConstraints[incollection,inproceedings]{
  \constraint[type=mandatory]{
    \constraintfield{pages}
  }
}

In the standard configuration eprint, eprintclass and eprinttype are not specified for the online entrytype. To change this I added:

\DeclareDatamodelEntryfields[online]{
  eprint,
  eprintclass,
  eprinttype,
  archiveprefix
}

And last I wanted all entry types to contain the langid field and when the publisher field is given also the location field has to be present:

\DeclareDatamodelConstraints[
  article,
  book,
  inbook,
  bookinbook,
  suppbook,
  booklet,
  collection,
  incollection,
  suppcollection,
  manual,
  misc,
  mvbook,
  mvcollection,
  online,
  patent,
  periodical,
  suppperiodical,
  proceedings,
  inproceedings,
  reference,
  inreference,
  report,
  set,
  thesis,
  unpublished]{
    \constraint[type=mandatory]{
        \constraintfield{langid}
    }
    \constraint[type=conditional]{
        \antecedent[quantifier=all]{
            \constraintfield{publisher}
        }
        \consequent[quantifier=all]{
            \constraintfield{location}
        }
    }
  }
user2653422
  • 2,333