diff --git a/doc/latex.rst b/doc/latex.rst index ebc14765e..b027528fa 100644 --- a/doc/latex.rst +++ b/doc/latex.rst @@ -438,7 +438,14 @@ Let us now list some macros from the package file the new macros are wrappers of the formerly hard-coded ``\texttt``, ``\emph``, ... The default definitions can be found in :file:`sphinx.sty`. -- paragraph level environments: for each admonition type ````, the +- a :dudir:`figure` may have an optional legend with arbitrary body + elements: they are rendered in a ``sphinxlegend`` environment. The default + definition issues ``\small``, and ends with ``\par``. + + .. versionadded:: 1.5.6 + formerly, the ``\small`` was hardcoded in LaTeX writer and the ending + ``\par`` was lacking. +- for each admonition type ````, the used environment is named ``sphinx``. They may be ``\renewenvironment`` 'd individually, and must then be defined with one argument (it is the heading of the notice, for example ``Warning:`` for :dudir:`warning` directive, if diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index 15f9910ff..7a142c116 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -1383,6 +1383,8 @@ \protected\def\sphinxstyleliteralstrong {\sphinxbfcode} \protected\def\sphinxstyleabbreviation {\textsc} \protected\def\sphinxstyleliteralintitle {\sphinxcode} +% figure legend comes after caption and may contain arbitrary body elements +\newenvironment{sphinxlegend}{\par\small}{\par} % LaTeX writer uses macros to hide double quotes from \sphinxcode's \@noligs \protected\def\sphinxquotedblleft{``} diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index be0771c09..44155da71 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1599,10 +1599,10 @@ class LaTeXTranslator(nodes.NodeVisitor): self.unrestrict_footnote(node) def visit_legend(self, node): - self.body.append('{\\small ') + self.body.append('\n\\begin{sphinxlegend}') def depart_legend(self, node): - self.body.append('}') + self.body.append('\\end{sphinxlegend}\n') def visit_admonition(self, node): self.body.append('\n\\begin{sphinxadmonition}{note}')