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