Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LaTeX: adding a footnote to a longtable cell causes table to occupy full width #8828

Open
jfbu opened this issue Feb 5, 2021 · 2 comments
Open

Comments

@jfbu
Copy link
Contributor

jfbu commented Feb 5, 2021

Describe the bug
A clear and concise description of what the bug is.

Capture d’écran 2021-02-05 à 14 56 59

To Reproduce
Steps to reproduce the behavior:

.. list-table:: longtable 1
    :header-rows: 1
    :class: longtable

    * - name
      - description
    * - a
      - b

.. list-table:: longtable 2
    :header-rows: 1
    :class: longtable

    * - name
      - description
    * - a
      - b [#]_


.. [#] footnote in longtable cell

and make latexpdf

Expected behavior
Table retains same width

Environment info

  • OS: [e.g. Unix/Linux/Mac/Win/other with version]
  • Python version: 3.8.7 (CPython)
  • Sphinx version: 3.4
  • Sphinx extensions: [e.g. sphinx.ext.autodoc, recommonmark]
  • Extra tools: TeXLive 2020
@jfbu jfbu added this to the 4.0.0 milestone Feb 5, 2021
@tk0miya tk0miya modified the milestones: 4.0.0, 4.1.0 Apr 19, 2021
@tk0miya tk0miya modified the milestones: 4.1.0, 5.0.0 Jul 10, 2021
@tk0miya tk0miya modified the milestones: 5.0.0, 5.x May 2, 2022
@AA-Turner AA-Turner modified the milestones: 5.x, 6.x Oct 4, 2022
@picnixz
Copy link
Member

picnixz commented Apr 15, 2023

The issue lies with the LaTeXTranslator:

sphinx/sphinx/writers/latex.py

Lines 1030 to 1031 in b6e6805

if len(list(node.findall(nodes.paragraph))) >= 2:
self.table.has_oldproblematic = True

and

elif self.has_oldproblematic:
return r'{%s*{%d}{\X{1}{%d}%s}}' % (_colsep, self.colcount,
self.colcount, _colsep) + CR

Because the footnote notes nodes are detected as problematic-like nodes, the table is marked as problematic, causing the usage of \begin{longtable}[c]{*{2}{\X{1}{2}}} instead of \begin{longtable}[c]{ll}.

For the "problematic" detection, we could reject nodes that are nodes.paragraph instances, but not just wrappers for nodes.footnote nodes.

@jfbu
Copy link
Contributor Author

jfbu commented Apr 16, 2023

@picnixz Thanks! I have long felt the problematic handling was problematic (could not resist). Until mid to end-May I am very busy so will probably look at this not before that date.

@AA-Turner AA-Turner modified the milestones: 6.x, 7.x Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants