diff --git a/CHANGES b/CHANGES index dcb1b581e..a436038eb 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,7 @@ Bugs fixed * #5016: ``character_level_inline_markup`` setting is not initialized for combination of non reST source parsers (ex. recommonmark) and docutils-0.13 * #5022: latex: crashed with docutils package provided by Debian/Ubuntu +* #5009: latex: a label for table is vanished if table does not have a caption Testing -------- diff --git a/sphinx/templates/latex/longtable.tex_t b/sphinx/templates/latex/longtable.tex_t index b7310a780..9b8c46d81 100644 --- a/sphinx/templates/latex/longtable.tex_t +++ b/sphinx/templates/latex/longtable.tex_t @@ -9,8 +9,12 @@ <%= table.get_colspec() %> <%- if table.caption -%> \caption{<%= ''.join(table.caption) %>\strut}<%= labels %>\\*[\sphinxlongtablecapskipadjust] -<% endif -%> \hline +<% elif labels -%> +\hline\noalign{\phantomsection<%= labels %>}% +<% else -%> +\hline +<% endif -%> <%= ''.join(table.header) %> \endfirsthead diff --git a/sphinx/templates/latex/tabular.tex_t b/sphinx/templates/latex/tabular.tex_t index 3fd347e53..26e4ff107 100644 --- a/sphinx/templates/latex/tabular.tex_t +++ b/sphinx/templates/latex/tabular.tex_t @@ -14,6 +14,8 @@ \sphinxcapstartof{table} \sphinxcaption{<%= ''.join(table.caption) %>}<%= labels %> \sphinxaftercaption +<% elif labels -%> +\phantomsection<%= labels %> <% endif -%> \begin{tabular}[t]<%= table.get_colspec() -%> \hline diff --git a/sphinx/templates/latex/tabulary.tex_t b/sphinx/templates/latex/tabulary.tex_t index 16d15192b..385076529 100644 --- a/sphinx/templates/latex/tabulary.tex_t +++ b/sphinx/templates/latex/tabulary.tex_t @@ -14,6 +14,8 @@ \sphinxcapstartof{table} \sphinxcaption{<%= ''.join(table.caption) %>}<%= labels %> \sphinxaftercaption +<% elif labels -%> +\phantomsection<%= labels %> <% endif -%> \begin{tabulary}{\linewidth}[t]<%= table.get_colspec() -%> \hline