I'm trying to arrange a list of sources which, from the point of view of their content, is hierarchically grouped. Specifically "archives" and "collection within archives". I'd like to express this relation within my bibliography/biblist using biblatex. "archives" are just a title, "collection within archives" have a shorthand which is the way they will be referred to in the text. So I'm looking for something "biblist-like".
I've been struggling with defbibenvironment but could not reach a satisfactory result yet. Ideally, I'm trying to set different (independent) indents/margins/etc for each hierarchical level of sources. A sort of a nested list within defbibenvironment.
The best result I could reach was by mixing elements of the default defbibenvironments for bibliography and shorthands, conditioning settings for each case:
\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@customa{natarch,
title = {National Archives. But with a title long enough to span two lines. Yet a little longer.},
sortshorthand = {NatArch},
}
@customb{natarch:presabc,
title = {President ABC Papers. A subtitle to let it reach a second line.},
shorthand = {NatArch -- ABC},
sortshorthand = {NatArch -- ABC},
xref = {natarch},
}
@customb{natarch:mintru,
title = {Ministry of Truth Papers. Fully and continuously updated.},
shorthand = {NatArch -- MT},
sortshorthand = {NatArch -- MT},
xref = {natarch},
}
@customa{libcong,
title = {Library of Congress},
sortshorthand = {LibCon},
}
@customb{libcong:digcoll,
title = {Digital Collections of the Library of Congress. But with a title long enough to span two lines.},
shorthand = {LibCon -- DC},
sortshorthand = {LibCon -- DC},
xref = {libcong},
}
\end{filecontents}
\documentclass{article}
\usepackage[style=authortitle,minxrefs=1]{biblatex}
\usepackage{calc}
\addbibresource{\jobname.bib}
\DeclareBiblistFilter{primary}{
\filteror{
\filter[type=type,filter=customa]
\filter[type=type,filter=customb]
}
}
\DeclareBibliographyDriver{primary}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\printfield{title}%
\usebibmacro{finentry}}
\DeclareBiblistFilter{primary}{
\filteror{
\filter[type=type,filter=customa]
\filter[type=type,filter=customb]
}
}
\DeclareSortingTemplate{primary}{
\sort{
\field{sortshorthand}
}
\sort{
\field{shorthand}
}
}
\defbibenvironment{primary}
{\list
{}
{\setlength{\leftmargin}{\bibhang+\biblabelsep}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}%
\renewcommand*{\makelabel}[1]{##1\hss}}}
{\endlist}
{\ifentrytype{customa}
{\item}{}
\ifentrytype{customb}
{\setlength{\labelwidth}{\shorthandwidth}%
\setlength{\labelsep}{\biblabelsep}%
\setlength{\itemindent}{\shorthandwidth-.5\biblabelsep}%
\item[\printfield{shorthand}]}{}
}
\begin{document}
\nocite{libcong:digcoll,natarch:mintru,natarch:presabc}
\printbiblist[title={Primary sources}]{primary}
\printshorthands
\printbibliography
\end{document}
Which results in:
The would be desired result is the first one "Primary sources", the others are there for comparison. With this approach I could not escape from a global setting for leftmargin, which is the same for the two type of entries. I could only change their respective indents.
Ideally, I'd like the "archive" to behave just like an entry in a bibliography (as in "References") and the "archive in collection" to behave just like a list of shorthands (as in "Abbreviations", that is, with left margin at shorthandwidth+biblabelsep), with an extra indent to emphasize the grouping.
Other approaches considered were:
Use of
biblatex'srelatedfacilities, as withmultivolumerelatedtype. This has two problems for my settings. First, the indent for the related entries would be not ideal for the multiline case. Second, and more important for me, is that I need the hook for the individual child entry in the bibliography for linking purposes from the citations, and I don't want it in duplicity.Use of some mechanism like
bibbycategory. That would actually be a good idea, having the mother entry as a bibheading and a proper biblist for the child entries. However, my list of sources is longer and I don't want to populate it manually. Furthermore, I wouldn't like to restrict the use of thecategorymechanism just for that (though I probably could restrain the loop for the categories of interest, I suppose). Anyway, I couldn't devise a way to populate it automatically (DeclareSourcemap, as far as I understand, cannot create a category, so I was already stuck at this point).I've also tried something in the line of Guido's answer to biblatex, biber, how to create a loop to \printbibliography year after year from xxxx to yyyy?, which involves removing the
\itemfromdefbibenvironmentand dealing with it at the bibentry, but I could not get any working solution in these lines.I've also considered Philippe Goutet's answer to Change hanging indent in description list, but it is beyond my understanding and thus I cannot really adapt it for my purposes, if that is indeed possible.
I've also attempted to start from a standard
printbibliographyand to redefine the bibdriver of the child entry to try to emulate a biblist entry withmboxes,parboxesandtabulars. But this approach seems to stretch by a long shot the bibdriver, and biblatex loses the grip on vertical spacing and punctuation. Though these issues might be eventually circumvented, I thought this line to be not a very wise one.



customaandcustombitems are sorted together, there is no second level of the sorting. So, if you changesortkeyof thenatarchtosortkey = {a}leaving everything other unchanged, it will generate incorrect result. In your previous solution a sorting ot thecustombitems was made inside appropriatecustomaitem. – andc Jun 26 '19 at 13:12xreffield is not used at all so entire logic is based on the sortkeys. But even such a solution is extremely helpful to me. – andc Jun 26 '19 at 18:41