diff --git a/CHANGES b/CHANGES index 0ba260bc5..347d53286 100644 --- a/CHANGES +++ b/CHANGES @@ -8,6 +8,8 @@ Incompatible changes to accelerate stemming. * Now sphinx_rtd_theme become optional. Please install it manually. Refs #2087, #2086, #1845 and #2097. Thanks to Victor Zverovich. +* #2231: Use DUrole instead of DUspan for custom roles in LaTeX writer. It enables to take + title of roles as an argument of custom macros. Features added diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index 138e84f54..f94d5c934 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -444,15 +444,18 @@ \RequirePackage{hypcap} % From docutils.writers.latex2e -\providecommand{\DUspan}[2]{% - {% group ("span") to limit the scope of styling commands - \@for\node@class@name:=#1\do{% - \ifcsname docutilsrole\node@class@name\endcsname% - \csname docutilsrole\node@class@name\endcsname% +% inline markup (custom roles) +% \DUrole{#1}{#2} tries \DUrole#1{#2} +\providecommand*{\DUrole}[2]{% + \ifcsname DUrole#1\endcsname% + \csname DUrole#1\endcsname{#2}% + \else% backwards compatibility: try \docutilsrole#1{#2} + \ifcsname docutilsrole#1\endcsname% + \csname docutilsrole#1\endcsname{#2}% + \else% + #2% \fi% - }% - {#2}% node content - }% close "span" + \fi% } \providecommand*{\DUprovidelength}[2]{ diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index a04804fa0..dd997361c 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1886,7 +1886,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.body.append(r'\underline{') self.context.append('}') elif classes and not self.in_title: - self.body.append(r'\DUspan{%s}{' % ','.join(classes)) + self.body.append(r'\DUrole{%s}{' % ','.join(classes)) self.context.append('}') else: self.context.append('')