diff --git a/sphinx/templates/latex/tabular.tex_t b/sphinx/templates/latex/tabular.tex_t index 95a8e84e6..3fd347e53 100644 --- a/sphinx/templates/latex/tabular.tex_t +++ b/sphinx/templates/latex/tabular.tex_t @@ -12,7 +12,7 @@ <%- endif %> <% if table.caption -%> \sphinxcapstartof{table} -\sphinxcaptionof{table}{<%= ''.join(table.caption) %>}<%= labels %> +\sphinxcaption{<%= ''.join(table.caption) %>}<%= labels %> \sphinxaftercaption <% endif -%> \begin{tabular}[t]<%= table.get_colspec() -%> diff --git a/sphinx/templates/latex/tabulary.tex_t b/sphinx/templates/latex/tabulary.tex_t index da9df1c48..16d15192b 100644 --- a/sphinx/templates/latex/tabulary.tex_t +++ b/sphinx/templates/latex/tabulary.tex_t @@ -12,7 +12,7 @@ <%- endif %> <% if table.caption -%> \sphinxcapstartof{table} -\sphinxcaptionof{table}{<%= ''.join(table.caption) %>}<%= labels %> +\sphinxcaption{<%= ''.join(table.caption) %>}<%= labels %> \sphinxaftercaption <% endif -%> \begin{tabulary}{\linewidth}[t]<%= table.get_colspec() -%> diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index 1fe8d3d30..d0d31ca61 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -113,7 +113,7 @@ % move back vertically to compensate space inserted by next paragraph \vskip-\baselineskip\vskip-\parskip }% -\newcommand\sphinxcaptionof[3][\LTcapwidth]{% +\newcommand\sphinxcaption[2][\LTcapwidth]{% \noindent\hb@xt@\linewidth{\hss \vtop{\@tempdima\dimexpr#1\relax % don't exceed linewidth for the caption width @@ -121,8 +121,8 @@ % longtable ignores \abovecaptionskip/\belowcaptionskip, so do the same here \abovecaptionskip\z@skip \belowcaptionskip\z@skip - \caption[{#3}]% - {\strut\ignorespaces#3\ifhmode\unskip\@finalstrut\strutbox\fi}% + \caption[{#2}]% + {\strut\ignorespaces#2\ifhmode\unskip\@finalstrut\strutbox\fi}% }\hss}% \par\prevdepth\dp\strutbox }% diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 42e0e8476..43e88f084 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -492,7 +492,7 @@ def test_footnote(app, status, warning): assert ('\\bibitem[bar]{\\detokenize{bar}}' '{\\phantomsection\\label{\\detokenize{footnote:bar}} ' '\ncite\n}') in result - assert '\\sphinxcaptionof{table}{Table caption \\sphinxfootnotemark[4]' in result + assert '\\sphinxcaption{Table caption \\sphinxfootnotemark[4]' in result assert ('\\hline%\n\\begin{footnotetext}[4]\\sphinxAtStartFootnote\n' 'footnote in table caption\n%\n\\end{footnotetext}\\ignorespaces %\n' '\\begin{footnotetext}[5]\\sphinxAtStartFootnote\n' @@ -517,7 +517,7 @@ def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning): '{\\hyperref[\\detokenize{index:authoryear}]' '{\\sphinxcrossref{{[}AuthorYear{]}}}}.}' in result) assert '\\chapter{The section with a reference to {[}AuthorYear{]}}' in result - assert ('\\sphinxcaptionof{table}{The table title with a reference' + assert ('\\sphinxcaption{The table title with a reference' ' to {[}AuthorYear{]}}' in result) assert '\\paragraph{The rubric title with a reference to {[}AuthorYear{]}}' in result assert ('\\chapter{The section with a reference to \\sphinxfootnotemark[4]}\n' @@ -528,7 +528,7 @@ def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning): '\\sphinxfootnotemark[6].}\\label{\\detokenize{index:id27}}\\end{figure}\n' '%\n\\begin{footnotetext}[6]\\sphinxAtStartFootnote\n' 'Footnote in caption\n%\n\\end{footnotetext}')in result - assert ('\\sphinxcaptionof{table}{footnote \\sphinxfootnotemark[7] in ' + assert ('\\sphinxcaption{footnote \\sphinxfootnotemark[7] in ' 'caption of normal table}\\label{\\detokenize{index:id28}}') in result assert ('\\caption{footnote \\sphinxfootnotemark[8] ' 'in caption \\sphinxfootnotemark[9] of longtable\\strut}') in result @@ -896,7 +896,7 @@ def test_latex_table_tabulars(app, status, warning): table = tables['table having caption'] assert ('\\begin{savenotes}\\sphinxattablestart\n\\centering\n' '\\sphinxcapstartof{table}\n' - '\\sphinxcaptionof{table}{caption for table}' + '\\sphinxcaption{caption for table}' '\\label{\\detokenize{tabular:id1}}\n' '\\sphinxaftercaption' in table) assert ('\\begin{tabulary}{\\linewidth}[t]{|T|T|}' in table)