## A LaTeX Bibliography Hack

Yet another LaTeX hack! This time to insert text between the bibliography/reference header and the actual references. I’ve had, I admit, no really good reason to do this, as I might have added some text before the bibliography, but it made a lot more sense to include the paragraph there.

This one is not particularly hard to hack. If you use a bibliography style other than plain, like natbib, you may already have a variable to define that will contain the text (\bibpreamble{...}). But I use plain, modified to suit my own needs—because of reasons and that’s it.

There’s no obvious way of doing so if your bibtex style doesn’t provide for this. The workaround I found is to redefine the thebibliography environment itself. As I am using the book document class, I just stuck this definition somewhere in the document’s preamble:

\makeatletter
\renewenvironment{thebibliography}[1]
{\chapter*{\bibname}%
\@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
\input{back-matter/bibliography-summary}%
\list{\@biblabel{\@arabic\c@enumiv}}%
{\settowidth\labelwidth{\@biblabel{#1}}%
\leftmargin\labelwidth
\@openbib@code
\usecounter{enumiv}%
\let\p@enumiv\@empty
\renewcommand\theenumiv{\@arabic\c@enumiv}}%
\sloppy
\clubpenalty4000
\@clubpenalty \clubpenalty
\widowpenalty4000%
\sfcode\.\@m}
{\def\@noitemerr
{\@latex@warning{Empty thebibliography' environment}}%
\endlist}
\makeatother


The only modifications are contained in the two highlighted lines. The first makes sure that the bibliography appears in the table of contents (and the PDF index, if you’re using pdflatex). The second inputs a block of LaTeX so that it get displayed just after the title but before the list containing the bibliography itself.