How to split the bibliography alphabetically?
You can create a category for each letter in the alphabet and, with \AtDataInput
, add entries to each category on the basis of the sortinit
field.
\documentclass{book}
\usepackage[style=alphabetic]{biblatex}
\addbibresource{biblatex-examples.bib}
\nocite{angenendt,bertram,doody,gillies}
% user-level test for skipbib enabled (e.g. related entry matuz:doody)
\makeatletter
\def\ifskipbib{\iftoggle{blx@skipbib}}
\makeatother
\def\initlist{}
\forcsvlist{\listadd\initlist}{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z}
\forlistloop{\DeclareBibliographyCategory}{\initlist}
\renewcommand*{\do}[1]{\defbibheading{#1}{\section*{#1}}}
\dolistloop{\initlist}
\AtDataInput{\ifskipbib{}{\addtocategory{\thefield{sortinit}}{\thefield{entrykey}}}}
\begin{document}
\printbibheading
\bibbycategory
\end{document}
Note that we need to access some internals to avoid entries that are skipped in the bibliography. I keep forgetting to make these toggle values available to the user, but we'll get around to it soon.
Here a hack of the internal bibitem
:
\documentclass[]{scrartcl}
\usepackage[style=alphabetic]{biblatex}
\makeatletter
\def\blx@head@tempa{0}
\def\blx@bibitem#1{%
\blx@ifdata{#1}
{\begingroup
\blx@getdata{#1}%
\blx@imc@iffieldequals{sortinit}\blx@head@tempa{}{\item[]\textbf{\thefield{sortinit}}}%
\global\let\blx@head@tempa\abx@field@sortinit%
\blx@bibcheck
\global\let\blx@noitem\@empty
\iftoggle{blx@skipentry}{}{%
\blx@setoptions@type\abx@field@entrytype
\blx@setoptions@entry
\blx@thelabelnumber
\blx@addprefixnumber
\addtocounter{instcount}\@ne
\csuse{blx@item@\blx@theenv}\relax
\blx@initsep
\blx@namesep
\csuse{blx@hook@bibitem}%
\blx@execute
\blx@initunit
\blx@anchor
\blx@beglangbib
\bibsentence
\blx@pagetracker
\blx@driver\abx@field@entrytype
\blx@postpunct
\blx@endlangbib}%
\endgroup}
{}}
\makeatother
\addbibresource{biblatex-examples.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
Although the marking of alphabetical sections with "heading letters" is sometimes used for indexes, I have never encountered such letters in bibliographies. I suggest to only add extra spacing between alphabetical sections; with biblatex
, this can be done by simply setting the \bibinitsep
length to a positive value.
\documentclass{book}
\usepackage[style=authoryear]{biblatex}
\setlength{\bibinitsep}{\baselineskip}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
@misc{A02,
author = {Author, A.},
year = {2002},
title = {And now for something completely different},
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\nocite{*}
\begin{document}
\printbibliography
\end{document}