1

How can I tell LaTeX to write additional content to bbl file?

Background of my question (see also MWE below): The page number for the bibliography displayed in the table of contents is correct if and only if \addcontentsline{toc}{chapter}{Bibliography} is placed at the beginning of the thebibliography environment. Hence, using bibTeX I need to write \addcontentsline{toc}{chapter}{Bibliography} into the bbl file. If I place it before \begin{thebibliography} the page number is first page of bibliography - 1, if I place it after \end{thebibliography} it is last page of bibliography + 1 (which in the MWE would be correct but not in general).

\documentclass{book}

\begin{document}
\tableofcontents

\begin{thebibliography}{B}
\addcontentsline{toc}{chapter}{Bibliography}
\bibitem[B]{B}
A. Brown
\newblock {\em Mathematics}.
\end{thebibliography}

\end{document}

1 Answer 1

5

The correct approach to add a bibliography entry to the ToC is not to fiddle with the .bbl file, but a) to add \addcontentsline{toc}{(sectioning level>}{Bibliography} to the (class-dependend!) definition of the thebibliography environment or b) to load packages for this task, e.g., \usepackage[nottoc]{tocbibind}.

See also Bibliography in table of contents; Gonzalo Medina's answer shows how to patch the thebibliography environment for the book class.

3
  • Apparently tocbibind is incompatible with imakeidx. In particular, including tocbibind results in the loss of `\indexprologue{abc}. Therefore I do no like including a package just for this purpose. One never knows what side effects new packages may possibly have ...
    – lpdbw
    Commented Feb 24, 2013 at 17:00
  • 2
    @lpdbw Use Gonzalo Medina's approach or try to load imakeidx after tocbibind.
    – lockstep
    Commented Feb 24, 2013 at 17:02
  • Yes, loading imakeidx after tocibind works. I wonder whether there are other unwanted effects due to tocibind which I am still ignoring ... I also tried Gonzalo Medina's second approach (the one with redefining \thebibliography) ... a remaining issue in combination with hyperref, is that if I click on the ToC entry for the bibliography, I jump to the first bib entry but not (as it should be) to the title of the bibliography ... maybe I will make this a comment of Medina's answer.
    – lpdbw
    Commented Feb 24, 2013 at 17:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .
https://tex.stackexchange.com/questions/99732/how-to-write-additional-content-into-bbl-file
tex.stackexchange.com
CC-MAIN-2024-38
151182
application/http; msgtype=response
sha1:H6LM7E32UNOGWNWFTJRRCGOHEQIB4F2A
<urn:uuid:8e7fdb93-9570-4669-93f9-d8fc4b6afe40>
2024-09-18T21:42:20Z
104.18.43.226
text/html
sha1:32MV7BYEXUUFUXZO4Z46CSRRTWLFCMXY
<urn:uuid:38694d71-b354-4b9b-b3d6-2135f6fa0b10>
https://tex.stackexchange.com/questions/99732/how-to-write-additional-content-into-bbl-file
response
<urn:uuid:6d13c8cc-b99a-4f58-a91a-92922592feaf>
isPartOf: CC-MAIN-2024-38
publisher: Common Crawl
description: Wide crawl of the web for September 2024
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-209
software: Apache Nutch 1.20 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.5-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/