BibTeX, biblatex and biberAdding free text before first reference

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
Post Reply
Cottonshirt
Posts: 9
Joined: Thu Nov 10, 2016 11:04 pm

Adding free text before first reference

Post by Cottonshirt »

Good morning,

I am writing a latex document in Texworks with a bibliography that works fine, as per the attached MWE:

Code: Select all

\begin{filecontents}{boookfile.bib} 
@book{nchc11893,
author = "Bateson, Edward",
title = "A History of Northumberland",
publisher = "{Andrew Reed, Sons \&  Co.}",
year = "1893",
}
\end{filecontents} 

\documentclass[10pt,a4paper]{book}
\pagestyle{empty}

\usepackage[utf8]{inputenc}
\usepackage{endnotes,graphicx,makeidx}
\listfiles

\begin{document}

Some text goes here \cite[p.~n]{nchc11893}.

\bibliography{boookfile}
\bibliographystyle{plain}

\end{document}
However, I would like to add a paragraph of free text between the section title "Bibliography" and the first entry in the list of references.

Among other places I have looked for an answer, I went here: http://tug.ctan.org/tex-archive/info/bi ... ethebeast/ and downloaded the pdf document "Tame the Beast" by Nicolas Markey where on page 8 the author gives the following code:

Code: Select all

\begin{thebibliography}{GMS93}
\item[]
\hskip-\leftmargin
\begin{minipage}{\textwidth}
Here are some useful references about \LaTeX. They are
available in every worthy bookshop. Much other good documentation
may be found on the web (the FAQ of \textsf{comp.text.tex} for
instance).
\end{minipage}
\bigskip
\bibitem[GMS93]{companion} Michel Goossens, Franck Mittelbach and
Alexander
Samarin, \emph{The \LaTeX{} Companion}, Addison Wesley, 1993.
\bibitem[Lam97]{lamport} Leslie Lamport, \emph{\LaTeX: A Document Preparation
System}, Addison Wesley, 1997.
\end{thebibliography}
There are two problems with this approach:

1. the first line of his code says: \begin{thebibliography}{GMS93} where my understanding is that GMS93 is the code for the longest entry in his bibliography, and it isn't obvious to me how I would know that at the time of writing my own document.

2. He appears to have hand-coded the bibliographical entries into his document whereas I want to gather them from a database (*.bib) at compile time.

So my question is:

1. Is there a way to adapt or edit Markey's code to my purpose?

2. If not, is there some other approach I can adopt?


Many thanks for your consideration,

Cottonshirt

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Adding free text before first reference

Post by Johannes_B »

Code: Select all

\documentclass[10pt,a4paper]{book}
\pagestyle{empty}

\usepackage[utf8]{inputenc}
\listfiles

\usepackage{etoolbox}
\tracingpatches
\makeatletter
\patchcmd{\thebibliography}{%
	\@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
}{%
	\@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}%
	Place your text here\par% <<------------------------------------------
}{}{}
\makeatother
\begin{document}

Some text goes here \cite[p.~n]{doody}.

\bibliography{biblatex-examples}
\bibliographystyle{plain}

\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Cottonshirt
Posts: 9
Joined: Thu Nov 10, 2016 11:04 pm

Adding free text before first reference

Post by Cottonshirt »

thank you. I had not heard of etoolbox before but on CTAN I noticed it is part of the standard MIkTex distribution.

your elegant solution does everything I wanted, thank you very much indeed.
Post Reply