Merge pull request #2448 from jfbu/fixpdfcaptioncolor

Fix #2447: VerbatimBorderColor wrongly used also for captions of PDF
This commit is contained in:
Takeshi KOMIYA 2016-04-16 23:27:21 +09:00
commit e62994b6e3

View File

@ -152,99 +152,63 @@
\newcommand*{\sphinxAtStartFootnote}{\mbox{ }} \newcommand*{\sphinxAtStartFootnote}{\mbox{ }}
% Redefine the Verbatim environment to allow border and background colors. % Redefine the Verbatim environment to allow border and background colors
% and to handle the top caption in a non separable by pagebreak way.
% The original environment is still used for verbatims within tables. % The original environment is still used for verbatims within tables.
\let\OriginalVerbatim=\Verbatim \let\OriginalVerbatim=\Verbatim
\let\endOriginalVerbatim=\endVerbatim \let\endOriginalVerbatim=\endVerbatim
% Play with vspace to be able to keep the indentation. \newcommand\Sphinx@colorbox [2]{%
\newlength\Sphinx@scratchlength % #1 will be \fcolorbox or, for first part of frame: \Sphinx@fcolorbox
\newcommand\Sphinxcolorbox [1]{% #1{VerbatimBorderColor}{VerbatimColor}{%
\setlength\Sphinx@scratchlength{\linewidth}% % adjust width to be able to handle indentation.
\advance\Sphinx@scratchlength -\@totalleftmargin % \begin{minipage}{\dimexpr\linewidth-\@totalleftmargin\relax}%
\fcolorbox{VerbatimBorderColor}{VerbatimColor}{% #2%
\begin{minipage}{\Sphinx@scratchlength}%
#1
\end{minipage}% \end{minipage}%
}% }%
} }
% used for split frames for continuation on next and final page % use of \color@b@x here is compatible with both xcolor.sty and color.sty
\def\MidFrameCommand{\Sphinxcolorbox} \def\Sphinx@fcolorbox #1#2%
\let\LastFrameCommand\MidFrameCommand {\color@b@x {\fboxsep\z@\color{#1}\Sphinx@VerbatimFBox}{\color{#2}}}%
% We customize \FrameCommand (for non split frames) and \FirstFrameCommand
% (split frames), in order for the framed environment to insert a Title above
% the frame, which can not be separated by a pagebreak.
% 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 environment. % \SphinxVerbatimTitle is reset to empty after each use of Verbatim.
% It is also possible to use directly framed environment (i.e. not indirectly
% via the Verbatim environment next), then it is \SphinxFrameTitle which specifies
% the title.
\newcommand*\SphinxFrameTitle {}
\newcommand*\SphinxVerbatimTitle {} \newcommand*\SphinxVerbatimTitle {}
% Holder macro for labels of literal blocks. Set-up by LaTeX writer.
\newcommand*\SphinxLiteralBlockLabel {}
\newcommand*\SphinxSetupCaptionForVerbatim [2] \newcommand*\SphinxSetupCaptionForVerbatim [2]
{% {%
\needspace{\literalblockneedspace}\vspace{\literalblockcaptiontopvspace}% \needspace{\literalblockneedspace}\vspace{\literalblockcaptiontopvspace}%
% insert a \label via \SphinxLiteralBlockLabel
% reset to normal the color for the literal block caption
\def\SphinxVerbatimTitle \def\SphinxVerbatimTitle
{\captionof{#1}{\SphinxLiteralBlockLabel #2}\smallskip }% {\py@NormalColor\captionof{#1}{\SphinxLiteralBlockLabel #2}\smallskip }%
} }
% \SphinxLiteralBlockLabel will be set dynamically to hold the label for links
\newcommand*\SphinxLiteralBlockLabel {}
% \SphinxCustomFBox is copied from framed.sty's \CustomFBox, but % Inspired and adapted from framed.sty's \CustomFBox with extra handling
% #1=title/caption is to be set _above_ the top rule, not _below_ % of a non separable by pagebreak caption, and controlled counter stepping.
% #1 must be "vertical material", it may be left empty.
% The amsmath patches \stepcounter to inhibit stepping under
% \firstchoice@false. We use it because framed.sty typesets multiple
% times its contents.
\newif\ifSphinx@myfirstframedpass \newif\ifSphinx@myfirstframedpass
\long\def\SphinxCustomFBox#1#2#3#4#5#6#7{% \long\def\Sphinx@VerbatimFBox#1{%
% we set up amsmath (amstext.sty) conditional to inhibit counter stepping \leavevmode
% except in first pass \begingroup
\ifSphinx@myfirstframedpass\firstchoice@true \ifSphinx@myfirstframedpass\else\firstchoice@false\fi
\else\firstchoice@false\fi \setbox\@tempboxa\hbox{\kern\fboxsep{#1}\kern\fboxsep}%
\leavevmode\begingroup \hbox
\setbox\@tempboxa\hbox{% {\lower\dimexpr\fboxrule+\fboxsep+\dp\@tempboxa
\color@begingroup \hbox{%
\kern\fboxsep{#7}\kern\fboxsep \vbox{\ifx\SphinxVerbatimTitle\empty\else{\SphinxVerbatimTitle}\fi
\color@endgroup}% \hrule\@height\fboxrule\relax
\hbox{% \hbox{\vrule\@width\fboxrule\relax
\lower\dimexpr#4+\fboxsep+\dp\@tempboxa\hbox{% \vbox{\vskip\fboxsep\copy\@tempboxa\vskip\fboxsep}%
\vbox{% \vrule\@width\fboxrule\relax}%
#1% TITLE \hrule\@height\fboxrule\relax}%
\hrule\@height#3\relax }}%
\hbox{%
\vrule\@width#5\relax
\vbox{%
\vskip\fboxsep
\copy\@tempboxa
\vskip\fboxsep}%
\vrule\@width#6\relax}%
#2%
\hrule\@height#4\relax}%
}%
}%
\endgroup \endgroup
% amsmath conditional inhibits counter stepping after first pass.
\global\Sphinx@myfirstframedpassfalse \global\Sphinx@myfirstframedpassfalse
} }
% for non split frames:
\def\FrameCommand{%
% this is inspired from framed.sty v 0.96 2011/10/22 lines 185--190
% \fcolorbox (see \Sphinxcolorbox above) from color.sty uses \fbox.
\def\fbox{\SphinxCustomFBox{\SphinxFrameTitle}{}%
\fboxrule\fboxrule\fboxrule\fboxrule}%
% \fcolorbox from xcolor.sty may use rather \XC@fbox.
\let\XC@fbox\fbox
\Sphinxcolorbox
}
% for first portion of split frames:
\let\FirstFrameCommand\FrameCommand
\renewcommand{\Verbatim}[1][1]{% \renewcommand{\Verbatim}[1][1]{%
% list starts new par, but we don't want it to be set apart vertically % list starts new par, but we don't want it to be set apart vertically
\parskip\z@skip \parskip\z@skip
@ -260,8 +224,14 @@
\fi \fi
\fi \fi
% non-empty \SphinxVerbatimTitle has label inside it (in case there is one) % non-empty \SphinxVerbatimTitle has label inside it (in case there is one)
\let\SphinxFrameTitle\SphinxVerbatimTitle % Customize framed.sty \MakeFramed to glue caption to literal block
\global\Sphinx@myfirstframedpasstrue \global\Sphinx@myfirstframedpasstrue
% via \Sphinx@fcolorbox, will use \Sphinx@VerbatimFBox 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{\Sphinx@colorbox\fcolorbox }%
\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.
\list{}{% \list{}{%