mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add the possibility to have colored verbatim border and background.
This commit is contained in:
parent
1ba3902225
commit
1130b8ed9c
@ -15,16 +15,20 @@
|
|||||||
\RequirePackage{titlesec}
|
\RequirePackage{titlesec}
|
||||||
|
|
||||||
\RequirePackage{color}
|
\RequirePackage{color}
|
||||||
\definecolor{py@InnerLinkColor}{rgb}{0.208,0.374,0.486}
|
\definecolor{InnerLinkColor}{rgb}{0.208,0.374,0.486}
|
||||||
\definecolor{py@OuterLinkColor}{rgb}{0.216,0.439,0.388}
|
\definecolor{OuterLinkColor}{rgb}{0.216,0.439,0.388}
|
||||||
|
% Define these colors to something not white if you want to have colored
|
||||||
|
% background and border for code examples.
|
||||||
|
\definecolor{VerbatimColor}{rgb}{1,1,1}
|
||||||
|
\definecolor{VerbatimBorderColor}{rgb}{1,1,1}
|
||||||
|
|
||||||
\RequirePackage[colorlinks,
|
\RequirePackage[colorlinks,
|
||||||
breaklinks,
|
breaklinks,
|
||||||
linkcolor=py@InnerLinkColor,
|
linkcolor=InnerLinkColor,
|
||||||
filecolor=py@OuterLinkColor,
|
filecolor=OuterLinkColor,
|
||||||
menucolor=py@OuterLinkColor,
|
menucolor=OuterLinkColor,
|
||||||
pagecolor=py@OuterLinkColor,
|
pagecolor=OuterLinkColor,
|
||||||
urlcolor=py@OuterLinkColor,
|
urlcolor=OuterLinkColor,
|
||||||
]{hyperref}
|
]{hyperref}
|
||||||
|
|
||||||
\RequirePackage{framed}
|
\RequirePackage{framed}
|
||||||
@ -234,8 +238,52 @@
|
|||||||
|
|
||||||
\newcommand{\py@modulebadkey}{{--just-some-junk--}}
|
\newcommand{\py@modulebadkey}{{--just-some-junk--}}
|
||||||
|
|
||||||
%% Lots of index-entry generation support.
|
% Redefine the Verbatim environment to allow border and background colors.
|
||||||
|
%
|
||||||
|
\let\py@OldVerbatim=\Verbatim
|
||||||
|
\let\py@OldEndVerbatim=\endVerbatim
|
||||||
|
|
||||||
|
% Play with vpsace to be able to keep the indentation.
|
||||||
|
\newlength\distancetoright
|
||||||
|
\newlength\leftsidespace
|
||||||
|
\def\mycolorbox#1{%
|
||||||
|
\setlength\leftsidespace{\@totalleftmargin}%
|
||||||
|
\setlength\distancetoright{\textwidth}%
|
||||||
|
\advance\distancetoright -\@totalleftmargin %
|
||||||
|
\noindent\hspace*{\@totalleftmargin}%
|
||||||
|
\fcolorbox{VerbatimBorderColor}{VerbatimColor}{%
|
||||||
|
\begin{minipage}{\distancetoright}%
|
||||||
|
\smallskip%
|
||||||
|
\noindent\hspace*{-\leftsidespace}%
|
||||||
|
#1
|
||||||
|
\end{minipage}%
|
||||||
|
}%
|
||||||
|
}
|
||||||
|
\def\FrameCommand{\mycolorbox}
|
||||||
|
|
||||||
|
\renewcommand{\Verbatim}[1][1]{%
|
||||||
|
% The list environement is needed to control perfectly the vertical
|
||||||
|
% space.
|
||||||
|
\list{}{%
|
||||||
|
\setlength\parskip{0pt}%
|
||||||
|
\setlength\itemsep{0ex}%
|
||||||
|
\setlength\topsep{0ex}%
|
||||||
|
\setlength\partopsep{0pt}%
|
||||||
|
\setlength\leftmargin{0pt}%
|
||||||
|
}%
|
||||||
|
\item\MakeFramed {\FrameRestore}%
|
||||||
|
\small%
|
||||||
|
\py@OldVerbatim[#1]%
|
||||||
|
}
|
||||||
|
\renewcommand{\endVerbatim}{%
|
||||||
|
\py@OldEndVerbatim%
|
||||||
|
\endMakeFramed%
|
||||||
|
\endlist%
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
% Lots of index-entry generation support.
|
||||||
|
%
|
||||||
% Command to wrap around stuff that refers to function / module /
|
% Command to wrap around stuff that refers to function / module /
|
||||||
% attribute names in the index. Default behavior: like \code{}. To
|
% attribute names in the index. Default behavior: like \code{}. To
|
||||||
% just keep the index entries in the roman font, uncomment the second
|
% just keep the index entries in the roman font, uncomment the second
|
||||||
|
Loading…
Reference in New Issue
Block a user