Make more robust Verbatim code for PDF. No more redefines \fbox.

Although the definition was made locally, it meant that for example
macros of type \PYG... could not use internally \fbox whose meaning
had been modified. New code never modifies \fbox or \XC@fbox.

	modified:   sphinx/texinputs/sphinx.sty
This commit is contained in:
jfbu 2016-04-14 18:14:44 +02:00
parent 53cc2aa8a8
commit 4e69311599

View File

@ -158,14 +158,19 @@
\let\OriginalVerbatim=\Verbatim
\let\endOriginalVerbatim=\endVerbatim
\newcommand\Sphinxcolorbox [1]{%
\fcolorbox{VerbatimBorderColor}{VerbatimColor}{%
% Adjust width to be able to handle indentation.
\newcommand\Sphinx@colorbox [2]{%
% #1 will be \fcolorbox or, for first part of frame: \Sphinx@fcolorbox
#1{VerbatimBorderColor}{VerbatimColor}{%
% adjust width to be able to handle indentation.
\begin{minipage}{\dimexpr\linewidth-\@totalleftmargin\relax}%
#1%
#2%
\end{minipage}%
}%
}
% use of \color@b@x here is compatible with both xcolor.sty and color.sty
\def\Sphinx@fcolorbox #1#2%
{\color@b@x {\fboxsep\z@\color{#1}\Sphinx@VerbatimFBox}{\color{#2}}}%
% The title is specified from outside as macro \SphinxVerbatimTitle.
% \SphinxVerbatimTitle is reset to empty after each use of Verbatim.
\newcommand*\SphinxVerbatimTitle {}
@ -184,7 +189,7 @@
% of a non separable by pagebreak caption, and controlled counter stepping.
\newif\ifSphinx@myfirstframedpass
\long\def\SphinxVerbatimFBox#1{%
\long\def\Sphinx@VerbatimFBox#1{%
\leavevmode
\begingroup
\ifSphinx@myfirstframedpass\else\firstchoice@false\fi
@ -221,15 +226,11 @@
% non-empty \SphinxVerbatimTitle has label inside it (in case there is one)
% Customize framed.sty \MakeFramed to glue caption to literal block
\global\Sphinx@myfirstframedpasstrue
\def\FrameCommand {%
% will insert the caption (if there is one) preventing pagebreaks
\def\fbox{\SphinxVerbatimFBox}%
% \fcolorbox from xcolor.sty may use rather \XC@fbox
\let\XC@fbox\fbox
\Sphinxcolorbox }%
% via \Sphinx@fcolorbox, will use \SphinxVerbatimFBox which inserts title
\def\FrameCommand {\Sphinx@colorbox\Sphinx@fcolorbox }%
\let\FirstFrameCommand\FrameCommand
% for mid pages and last page portion of (long) split frame:
\def\MidFrameCommand{\Sphinxcolorbox}%
\def\MidFrameCommand{\Sphinx@colorbox\fcolorbox }%
\let\LastFrameCommand\MidFrameCommand
% The list environement is needed to control perfectly the vertical
% space.