0

I has created a custom entry type for manage the registers of an archive where the jurisdiction is the lead element of the reference, and not an author. And I would like to configure the DeclareBibliographyDriver (using biblatex) to add the dash for references that have the same jurisdiction.

So, in my case, the bib file references.bib have the next entries (where @register is the custom entry type)

@register{refacteID312,
  jurisdiction = {Biarritz, Pyrénées Atlantiques, France},
  volume = {Etat Civil, Collection communale, Marriages (1843-1852)},
  section = {Section 1845},
  repository = {Archives Départementales des Pyrénées Atlantiques},
  repositorylocation = {Bayonne},  
}

@register{refacteID313,
  jurisdiction = {Biarritz, Pyrénées Atlantiques, France},
  volume = {Etat Civil, Collection communale, Marriages (1853-1862)},
  section = {Section 1845},
  repository = {Archives Départementales des Pyrénées Atlantiques},
  repositorylocation = {Bayonne},  
}

@book{negretoponymie1996,
    title = {Toponymie générale de la {France}},
    volume = {2},
    publisher = {Librairie Droz},
    author = {Nègre, Ernest},
    year = {1996},
}

The bibliography's output is like that:

enter image description here

And I would like to have something like that:

enter image description here

The datamodel file evidence.dbx with the entry type @register definition have the next content:

\DeclareDatamodelEntrytypes{register}
\DeclareDatamodelFields[type=field,datatype=literal]{
  jurisdiction,
  volume,
  section,
  repository,
  repositorylocation,
}
\DeclareDatamodelEntryfields[register]{
  jurisdiction,
  volume,
  section,
  repository,
  repositorylocation,
}

The tex file with the example have the next content :

\documentclass{book}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[datamodel=evidence,backend=biber,style=authortitle]{biblatex}
\addbibresource{Lib1.bib}

\DeclareFieldFormat[register]{jurisdiction}{#1}
\DeclareFieldFormat[register]{volume}{\mkbibquote{#1}}
\DeclareFieldFormat[register]{section}{#1}
\DeclareFieldFormat[register]{repository}{#1}
\DeclareFieldFormat[register]{repositorylocation}{#1}

\DeclareBibliographyDriver{register}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \printfield{jurisdiction}%
  \newunit\newblock
  \printfield{volume}%
  \newunit\newblock
  \printfield{section}%
  \newunit\newblock
  \printfield{repository}%
  \newunit
  \printfield{repositorylocation}%   
  \usebibmacro{finentry}}

\begin{document}
\nocite{*} 
\printbibliography[title={Referencias}]
\end{document}

How can I improve this body in order to put the dashes in the bibliography entries that have the same jurisdiction?

0

biblatex has everything built in to handle replacing name lists with dashes, but not literal fields. So we need to recreate what biblatex does for names for simple literal fields. A caveat of the straightforward solution shown here is that the dash check for literal fields does not interface with the dash check for name fields, so you won't get a dash if the author of a @book and the jurisdiction of a @register are the same.

The idea is to save the last jurisdiction with \savefield and compare it in the next entry with \iffieldequals.

\documentclass{article}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\begin{filecontents}{evidence.dbx}
\DeclareDatamodelEntrytypes{register}
\DeclareDatamodelFields[type=field,datatype=literal]{
  jurisdiction,
  volume,
  section,
  repository,
  repositorylocation,
}
\DeclareDatamodelEntryfields[register]{
  jurisdiction,
  volume,
  section,
  repository,
  repositorylocation,
}
\end{filecontents}
\usepackage[datamodel=evidence,backend=biber,style=authortitle]{biblatex}

\DeclareFieldFormat[register]{jurisdiction}{#1}
\DeclareFieldFormat[register]{volume}{\mkbibquote{#1}}
\DeclareFieldFormat[register]{section}{#1}
\DeclareFieldFormat[register]{repository}{#1}
\DeclareFieldFormat[register]{repositorylocation}{#1}

\makeatletter
\InitializeBibliographyStyle{\global\undef\bbx@last@jurisdiction}

\newbibmacro*{bbx:dashcheck:jurisdiction}[2]{%
  \ifboolexpr{
    test {\iffieldequals{jurisdiction}\bbx@last@jurisdiction}
    and
    not test \iffirstonpage
    and
    (
       not bool {bbx@inset}
       or
       test {\iffieldequalstr{entrysetcount}{1}}
    )
  }
    {#1}
    {#2}}

\newbibmacro*{bbx:save:jurisdiction}{%
  \savefield{jurisdiction}{\bbx@last@jurisdiction}}%

\newbibmacro{jurisdiction}{%
  \usebibmacro{bbx:dashcheck:jurisdiction}
    {\bibnamedash}
    {\usebibmacro{bbx:save:jurisdiction}%
     \printfield{jurisdiction}}}
\makeatother

\DeclareBibliographyDriver{register}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{jurisdiction}%
  \newunit\newblock
  \printfield{volume}%
  \newunit\newblock
  \printfield{section}%
  \newunit\newblock
  \printfield{repository}%
  \newunit
  \printfield{repositorylocation}%   
  \usebibmacro{finentry}}

\begin{filecontents}{\jobname.bib}
@register{refacteID312,
  jurisdiction       = {Biarritz, Pyrénées Atlantiques, France},
  volume             = {Etat Civil, Collection communale, Marriages (1843-1852)},
  section            = {Section 1845},
  repository         = {Archives Départementales des Pyrénées Atlantiques},
  repositorylocation = {Bayonne},  
}
@register{refacteID313,
  jurisdiction       = {Biarritz, Pyrénées Atlantiques, France},
  volume             = {Etat Civil, Collection communale, Marriages (1853-1862)},
  section            = {Section 1845},
  repository         = {Archives Départementales des Pyrénées Atlantiques},
  repositorylocation = {Bayonne},  
}
@book{negretoponymie1996,
  title     = {Toponymie générale de la {France}},
  volume    = {2},
  publisher = {Librairie Droz},
  author    = {Nègre, Ernest},
  year      = {1996},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*} 
\printbibliography[title={Referencias}]
\end{document}

Reference with dash.

1
  • Thank you very much for your quick and efficient response. I am new to this community and just learning Latex despite comments that I have seen that this technology is outdated. This community and the quality of your response show the opposite. Thank you!
    – Andres
    Nov 27 '20 at 21:17

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.