0

I would like to add wrap something around an existing environment.

Consider an existing environment sphinxVerbatim, I would like to renew this environment by adding something before and after that environment call. I could write this, but obviously it doesn't work:

\renewenvironment{sphinxVerbatim}[1]
    {\begin{code}\begin{sphinxVerbatim}{#1}}
    {\end{sphinxVerbatim}\end{code}}

In context, I would like to wrap my code environment around an existing environment named sphinxVerbatim:

\newtcolorbox{code}{breakable,enhanced,arc=0mm,colback=lightgray!5,colframe=lightgray}

Sphinx generates some code such as:

\begin{sphinxVerbatim}[commandchars=\\\{\}]
\PYG{c+cp}{\PYGZsh{}}\PYG{c+cp}{include} \PYG{c+cpf}{\PYGZlt{}stdio.h\PYGZgt{}}
\end{sphinxVerbatim}

and I would like to redeclare this environment for this sphinxVerbatim to be wrapped inside a \begin{code}...\end{code}.

The main issue I have with sphinxVerbatim is that the frame goes outside from the page area, I want it to be inside with some margin as shown below:

enter image description here

enter image description here I thought I could simply redeclare sphinxVerbatim...

4
  • The etoolbox package defines \BeforeBeginEnvironment and \AfterEndEnvironment commands.
    – Bernard
    Commented Aug 2, 2020 at 14:41
  • @Bernard I don't think I can do \begin{something} inside a \BeforeBeginEnvironment :(
    – nowox
    Commented Aug 2, 2020 at 14:43
  • 1
    You didn't give many details. Could you show what you're trying to obtain and what you tried?
    – Bernard
    Commented Aug 2, 2020 at 15:06
  • @Bernard I've added some information to my question
    – nowox
    Commented Aug 2, 2020 at 15:10

1 Answer 1

1

You may benefit from looking at the documentation for Sphinx: https://www.sphinx-doc.org/en/master/latex.html

The section on sphinxsetup mentions the ability to do things like adding a frame, coloring, etc. which should allow you to do the customizations that you like.

1
  • No unfortunately it doesn't work. The standard Sphinx options are very ugly. I would like to declare a code-block inside a tcolorbox environment.
    – nowox
    Commented Aug 2, 2020 at 15:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .