diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 837542c4d..51f0607b2 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1530,9 +1530,10 @@ class LaTeXTranslator(nodes.NodeVisitor): self.body.append('\\begin{enumerate}\n') self.body.append('\\def\\the%s{%s{%s}}\n' % (enum, style, enum)) - self.body.append('\\def\\label%s{\\the%s.}\n' % (enum, enum)) - self.body.append('\\makeatletter\\def\\p@%s{\\p@%s\\the%s.}\\makeatother\n' % - (enumnext, enum, enum)) + self.body.append('\\def\\label%s{%s\\the%s %s}\n' % + (enum, node['prefix'], enum, node['suffix'])) + self.body.append('\\makeatletter\\def\\p@%s{\\p@%s %s\\the%s %s}\\makeatother\n' % + (enumnext, enum, node['prefix'], enum, node['suffix'])) if 'start' in node: self.body.append('\\setcounter{%s}{%d}\n' % (enum, node['start'] - 1)) if self.table: diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 6be772bbe..2f66c4e89 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -1230,24 +1230,24 @@ def test_latex_nested_enumerated_list(app, status, warning): result = (app.outdir / 'test.tex').text(encoding='utf8') assert ('\\def\\theenumi{\\arabic{enumi}}\n' - '\\def\\labelenumi{\\theenumi.}\n' - '\\makeatletter\\def\\p@enumii{\\p@enumi\\theenumi.}\\makeatother\n' + '\\def\\labelenumi{\\theenumi .}\n' + '\\makeatletter\\def\\p@enumii{\\p@enumi \\theenumi .}\\makeatother\n' '\\setcounter{enumi}{4}\n' in result) assert ('\\def\\theenumii{\\alph{enumii}}\n' - '\\def\\labelenumii{\\theenumii.}\n' - '\\makeatletter\\def\\p@enumiii{\\p@enumii\\theenumii.}\\makeatother\n' + '\\def\\labelenumii{\\theenumii .}\n' + '\\makeatletter\\def\\p@enumiii{\\p@enumii \\theenumii .}\\makeatother\n' '\\setcounter{enumii}{3}\n' in result) assert ('\\def\\theenumiii{\\arabic{enumiii}}\n' - '\\def\\labelenumiii{\\theenumiii.}\n' - '\\makeatletter\\def\\p@enumiv{\\p@enumiii\\theenumiii.}\\makeatother\n' + '\\def\\labelenumiii{\\theenumiii )}\n' + '\\makeatletter\\def\\p@enumiv{\\p@enumiii \\theenumiii )}\\makeatother\n' '\\setcounter{enumiii}{9}\n' in result) assert ('\\def\\theenumiv{\\arabic{enumiv}}\n' - '\\def\\labelenumiv{\\theenumiv.}\n' - '\\makeatletter\\def\\p@enumv{\\p@enumiv\\theenumiv.}\\makeatother\n' + '\\def\\labelenumiv{(\\theenumiv )}\n' + '\\makeatletter\\def\\p@enumv{\\p@enumiv (\\theenumiv )}\\makeatother\n' '\\setcounter{enumiv}{23}\n' in result) assert ('\\def\\theenumii{\\roman{enumii}}\n' - '\\def\\labelenumii{\\theenumii.}\n' - '\\makeatletter\\def\\p@enumiii{\\p@enumii\\theenumii.}\\makeatother\n' + '\\def\\labelenumii{\\theenumii .}\n' + '\\makeatletter\\def\\p@enumiii{\\p@enumii \\theenumii .}\\makeatother\n' '\\setcounter{enumii}{2}\n' in result)