I would like to remove the frames and set a light grey shade background to my code blocks.

I know I could use colorbox such as \begin{tcolorbox}, but I have no idea where to place it.

Sphinx uses this environment:

  % first, let's check if there is a caption
      % there was no caption. Check if nevertheless a label was set.
      % we require some space to be sure hyperlink target from \phantomsection
      % will not be separated from upcoming verbatim by a page break
     \if t\spx@opt@literalblockcappos
                 % if no frame (code-blocks inside table cells), remove
                 % the "verbatimsep" whitespace from the top (better visually)
                 % caption package adds \abovecaptionskip vspace, remove it
     % \sphinxVerbatimTitle must reset color
     % caption package may detect wrongly if top or bottom, so we help it
  \fboxsep\sphinxverbatimsep \fboxrule\sphinxverbatimborder
  \let\FrameCommand     \sphinxVerbatim@FrameCommand
  \let\MidFrameCommand  \sphinxVerbatim@MidFrameCommand
  \let\LastFrameCommand \sphinxVerbatim@LastFrameCommand
  % fancyvrb's Verbatim puts each input line in (unbreakable) horizontal boxes.
  % This customization wraps each line from the input in a \vtop, thus
  % allowing it to wrap and display on two or more lines in the latex output.
  %     - The codeline counter will be increased only once.
  %     - The wrapped material will not break across pages, it is impossible
  %       to achieve this without extensive rewrite of fancyvrb.
  %     - The (not used in sphinx) obeytabs option to Verbatim is
  %       broken by this change (showtabs and tabspace work).
  % Allow breaks at special characters using \PYG... macros.
  % Breaks at punctuation characters . , ; ? ! and / (needs catcode activation)
  \else % end of conditional code for wrapping long code lines
  % workaround to fancyvrb's check of current list depth
  \def\@toodeep {\advance\@listdepth\@ne}%
  % The list environment is needed to control perfectly the vertical space.
  % Note: \OuterFrameSep used by framed.sty is later set to \topsep hence 0pt.
  % - if caption: distance from last text baseline to caption baseline is
  %   A+(B-F)+\ht\strutbox, A = \abovecaptionskip (default 10pt), B =
  %   \baselineskip, F is the framed.sty \FrameHeightAdjust macro, default 6pt.
  %   Formula valid for F < 10pt.
  % - distance of baseline of caption to top of frame is like for tables:
  %   \sphinxbelowcaptionspace (=0.5\baselineskip)
  % - if no caption: distance of last text baseline to code frame is S+(B-F),
  %   with S = \sphinxverbatimtopskip (=\smallskip)
  % - and distance from bottom of frame to next text baseline is
  %   \baselineskip+\parskip.
  % The \trivlist is used to avoid possible "too deeply nested" error.
  \itemsep   \z@skip
  \topsep    \z@skip
  \partopsep \z@skip
  % trivlist will set \parsep to \parskip = zero
  % \leftmargin will be set to zero by trivlist
  \parindent  \z@% becomes \itemindent. Default zero, but perhaps overwritten.
     % use a minipage if we are already inside a framed environment
     \MakeFramed {% adapted over from framed.sty's snugshade environment
     % For grid placement from \strut's in \FancyVerbFormatLine
     % active comma should not be overwritten by \@noligs
       \let\verbatim@nolig@list \sphinx@verbatim@nolig@list
     % will fetch its optional arguments if any

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.