You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Figure or literal block captions in cells of short tables cause havoc in PDF output #3532
Subject: when a table cell contains a figure directive, and is rendered in LaTeX via threeparttable, the figure caption is used as table caption and there are other nefarious consequences.
Error logs / results
Reproducible project / your project
Welcome to FOO's documentation!
===============================
First table:
.. list-table:: This is a table
:widths: auto
:header-rows: 1
* - header 1
- header 2
* - cell
- .. figure:: more.png
No, I am not the table caption!
Second table (uses longtable):
.. cssclass:: longtable
.. list-table:: This is a table
:widths: auto
:header-rows: 1
* - header 1
- header 2
* - cell
- .. figure:: more.png
I told you I was the figure caption!
This second table does use the figure caption (but has its problems, too).
Third table:
.. list-table:: This is a table
:widths: auto
:header-rows: 1
* - header 1
- header 2
* - cell
- .. code-block:: python
:caption: No, I am not the table caption!
def foo(x):
return None
Fourth table (uses longtable):
.. cssclass:: longtable
.. list-table:: This is a table
:widths: auto
:header-rows: 1
* - header 1
- header 2
* - cell
- .. code-block:: python
:caption: I told you I was the code-block caption!
def foo(x):
return None
This fourth table does use correctly the code-block caption.
Screenshot above is with current HEAD of master. Similar result with 1.5.3., but as its vertical spacing is not so good, I preferred master for not distracting from issue.
Details
The Sphinx LaTeX takes precautions for figures regarding the \caption macro, so it works in longtable environment despite its redefintion of \caption but threeparttable redefines rather \@caption, not \caption so in this environment, the Sphinx prophylactic measures fail.
Similar issues exist with literal-blocks or anything using \caption.
Standard LaTeX does not allow such things as \caption in a table cell, which explains table packages take no special precautions.
changed the title [-]Figure or literal block captions in table cells cause havoc in PDF output[/-][+]Figure or literal block captions in cells of short tables cause havoc in PDF output[/+]on Mar 9, 2017
Activity
[-]Figure or literal block captions in table cells cause havoc in PDF output[/-][+]Figure or literal block captions in cells of short tables cause havoc in PDF output[/+]Drop usage of threeparttable LaTeX package (closes sphinx-doc#3532)
jfbu commentedon May 9, 2017
Fixed by #3686 merge (includes 5c87879)