Proper references to figures/code/tables/etc.

Georg Brandl avatarGeorg Brandl created an issue

For things like scientific publications, floating envs like figures, tables and code displays need to be numbered and references must contain these numbers.

Comments (12)

  1. Anonymous

    Could we also add that the target page number to references is shown, e.g. "(see page xx)". This would be useful for printed documents.

    Not sure if this should be added as a separate issue, though.

  2. Anonymous

    +1 for me too.

    P.S.: I'm also willing to contribute some code, but I may need some coaching for the dev process.

  3. Martin Gaitan

    Hi, I did a hack because I really needed this behavior for my thesis report. I attach the patch.

    The added code check the reference label and if it has '-num' as suffix write a \ref{} as latex output instead a \hyperref

    Obviously , it's a dirty thing, but maybe could be a base to a new role like :refnum: or an alternative behavior (settable via conf.py) to :ref: just for figure targets.

    I also wrote a post (in Spanish) with a little example of the problem an the result: http://nqnwebs.com/blog/article/referenciar-figuras-por-numero-en

  4. bmu

    For latex I changed by using "\ref" or "\autoref" for internal links. If you want to use "\autoref" or "\ref" could perhaps be switched with a config value, e.g. latex_use_autoref=True.

    the patch doesn't work if latex_show_pagerefs is True, but this could easily be adapted.

  5. bmu

    For html I tried this with an extension (see attachment). This works for modification of the figurelabels and the references to figures. But: the figures are not numbered correctly, because every document stands for its own and consistent numbering for the all documents is not possble..

    So I don't think this can be changed with an extension, but with something like the method "assign_section_numbers" in class BuildEnvironment.

    If there is a dictionary for figures, tables and sections (there is one for sections) in the environment, one could use this to change figure and table captions and references.

    by the way: thanks for sphinx. I'm beginning to understand it and I learned a lot.

  6. Anonymous

    I just want to add that in the current version of 1.1.2 the pagerefs for tables are set wrong. A phantomsection with the label is created before the tabular environment so that all references point to the page where the reference is set not to the page where the table is printed in LaTeX.

  7. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.