在以下 MWE 中(构建自https://tex.stackexchange.com/a/170767/69378)我已经证明,覆盖tcolorbox
节点中的标题文本会在分页符之间重复。
我对照每个配置的参数检查了手册,并尝试注释掉那些我认为可能是罪魁祸首的参数,但总是留下这个重复的标题。通常这是一个很好的功能,但我希望能够有选择地关闭它,当它tcolorbox
很小并且重复这个标题只会增加混乱时。
是什么导致这种重复?
\documentclass{article}
\usepackage[left=60pt,top=60pt,right=60pt,bottom=60pt]{geometry}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{kantlipsum}
\usepackage{enumitem}
\usepackage[many]{tcolorbox}
\setitemize{nolistsep,labelsep=1ex,leftmargin=*}
%% colors---
\definecolor{lightgray}{gray}{0.8}
%%items--
\newlist{items}{description}{1}
\setlist[items]{align=right,font=\normalfont, leftmargin=1.8in,style=nextline,labelsep=1em,}
%% leftrulebox---
\tcbuselibrary{skins,breakable}
\newtcolorbox{leftrulebox}[1][]{
colback=white,
boxrule=10pt
left=0.5ex,
top=0pt,
arc=0pt,
outer arc=0pt,
enlarge left by=1.8cm,
enlarge right by=-\dimexpr1.8cm+\parindent\relax,
right=\dimexpr1.8cm+\parindent\relax,
leftrule=1pt,
rightrule=0pt,
toprule=0pt,
bottomrule=0pt,
breakable,
nobeforeafter,
enhanced jigsaw,
overlay={
\node[anchor=north east,inner ysep=0pt,align=right,text width=1.8cm]
at ([yshift=-0.55ex]frame.north west) {\hfill#1};
},
before=\vskip2\itemsep\noindent
}
\begin{document}
\section*{Sample}
\begin{leftrulebox}[Text Title]
\kant[1]
\kant[2]
\kant[3]
\kant[4]
\kant[5]
\end{leftrulebox}
\end{document}
**更新:MWE 2 用于间歇性解决方案**
\documentclass{article}
\usepackage[left=60pt,top=60pt,right=60pt,bottom=60pt]{geometry}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{kantlipsum}
\usepackage{enumitem}
\usepackage[many]{tcolorbox}
\setitemize{nolistsep,labelsep=1ex,leftmargin=*}
%% colors---
\definecolor{lightgray}{gray}{0.8}
%%items--
\newlist{items}{description}{1}
\setlist[items]{align=right,font=\normalfont, leftmargin=1.8in,style=nextline,labelsep=1em,}
%% leftrulebox---
\tcbuselibrary{skins,breakable}
\newtcolorbox{leftrulebox}[1][]{
colback=white,
boxrule=10pt
left=0.5ex,
top=0pt,
arc=0pt,
outer arc=0pt,
enlarge left by=1.8cm,
enlarge right by=-\dimexpr1.8cm+\parindent\relax,
right=\dimexpr1.8cm+\parindent\relax,
leftrule=1pt,
rightrule=0pt,
toprule=0pt,
bottomrule=0pt,
breakable,
nobeforeafter,
enhanced jigsaw,
%overlay={
% \node[anchor=north east,inner ysep=0pt,align=right,text width=2.6cm]
% at ([yshift=0.5ex]frame.north west) {\hfill#1};%-0.55 hold yshift
%},
extras first={
overlay={%
\node[anchor=north east,inner ysep=0pt,align=right,text width=2.6cm]
at ([yshift=-0.5ex]frame.north west) {\hfill#1};
},
},
extras middle and last={%
overlay={%
\node[anchor=north east,inner ysep=0pt,align=right,text width=2.6cm]
at ([yshift=-0.5ex]frame.north west) {\hfill};
},
},
%before=\vskip2\itemsep\noindent
before=\vskip\itemsep\noindent
}
\begin{document}
\section*{Sample}
\begin{leftrulebox}[Text Title 1]
\kant[1]
\end{leftrulebox}
\begin{leftrulebox}[Text Title 2]
\kant[2]
\kant[3]
\kant[4]
\kant[5]
\end{leftrulebox}
\begin{leftrulebox}[Text Title 3]
\kant[3]
\kant[4]
\kant[5]
\end{leftrulebox}
\end{document}
答案1
恕我直言,您正在寻找overlay unbroken and first
钥匙:
\documentclass{article}
\usepackage[left=60pt,top=60pt,right=60pt,bottom=60pt]{geometry}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{kantlipsum}
\usepackage{enumitem}
\usepackage[many]{tcolorbox}
\setitemize{nolistsep,labelsep=1ex,leftmargin=*}
%% colors---
\definecolor{lightgray}{gray}{0.8}
%%items--
\newlist{items}{description}{1}
\setlist[items]{align=right,font=\normalfont, leftmargin=1.8in,style=nextline,labelsep=1em,}
%% leftrulebox---
\tcbuselibrary{skins,breakable}
\newtcolorbox{leftrulebox}[1][]{
colback=white,
boxrule=10pt
left=0.5ex,
top=0pt,
arc=0pt,
outer arc=0pt,
enlarge left by=1.8cm,
enlarge right by=-\dimexpr1.8cm+\parindent\relax,
right=\dimexpr1.8cm+\parindent\relax,
leftrule=1pt,
rightrule=0pt,
toprule=0pt,
bottomrule=0pt,
breakable,
nobeforeafter,
enhanced jigsaw,
overlay unbroken and first={
\node[anchor=north east,inner ysep=0pt,align=right,text width=2.6cm]
at ([yshift=0.5ex]frame.north west) {\hfill#1};%-0.55 hold yshift
},
%before=\vskip2\itemsep\noindent
before=\vskip\itemsep\noindent
}
\begin{document}
\section*{Sample}
\begin{leftrulebox}[Text Title 1]
\kant[1]
\end{leftrulebox}
\begin{leftrulebox}[Text Title 2]
\kant[2]
\kant[3]
\kant[4]
\kant[5]
\end{leftrulebox}
\begin{leftrulebox}[Text Title 3]
\kant[3]
\kant[4]
\kant[5]
\end{leftrulebox}
\end{document}
答案2
可以尝试使用extras first
和extras middle and last
选项为第一个框(第一个断开的框)提供特定的覆盖(带有文本),而#1
对于断开序列中的中间和最后一个框则保留不带覆盖。
\documentclass{article}
\usepackage[left=60pt,top=60pt,right=60pt,bottom=60pt]{geometry}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{kantlipsum}
\usepackage{enumitem}
\usepackage[many]{tcolorbox}
\setitemize{nolistsep,labelsep=1ex,leftmargin=*}
%% colors---
\definecolor{lightgray}{gray}{0.8}
%%items--
\newlist{items}{description}{1}
\setlist[items]{align=right,font=\normalfont, leftmargin=1.8in,style=nextline,labelsep=1em,}
%% leftrulebox---
\tcbuselibrary{skins,breakable}
\newtcolorbox{leftrulebox}[1][]{
colback=white,
boxrule=10pt
left=0.5ex,
top=0pt,
arc=0pt,
outer arc=0pt,
enlarge left by=1.8cm,
enlarge right by=-\dimexpr1.8cm+\parindent\relax,
right=\dimexpr1.8cm+\parindent\relax,
leftrule=1pt,
rightrule=0pt,
toprule=0pt,
bottomrule=0pt,
breakable,
nobeforeafter,
enhanced jigsaw,
extras first={
overlay={%
\node[anchor=north east,inner ysep=0pt,align=right,text width=1.8cm]
at ([yshift=-0.55ex]frame.north west) {\hfill#1};
},
},
extras middle and last={%
overlay={%
\node[anchor=north east,inner ysep=0pt,align=right,text width=1.8cm]
at ([yshift=-0.55ex]frame.north west) {\hfill};
},
},
before=\vskip2\itemsep\noindent
}
\begin{document}
\section*{Sample}
\begin{leftrulebox}[Text Title]
\kant[1]
\kant[2]
\kant[3]
\kant[4]
\kant[5]
\end{leftrulebox}
\end{document}