当在 mdframed 环境中使用代码块时,我的代码块不会在新页面上中断:
\begin{mdframed}
\begin{sphinxVerbatim}[commandchars=\\\{\}]
Tablespaces:
PRIMARY (1)
Full path: /home/test/employee.fdb
Tables:
COUNTRY
JOB
Indices:
RDB\PYGZdl{}PRIMARY1 (COUNTRY)
RDB\PYGZdl{}FOREIGN23 (CUSTOMER)
RDB\PYGZdl{}PRIMARY22 (CUSTOMER)
TS1 (2)
Full path: /home/test/ts.ts
Tables:
EMPLOYEE
PROJECT
SALES
Indices:
CUSTNAMEX (CUSTOMER)
MAXSALX (JOB)
NEEDX (SALES)
QTYX (SALES)
TS2 (3)
Full path: /home/test/ts2.ts
Tables:
CUSTOMER
Indices:
CUSTREGION (CUSTOMER)
TS3 (4)
Full path: /home/test/ts3.ts
Tablespace is empty
\end{sphinxVerbatim}
\end{mdframed}
设置:
\mdfsetup{%
middlelinewidth=0.5pt,
backgroundcolor=white!98!black,
roundcorner=5pt,
innerleftmargin = 10pt,
innertopmargin=2pt,
innerbottommargin=2pt,
skipabove = 10pt,
skipbelow = 5pt,
shadow=true,
shadowsize=4pt,
nobreak=false,
rightmargin=0pt,
}
如果我只执行 \begin{sphinxVerbatim}[commandchars=\{}] ... \end{sphinxVerbatim} (没有 mdframed)分页符即可起作用。
环境sphinxVerbatim是:
\newenvironment{sphinxVerbatim}{%
% first, let's check if there is a caption
\ifx\sphinxVerbatimTitle\empty
\sphinxvspacefixafterfrenchlists
\parskip\z@skip
\vskip\sphinxverbatimsmallskipamount
% there was no caption. Check if nevertheless a label was set.
\ifx\sphinxLiteralBlockLabel\empty\else
% we require some space to be sure hyperlink target from \phantomsection
% will not be separated from upcoming verbatim by a page break
\needspace{\sphinxliteralblockwithoutcaptionneedspace}%
\phantomsection\sphinxLiteralBlockLabel
\fi
\else
\parskip\z@skip
\if t\spx@opt@literalblockcappos
\vskip\spx@abovecaptionskip
\def\sphinxVerbatim@Before
{\sphinxVerbatim@Title\nointerlineskip
\kern\dimexpr-\dp\strutbox+\sphinxbelowcaptionspace
% if no frame (code-blocks inside table cells), remove
% the top padding (better visually)
\ifspx@opt@verbatimwithframe\else
% but we must now check if there is a background color
% MEMO: "fcolorbox@setup" will have been done by time of use
\ifspx@boxes@withbackgroundcolor\else-\spx@boxes@padding@top\fi
\fi
% caption package adds \abovecaptionskip vspace, remove it
\spx@ifcaptionpackage{-\abovecaptionskip}{}\relax}%
\else
\vskip\sphinxverbatimsmallskipamount
\def\sphinxVerbatim@After
{\nointerlineskip\kern\dimexpr\dp\strutbox
\ifspx@opt@verbatimwithframe\else
% but we must now check if there is a background color
% MEMO: "fcolorbox@setup" will have been done by time of use
\ifspx@boxes@withbackgroundcolor\else-\spx@boxes@padding@bottom\fi
\fi
\spx@ifcaptionpackage{-\abovecaptionskip}{}\relax
\sphinxVerbatim@Title}%
\fi
\def\@captype{literalblock}%
\capstart
% \sphinxVerbatimTitle must reset color
\setbox\sphinxVerbatim@TitleBox
\hbox{\begin{minipage}{\linewidth}%
% caption package may detect wrongly if top or bottom, so we help it
\spx@ifcaptionpackage
{\caption@setposition{\spx@opt@literalblockcappos}}{}%
\sphinxVerbatimTitle
\end{minipage}}%
\fi
\global\let\sphinxLiteralBlockLabel\empty
\global\let\sphinxVerbatimTitle\empty
% the "FrameCommand"'s are also responsible to attach the "Title".
\let\FrameCommand \sphinxVerbatim@FrameCommand
% those will also check status of the pre_box-decoration-break option
\let\FirstFrameCommand\sphinxVerbatim@FirstFrameCommand
\let\MidFrameCommand \sphinxVerbatim@MidFrameCommand
\let\LastFrameCommand \sphinxVerbatim@LastFrameCommand
%
\ifspx@opt@verbatimhintsturnover\else
\let\sphinxVerbatim@Continued\@empty
\let\sphinxVerbatim@Continues\@empty
\fi
% initialization for \spx@boxes@fcolorbox from sphinxpackageboxes.sty
% it will take into account status of verbatimwithframe Boolean
\spx@verb@boxes@fcolorbox@setup
\ifspx@opt@verbatimwrapslines
% deep hack into fancyvrb's internal processing of input lines
\let\FV@@PreProcessLine\spx@verb@@PreProcessLine
% space character will allow line breaks
\let\FV@Space\spx@verbatim@space
% allow breaks at special characters using \PYG... macros.
\sphinxbreaksatspecials
% breaks at punctuation characters . , ; ? ! and / (needs catcode activation)
\fvset{codes*=\sphinxbreaksviaactive}%
\fi
\let\FancyVerbFormatLine\sphinxFancyVerbFormatLine
\VerbatimEnvironment
% 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 (which itself is set to zero above)
% \leftmargin will be set to zero by trivlist
\rightmargin\z@
\parindent \z@% becomes \itemindent. Default zero, but perhaps overwritten.
\trivlist\item\relax
\ifspx@inframed\setbox\sphinxVerbatim@ContentsBox\vbox\bgroup
\@setminipage\hsize\linewidth
% use bulk of minipage paragraph shape restores (this is needed
% in indented contexts, at least for some)
\textwidth\hsize \columnwidth\hsize \@totalleftmargin\z@
\leftskip\z@skip \rightskip\z@skip \@rightskip\z@skip
\else
\ifsphinxverbatimwithminipage\noindent\begin{minipage}{\linewidth}\fi
\MakeFramed {% adapted over from framed.sty's snugshade environment
\advance\hsize-\width\@totalleftmargin\z@\linewidth\hsize\@setminipage
}%
\fi
% For grid placement from \strut's in \FancyVerbFormatLine
\lineskip\z@skip
% active comma should not be overwritten by \@noligs
\ifspx@opt@verbatimwrapslines
\let\verbatim@nolig@list \sphinx@verbatim@nolig@list
\fi
% optimization: as codelines will be handled inside boxes, \everypar is
% never reset, and it issues \@minipagefalse repeatedly (from \@setminipage).
% As fancyvrb Verbatim will do \@minipagefalse itself, let's simplify things.
\everypar{}%
\color@begingroup % protect against color leaks (upstream framed.sty bug)
\ifspx@pre@withtextcolor\color{VerbatimTextColor}\fi % mostly shadowed by
% Pygments highlighting anyhow
\spx@pre@TeXextras
% will fetch its optional arguments if any
\OriginalVerbatim
}%
{%
\endOriginalVerbatim
\color@endgroup % matches the \color@begingroup
\ifspx@inframed
\egroup % finish \sphinxVerbatim@ContentsBox vbox
\nobreak % update page totals
%%%%
% MEMO (2022/07/09, while preparing 5.1.0 LaTeX CSS-style sphinxsetup options)
% This test will systematically cause to abandon framing if the code-block
% is near bottom of a warning-type notice which TeX has not yet decided whether
% it fits on current page and which is near bottom of page. Indeed the
% \pagetotal will already be very near \pagegoal. This is probably a not
% intended behaviour, and perhaps the whole thing should be removed? Indeed
% the result is surprising then because the notice will be split, code-block
% will be on page 2 and will have no background-color, no border.
\ifdim\dimexpr
\ht\sphinxVerbatim@ContentsBox+
\dp\sphinxVerbatim@ContentsBox+
\ht\sphinxVerbatim@TitleBox+
\dp\sphinxVerbatim@TitleBox+
% 6.2.0 uses here the dimen registers from sphinxpackageboxes.sty,
% they got setup by \spx@verb@boxes@fcolorbox@setup
\spx@boxes@padding@top+
\spx@boxes@padding@bottom+
\ifspx@opt@verbatimwithframe \spx@boxes@border@top+
\spx@boxes@border@bottom+\fi
% try to account for external frame parameters
% MEMO: this is because the sphinxheavybox (for warning admonitions)
% environment sets \FrameSep and \FrameRule
% TODO: fix this bad implicit dependency
\FrameSep+\FrameRule+
% Usage here of 2 baseline distances is empirical.
% In border case where code-block fits barely in remaining space,
% it gets framed and looks good but the outer frame may continue
% on top of next page and give (if no contents after code-block)
% an empty framed line, as testing showed.
2\baselineskip+
% now add all to accumulated page totals and compare to \pagegoal
\pagetotal+\pagedepth>\pagegoal
% long contents: do not \MakeFramed. Do make a caption (either before or
% after) if title exists. Continuation hints across pagebreaks dropped.
% FIXME? a bottom caption may end up isolated at top of next page
% (no problem with a top caption, which is default)
\spx@opt@verbatimwithframefalse
\def\sphinxVerbatim@Title{\noindent\box\sphinxVerbatim@TitleBox\par}%
\sphinxVerbatim@Before
\noindent\unvbox\sphinxVerbatim@ContentsBox\par
\sphinxVerbatim@After
\else
% short enough contents: use \MakeFramed. As it is nested, this requires
% minipage encapsulation.
\noindent\begin{minipage}{\linewidth}%
\MakeFramed {% Use it now with the fetched contents
\advance\hsize-\width\@totalleftmargin\z@\linewidth\hsize\@setminipage
}%
\unvbox\sphinxVerbatim@ContentsBox
% the \@minipagefalse is superfluous, actually.
\par\unskip\@minipagefalse\endMakeFramed
\end{minipage}%
\fi
\else % non-nested \MakeFramed
\par\unskip\@minipagefalse\endMakeFramed % from framed.sty snugshade
\ifsphinxverbatimwithminipage\end{minipage}\fi
\fi
\endtrivlist
}
代码损坏了我能做什么?