TeX - LaTeX Asked on March 9, 2021
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:
And I would like to have something like that:
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}%
newunitnewblock
printfield{volume}%
newunitnewblock
printfield{section}%
newunitnewblock
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?
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{globalundefbbx@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}%
newunitnewblock
printfield{volume}%
newunitnewblock
printfield{section}%
newunitnewblock
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}
Correct answer by moewe on March 9, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP