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: the \label in a figure should be immediately after \caption, not after legend. #3704

Closed
jfbu opened this issue May 4, 2017 · 2 comments

Comments

@jfbu
Copy link
Contributor

jfbu commented May 4, 2017

Subject: a figure may have a legend. This consists of arbitrary body elements after the caption.

Currently the LaTeX writer inserts the \label right before the end of the figure environment (or wrapfigure, sphinxfigure-in-table). But, theoretically, the legend contents could contain for example a table having itself a caption. Then the \label inserted after it will result to document hyperlinks inserted by Sphinx to point to the table in the legend not to the image at top of figure environment.

Proof of concept:

capture d ecran 2017-05-04 a 10 39 48

edit: the screenshot was taken with #3702 applied. Without it the very last words caption code are slightly shifted down, because the interline spacing is not correct for the last paragraph.

Source:

Welcome to FOO's documentation!
===============================

.. figure:: more.png
   :name: afigure

   This is the caption.

   This is some legend which contains a table.

   Here is some random extra paragraph for filling up.

   Again some random paragraph and now the table:

   .. table:: A table in a legend of a figure
      :name: atable

      ===== ===== =====
      A     B     C
      ===== ===== =====
      a     b     c
      ===== ===== =====

   Notice also that the small font size does not apply to the table
   caption, due to some hard-coded ``\normalsize`` in LaTeX's caption code.

Now the link to the figure: :ref:`incorrect <afigure>`. It actually brings us
to the table.
  • Sphinx version: 1.5.5
@jfbu
Copy link
Contributor Author

jfbu commented May 4, 2017

Also, we notice that the table caption is incorrect it uses Fig. 2 like for a figure.

jfbu added a commit to jfbu/sphinx that referenced this issue Oct 7, 2018
jfbu added a commit that referenced this issue Oct 7, 2018
Fix #3704: (latex) wrong ``\label`` positioning for figures with a legend
@jfbu
Copy link
Contributor Author

jfbu commented Oct 7, 2018

Fixed at 9875a57

@jfbu jfbu closed this as completed Oct 7, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant