代码
\documentclass[parskip=half]{scrbook}
\usepackage{mdframed}
\usepackage{lipsum}
\usepackage{xcolor}
\newmdenv[
usetwoside=false,
leftmargin = \dimexpr-1em-3pt,
innerleftmargin = 1em,
innertopmargin = 0pt,
innerbottommargin = 0pt,
innerrightmargin = 0pt,
rightmargin = 0pt,
linewidth = 3pt,
linecolor = orange,
skipbelow = 0pt,
backgroundcolor = yellow!20,
topline = true,
rightline = false,
bottomline = false
]{highlighted}
\newmdenv[
usetwoside=false,
leftmargin = \dimexpr-1em-3pt,
innerleftmargin = 1em,
innertopmargin = 0pt,
innerbottommargin = 0pt,
innerrightmargin = 0pt,
rightmargin = 0pt,
linewidth = 3pt,
linecolor = orange,
skipabove= 0pt,
skipbelow = \parskip,
topline = false,
rightline = false,
bottomline = false,
footnoteinside = false,
nobreak = false
]{sidebaronly}
\DeclareNewTOC[
category=float,
float,% declares floating environment eq
floatpos=ht,
nonfloat,% declares non-floating environment eq-
listname={Some Special Stuff},
name=TM,
tocentrystyle=tocline,
tocentrylevel:=table,
tocentryindent:=table,
tocentrynumwidth:=table,
type=MySpecialEnvFloat,
]{ltm}
\newcounter{MySpecialEnvCounter}
\makeatletter
\newcommand{\MySpecialEnv}[4]{%
\refstepcounter{MySpecialEnvCounter}%
\begin{samepage}
\begin{MySpecialEnvFloat-}
\begin{highlighted}
\textbf{TM\,\theMySpecialEnvCounter}: #2
\end{highlighted}
\addcontentsline{ltm}{section}{TM\,\theMySpecialEnvCounter: #2}
\label{#1}%
\end{MySpecialEnvFloat-}
\zref@labelbyprops{#1}{MySpecialEnvId,MySpecialEnvDefinition,MySpecialEnvPL}%
\begin{sidebaronly}
\setlength{\parskip}{1ex}
\protect{#4}
\end{sidebaronly}
\end{samepage}
}%
\makeatother
\begin{document}
\sffamily
\listofMySpecialEnvFloats
\MySpecialEnv{test-id}{Something that looks like a summary}{-}{
\lipsum[1]
% There could be a page break here
\lipsum[1]
% There could be a page break here
\lipsum[1]
% There could be a page break here
}
\MySpecialEnv{test-id-2}{Yet another summary}{-}{
\lipsum[1]
% There could be a page break here
\lipsum[1]
% There could be a page break here
\lipsum[1]
% There could be a page break here
}
\end{document}
产生一个在突出显示区域后很容易跨页中断的环境。我希望这能打破其他地方,但如何做呢?
另外,有什么想法可以使橙色边线不被打断吗?
更新 2022-02-11
根据 Ulrike 的提议,并且经过一整晚阅读文档后,我在这里几乎达到了我的目标,如果有人能向我解释如何像在常规文本中一样恢复 parskip。
\documentclass[parskip=half]{scrbook}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage[nospace]{varioref}
\usepackage[pdfencoding=unicode, psdextra]{hyperref}
\usepackage{cleveref}
\usepackage[pdfencoding=unicode, psdextra]{hyperref}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\DeclareNewTOC[
category=float,
float,% declares floating environment eq
floatpos=ht,
nonfloat,% declares non-floating environment eq-
listname={Some Special Stuff},
name=TM,
tocentrystyle=tocline,
tocentrylevel:=table,
tocentryindent:=table,
tocentrynumwidth:=table,
type=MySpecialEnvFloat,
]{ltm}
\newtcolorbox[
auto counter,
crefname={TM}{TMs}]{MyBox}[2][]{
breakable,
sharp corners=all,
left skip=\dimexpr-1em-3pt,
leftrule=3pt,
rightrule=-1pt,
toprule=3pt,
toprule at break=-1pt,
bottomrule=-1pt,
bottomrule at break=-1pt,
colback=white,
colframe=orange,
colbacktitle=yellow!20,
coltitle=black,
fonttitle=\sffamily,
titlerule=0pt,
colupper=blue,
subtitle style={boxrule=0.4pt, rightrule=-1pt,
colback=yellow!20},
title={TM\,\thetcbcounter: #2},
#1}
\newcounter{MySpecialEnvCounter}
\makeatletter
\newcommand{\MySpecialEnv}[4]{%
\refstepcounter{MySpecialEnvCounter}%
\begin{MyBox}[label={#1}]{#2}
\addcontentsline{ltm}{section}{TM\,\theMySpecialEnvCounter: #2}
Some text
\tcblower
#4
\end{MyBox}
}%
\makeatother
\begin{document}
\sffamily
\listofMySpecialEnvFloats
Varioref test: Reference to \vref{test-id} and \vref{test-id-2}
\MySpecialEnv{test-id}{Something that looks like a summary}{-}{
\lipsum[1]
% There could be a page break here
\lipsum[1]
% There could be a page break here
\lipsum[1]
% There could be a page break here
}
\MySpecialEnv{test-id-2}{Yet another summary}{-}{
\lipsum[1]
% There could be a page break here
\lipsum[1]
% There could be a page break here
\lipsum[1]
% There could be a page break here
}
\end{document}