Support containers in LaTeX output.

Support containers in the LaTeX writer by outputting the start and end
of a LaTeX group, wrapping the beginning and end of a LaTeX
environment. The class name(s) are passed as an argument to the
environment.
This commit is contained in:
David Ham 2021-05-03 21:50:22 +01:00
parent f31af4b815
commit 31f7eae822
3 changed files with 21 additions and 2 deletions

View File

@ -270,6 +270,11 @@
\input{sphinxlatexshadowbox.sty}
%% CONTAINERS
%
\input{sphinxlatexcontainers.sty}
%% PYGMENTS
% stylesheet for highlighting with pygments
\RequirePackage{sphinxhighlight}

View File

@ -0,0 +1,12 @@
%% CONTAINER DIRECTIVES
%
% change this info string if making any custom modification
\ProvidesFile{sphinxlatexcontainers.sty}[2021/05/03 containers]
% The purpose of this file is to provide a dummy environment sphinxcontainer
% which will be inserted for every container directive the container class
% name will be passed as the argument to the environment. User-defined
% formatting of directives can be achieved by renewing the definition of
% this environment, and branching on the value of the argument.
\newenvironment{sphinxcontainer}[1]{}{}

View File

@ -1975,10 +1975,12 @@ class LaTeXTranslator(SphinxTranslator):
pass
def visit_container(self, node: Element) -> None:
pass
classes = node.get('classes', [])
self.body.append(
'\n\\bgroup\\begin{sphinxcontainer}{%s}' % ' '.join(classes))
def depart_container(self, node: Element) -> None:
pass
self.body.append('\n\\end{sphinxcontainer}\\egroup')
def visit_decoration(self, node: Element) -> None:
pass