The latex2e writer outputs \label{} for tables after \end{longtable}. This is incorrect causing the table referencing to end up with empty reference text rather than the table number. The author of the longtable latex package suggest putting the \label{} inside the caption itself \caption{My caption \label{mylabel}} or inside the table body. The latter option has the added benefit of working for tables without a caption. I've attached a proposed fix.
longtable package documentation can be found at https://mirror.ox.ac.uk/sites/ctan.org/macros/latex/required/tools/longtable.pdf. See page 4 and 5 about the discussion on labeling.
Btw, I'm a beginner when it comes to Latex. Even though the proposed patch works for my test case, please double check it to ensure it produces valid Latex.
Thank you for the report and patch.
The warning in the source (introduced 2010-02-05 in [r6255])
makes me hesitating to change the current behaviour. OTOH, it may be outdated.
Currently standard Docutils does not write
\refmacros. How do you get a table number in the document? Can you provide your test file (and info about how it is converted)?Did you try your patch with the Docutils test suite? Here, I get
FAILED (failures=4, errors=21, skipped=1)and a lot of additional (spurious) labels after longtables.Related
Commit: [r6255]
I've attached the sample table I've used. See
tables.rst. I did use the--reference-label refoption to get table numbers in the references. The attachedrun.shshows how I've run the tools.The standard named references work fine with the
\labelafter the\end{longtable}. When using\ref{}to refer to tables however, no number shows. This only seems possible when the\label{}is moved near the caption or inside table body. Seetables_edited.texfor how I'v manually edited the tex file to make it work. That is, if the table has a caption it works. For some reason I haven't been able to place a\label{}inside a table without a caption.Haven't run the docutils test suite.
I guess this whole ticket boils down to how can we get numbered tables references to work?
Thank you for the additional info, it helped to reproduce the problem.
Mind, that for references to section numbers with
reference-label: ref, you need to activate section numbering by LaTeX (sectnum-xform: False), Docutils-generated section numbers do not show up (cf. the documentation fixes in [r9395]With at least one LaTeX-numbered section in the document, a
\refto a table with title/caption (and hence Table number) also works with the\labelplaced after the table, so setting sectnum-xform toFalsefor the LaTeX writer (or using the somewhat misleading command line option--no-section-numbering) might provide a fast workaround.Does the attached patch (against [r9395]) solve the problem?
Related
Commit: [r9395]
Fixed in [r9401]. Thank you for reporting.
Related
Commit: [r9401]