sphinx-doc / sphinx-doc/sphinx

Error generating latex from Markdown with empty table

Open
#14,271 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

builder:latex type:bug
Dominant language
Python
Stars
8k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

This was found when building a document containing Markdown files, using the Myst parser. It may be a problem with the myst parser, but HTML is generated correctly. The latex builder crashes without a useful error message.

How to Reproduce

index.rst:

# Table Test

| Key |  P  | Summary |
| --- | --- | ------- |

conf.py

project = 'Latex Table'

extensions = ['myst_parser']

html_theme = 'alabaster'

Environment Information
Platform:              darwin; (macOS-15.7.3-arm64-arm-64bit)
Python version:        3.11.14 (main, Oct 28 2025, 12:11:54) [Clang 20.1.4 ])
Python implementation: CPython
Sphinx version:        9.0.4
Docutils version:      0.22.4
Jinja2 version:        3.1.6
Pygments version:      2.19.2
Sphinx extensions

Additional context
Running Sphinx v9.0.4
loading translations [en]... done
myst v5.0.0: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions=set(), disable_syntax=[], all_links_external=False, links_external_new_tab=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=0, heading_slug_func=None, html_meta={}, footnote_sort=True, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, suppress_warnings=[], highlight_code_blocks=True)
building [mo]: targets for 0 po files that are out of date
writing output... 
building [latex]: all documents
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
copying assets... 
copying TeX support files... Writing evaluated template result to /Users/jamie/Documents/Projects/latex-tables/latex/make.bat
Writing evaluated template result to /Users/jamie/Documents/Projects/latex-tables/latex/Makefile
Writing evaluated template result to /Users/jamie/Documents/Projects/latex-tables/latex/latexmkrc
Writing evaluated template result to /Users/jamie/Documents/Projects/latex-tables/latex/latexmkjarc
done
copying assets: done
processing latextable.tex... 
index

resolving references...
processing latextable.tex: failed


Versions
========

* Platform:         darwin; (macOS-15.7.3-arm64-arm-64bit)
* Python version:   3.11.14 (CPython)
* Sphinx version:   9.0.4
* Docutils version: 0.22.4
* Jinja2 version:   3.1.6
* Pygments version: 2.19.2

Last Messages
=============

    Writing evaluated template result to /Users/jamie/Documents/Projects/latex-tables/latex/Makefile
    Writing evaluated template result to /Users/jamie/Documents/Projects/latex-tables/latex/latexmkrc
    Writing evaluated template result to /Users/jamie/Documents/Projects/latex-tables/latex/latexmkjarc
    done
    copying assets: done
    processing latextable.tex...
    index

    resolving references...
    processing latextable.tex: failed

Loaded Extensions
=================

* sphinx.ext.mathjax (9.0.4)
* alabaster (1.0.0)
* sphinxcontrib.applehelp (2.0.0)
* sphinxcontrib.devhelp (2.0.0)
* sphinxcontrib.htmlhelp (2.1.0)
* sphinxcontrib.serializinghtml (2.0.0)
* sphinxcontrib.qthelp (2.0.0)
* myst_parser (5.0.0)

Traceback
=========

      File "/Users/jamie/.cache/uv/archive-v0/V_aHqdZh4qaKomUKPUD_9/lib/python3.11/site-packages/sphinx/builders/latex/transforms.py", line 443, in depart_table
        tbody = next(node.findall(nodes.tbody))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    StopIteration

Log file
sphinx-err-8uxyk0ll.log

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the index.rst and conf.py example, then inspect sphinx/builders/latex/transforms.py at depart_table, where the traceback shows the empty table is assumed to contain a tbody. Done should mean the empty Markdown table no longer crashes the LaTeX builder and produces a useful result or error.

Written by the indexing model from the issue text.

Assessment

Tech stack
markdown, python
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.