From 45c63a8e2df9f0da6520fd3b4c8bf259fc9c4361 Mon Sep 17 00:00:00 2001 From: jfbu Date: Fri, 8 Jun 2018 18:45:29 +0200 Subject: [PATCH] LaTeX, follow-up to PR #5012, avoid label separated by pagebreak PR #5012 took care of this for longtable, but the problem can also arise with tabular/tabulary and is much easier to fix. --- sphinx/templates/latex/tabular.tex_t | 2 +- sphinx/templates/latex/tabulary.tex_t | 2 +- tests/roots/test-latex-table/expects/table_having_widths.tex | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sphinx/templates/latex/tabular.tex_t b/sphinx/templates/latex/tabular.tex_t index 26e4ff107..67d71c985 100644 --- a/sphinx/templates/latex/tabular.tex_t +++ b/sphinx/templates/latex/tabular.tex_t @@ -15,7 +15,7 @@ \sphinxcaption{<%= ''.join(table.caption) %>}<%= labels %> \sphinxaftercaption <% elif labels -%> -\phantomsection<%= labels %> +\phantomsection<%= labels %>\nobreak <% 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 385076529..4d3571a7b 100644 --- a/sphinx/templates/latex/tabulary.tex_t +++ b/sphinx/templates/latex/tabulary.tex_t @@ -15,7 +15,7 @@ \sphinxcaption{<%= ''.join(table.caption) %>}<%= labels %> \sphinxaftercaption <% elif labels -%> -\phantomsection<%= labels %> +\phantomsection<%= labels %>\nobreak <% endif -%> \begin{tabulary}{\linewidth}[t]<%= table.get_colspec() -%> \hline diff --git a/tests/roots/test-latex-table/expects/table_having_widths.tex b/tests/roots/test-latex-table/expects/table_having_widths.tex index 5a69d5b22..b4fcea04e 100644 --- a/tests/roots/test-latex-table/expects/table_having_widths.tex +++ b/tests/roots/test-latex-table/expects/table_having_widths.tex @@ -2,7 +2,7 @@ \begin{savenotes}\sphinxattablestart \centering -\phantomsection\label{\detokenize{tabular:namedtabular}}\label{\detokenize{tabular:mytabular}} +\phantomsection\label{\detokenize{tabular:namedtabular}}\label{\detokenize{tabular:mytabular}}\nobreak \begin{tabular}[t]{|\X{30}{100}|\X{70}{100}|} \hline \sphinxstyletheadfamily