latex builder fails if no footbibliography is present
Describe the bug
when using :footcite: without the corresponding .. footbibliography:: directive, the latex builder fails with a cryptic error message. Using the html builder results in no error.
The error is:
ValueError: No footnote was found for given reference node <footnote_reference: <#text: '1'>>
with no indication of a file. Printing out the file where the error occurs, quickly helps finding the error. It is present in the function get_footnote_by_reference which raises the error
def get_footnote_by_reference(
self, node: nodes.footnote_reference
) -> nodes.footnote:
docname = node['docname']
for footnote in self.footnotes:
if docname == footnote['docname'] and footnote['ids'][0] == node['refid']:
return footnote
print(node) # -> prints: <footnote_reference auto="1" docname="index" ids="id1" refid="footcite-eigenweb">1</footnote_reference>
raise ValueError(__('No footnote was found for given reference node %r') % node)
How to Reproduce
index.rst:
Welcome to sphinx_test's documentation!
=======================================
.. toctree::
:maxdepth: 2
:caption: Contents:
Indices and tables
==================
This is a test of :footcite:p:`eigenweb`
conf.py:
project = 'sphinx_test'
copyright = '2024, Doe'
author = 'Doe'
release = '1.0.0'
extensions = ['sphinxcontrib.bibtex']
bibtex_bibfiles = ['literature.bib']
templates_path = ['_templates']
exclude_patterns = []
numfig = True
html_theme = 'alabaster'
html_static_path = ['_static']
literature.bib:
@MISC{eigenweb,
author = {Ga\"{e}l Guennebaud and Beno\^{i}t Jacob and others},
title = {Eigen v3},
howpublished = {http://eigen.tuxfamily.org},
year = {2010}
}
Environment Information
Platform: win32; (Windows-10-10.0.26100-SP0)
Python version: 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)])
Python implementation: CPython
Sphinx version: 8.2.3
Docutils version: 0.21.2
Jinja2 version: 3.1.4
Pygments version: 2.18.0
Sphinx extensions
Additional context
No response
These roles and directives are provided by https://github.com/mcmtroffaes/sphinxcontrib-bibtex, not by core Sphinx. Although the problem could be in Sphinx core code, it may be a deficiency of the sphinxcontrib.bibtex extension. Have you tested other builders than HTML and LaTeX? Consider reporting it at https://github.com/mcmtroffaes/sphinxcontrib-bibtex first. Also perhaps check if https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/378 is related to your problem in any way or if some comments there are.
I gladly open an issure there, thanks!
I already know how to solve the error. This bug report is more like for improving the error message and hinting the user at the correct file.
I've got in touch with sphinxcontrib-bibtex: https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/379#issuecomment-3583493595
on sphinx side it should be possible to at least improve the error message