Merge pull request #5012 from tk0miya/5009_label_for_table_on_latex

Fix #5009: latex: a label for table is vanished if table does not have a caption
This commit is contained in:
Takeshi KOMIYA 2018-06-08 21:40:35 +09:00 committed by GitHub
commit 40d84aa845
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 27 additions and 3 deletions

View File

@ -20,6 +20,7 @@ Bugs fixed
* sphinx.testing uses deprecated pytest API; ``Node.get_marker(name)`` * sphinx.testing uses deprecated pytest API; ``Node.get_marker(name)``
* #5016: crashed when recommonmark.AutoStrictify is enabled * #5016: crashed when recommonmark.AutoStrictify is enabled
* #5022: latex: crashed with docutils package provided by Debian/Ubuntu * #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 Testing
-------- --------

View File

@ -9,8 +9,12 @@
<%= table.get_colspec() %> <%= table.get_colspec() %>
<%- if table.caption -%> <%- if table.caption -%>
\caption{<%= ''.join(table.caption) %>\strut}<%= labels %>\\*[\sphinxlongtablecapskipadjust] \caption{<%= ''.join(table.caption) %>\strut}<%= labels %>\\*[\sphinxlongtablecapskipadjust]
<% endif -%>
\hline \hline
<% elif labels -%>
\hline\noalign{\phantomsection<%= labels %>}%
<% else -%>
\hline
<% endif -%>
<%= ''.join(table.header) %> <%= ''.join(table.header) %>
\endfirsthead \endfirsthead

View File

@ -14,6 +14,8 @@
\sphinxcapstartof{table} \sphinxcapstartof{table}
\sphinxcaption{<%= ''.join(table.caption) %>}<%= labels %> \sphinxcaption{<%= ''.join(table.caption) %>}<%= labels %>
\sphinxaftercaption \sphinxaftercaption
<% elif labels -%>
\phantomsection<%= labels %>
<% endif -%> <% endif -%>
\begin{tabular}[t]<%= table.get_colspec() -%> \begin{tabular}[t]<%= table.get_colspec() -%>
\hline \hline

View File

@ -14,6 +14,8 @@
\sphinxcapstartof{table} \sphinxcapstartof{table}
\sphinxcaption{<%= ''.join(table.caption) %>}<%= labels %> \sphinxcaption{<%= ''.join(table.caption) %>}<%= labels %>
\sphinxaftercaption \sphinxaftercaption
<% elif labels -%>
\phantomsection<%= labels %>
<% endif -%> <% endif -%>
\begin{tabulary}{\linewidth}[t]<%= table.get_colspec() -%> \begin{tabulary}{\linewidth}[t]<%= table.get_colspec() -%>
\hline \hline

View File

@ -1,7 +1,7 @@
\label{\detokenize{longtable:longtable-having-widths-option}} \label{\detokenize{longtable:longtable-having-widths-option}}
\begin{savenotes}\sphinxatlongtablestart\begin{longtable}{|\X{30}{100}|\X{70}{100}|} \begin{savenotes}\sphinxatlongtablestart\begin{longtable}{|\X{30}{100}|\X{70}{100}|}
\hline \hline\noalign{\phantomsection\label{\detokenize{longtable:namedlongtable}}\label{\detokenize{longtable:mylongtable}}}%
\sphinxstyletheadfamily \sphinxstyletheadfamily
header1 header1
&\sphinxstyletheadfamily &\sphinxstyletheadfamily
@ -43,3 +43,5 @@ cell3-2
\\ \\
\hline \hline
\end{longtable}\sphinxatlongtableend\end{savenotes} \end{longtable}\sphinxatlongtableend\end{savenotes}
See {\hyperref[\detokenize{longtable:mylongtable}]{\sphinxcrossref{mylongtable}}}, same as {\hyperref[\detokenize{longtable:namedlongtable}]{\sphinxcrossref{\DUrole{std,std-ref}{this one}}}}.

View File

@ -2,6 +2,7 @@
\begin{savenotes}\sphinxattablestart \begin{savenotes}\sphinxattablestart
\centering \centering
\phantomsection\label{\detokenize{tabular:namedtabular}}\label{\detokenize{tabular:mytabular}}
\begin{tabular}[t]{|\X{30}{100}|\X{70}{100}|} \begin{tabular}[t]{|\X{30}{100}|\X{70}{100}|}
\hline \hline
\sphinxstyletheadfamily \sphinxstyletheadfamily
@ -28,3 +29,5 @@ cell3-2
\end{tabular} \end{tabular}
\par \par
\sphinxattableend\end{savenotes} \sphinxattableend\end{savenotes}
See {\hyperref[\detokenize{tabular:mytabular}]{\sphinxcrossref{\DUrole{std,std-ref}{this}}}}, same as {\hyperref[\detokenize{tabular:namedtabular}]{\sphinxcrossref{namedtabular}}}.

View File

@ -18,9 +18,12 @@ longtable
longtable having :widths: option longtable having :widths: option
-------------------------------- --------------------------------
.. _mylongtable:
.. table:: .. table::
:class: longtable :class: longtable
:widths: 30,70 :widths: 30,70
:name: namedlongtable
======= ======= ======= =======
header1 header2 header1 header2
@ -30,6 +33,8 @@ longtable having :widths: option
cell3-1 cell3-2 cell3-1 cell3-2
======= ======= ======= =======
See mylongtable_, same as :ref:`this one <namedlongtable>`.
longtable having :align: option longtable having :align: option
------------------------------- -------------------------------

View File

@ -1,4 +1,4 @@
taburar and taburary tabular and tabulary
==================== ====================
simple table simple table
@ -15,8 +15,11 @@ cell3-1 cell3-2
table having :widths: option table having :widths: option
---------------------------- ----------------------------
.. _mytabular:
.. table:: .. table::
:widths: 30,70 :widths: 30,70
:name: namedtabular
======= ======= ======= =======
header1 header2 header1 header2
@ -26,6 +29,8 @@ table having :widths: option
cell3-1 cell3-2 cell3-1 cell3-2
======= ======= ======= =======
See :ref:`this <mytabular>`, same as namedtabular_.
table having :align: option (tabulary) table having :align: option (tabulary)
-------------------------------------- --------------------------------------