tcolorbox 中的 longtable 使分项列表牢不可破

tcolorbox 中的 longtable 使分项列表牢不可破

结构:利用tcolorbox可分页的段落或列表内容,我尝试使用上方的长表格来对齐一些摘要信息。

但我观察到,如果我将一个长表放在环境创建的列表上方,曾经可中断的tcolorbox决定它只能在不同的对象之间中断(即在longtable和 列表之间的接缝处)。删除下面 MWE 中注释掉的longtable环境将说明我的意思。

是否存在错误tcolorbox,或者某些longtable诱导 par 或包装插入会诱使tcolorbox将列表放置在它自己的 vbox 或类似的东西中?

\documentclass{article}
\usepackage[left=60pt,top=60pt,right=60pt,bottom=60pt]{geometry}
\usepackage{xcolor}
\usepackage{kantlipsum}
\usepackage{enumitem}
\usepackage[many]{tcolorbox}
\usepackage{environ,longtable,threeparttablex,booktabs,multirow,array,adjustbox,supertabular}% table
\setitemize{nolistsep,labelsep=1ex,leftmargin=*}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
%% colors---
\definecolor{lightgray}{gray}{0.8}

%%items--
\newlist{items}{description}{1}
\setlist[items]{align=right,font=\normalfont, leftmargin=1.8in,style=nextline,labelsep=1em,}

\setlength{\tabcolsep}{0em}%https://tex.stackexchange.com/questions/29259/how-to-globally-adjust-horizontal-spacing-in-table-length


%% leftrulebox---
\tcbuselibrary{skins,breakable}
\newtcolorbox{leftrulebox}[1][]{
    colback=white,
    left=0.5ex,
    top=0pt,
    arc=0pt,
    outer arc=0pt,
    enlarge left by=2.5cm,
    enlarge right by=-\dimexpr2.5cm+\parindent\relax,
    right=\dimexpr2.5cm+\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.5in] 
        at ([yshift=-0.55ex]frame.north west) {\hfill#1};
    },
    before=\vskip\itemsep\noindent
}

\begin{document}

\section*{First Session}

\begin{leftrulebox}[Objective]
\kant[1]
\end{leftrulebox}

\section*{Second Session}

\begin{leftrulebox}[Past -- Future]
\textbf{Okay} \par
Some text \par some text
  \begin{itemize}
    \item \kant[1]
    \item \kant[2]
    \end{itemize}
\end{leftrulebox}

\begin{leftrulebox}[Today -- Tomorrow]
%\begin{longtable}[l]{L{13cm}}
        \textbf{Programmer I}, The Coolest Search Engine
%\end{longtable}
  \begin{itemize}
    \item \kant[4]
    \item The quick brown fox jumped over the lazy brown dog.
    \item The quick brown fox jumped over the lazy brown dog.
    \item The quick brown fox jumped over the lazy brown dog.
    \item The quick brown fox jumped over the lazy brown dog.
    \item The quick brown fox jumped over the lazy brown dog.
    \item The quick brown fox jumped over the lazy brown dog.
    \item The quick brown fox jumped over the lazy brown dog.
    \item The quick brown fox jumped over the lazy brown dog.
    \item The quick brown fox jumped over the lazy brown dog.
    \item The quick brown fox jumped over the lazy brown dog.
    \item The quick brown fox jumped over the lazy brown dog.
    \item The quick brown fox jumped over the lazy brown dog.
    \item The quick brown fox jumped over the lazy brown dog.
    \item The quick brown fox jumped over the lazy brown dog.
    \item The quick brown fox jumped over the lazy brown dog.
    \item \kant[5]
\end{itemize}
\end{leftrulebox}

\end{document}

信用: 如何将“tcolorbox”对齐到顶部?作为本 MWE 的基础

答案1

这个问题与列表无关,而且 longtable 不会使事物“牢不可破”。问题的根源是 longtable 插入的惩罚,它会强制分页。可以通过将此惩罚设置为较小的值来避免这种情况。但我不知道这是否会产生不良副作用,我认为 David Carlisle 和 Thomas Sturm 必须研究它。

\documentclass{article}
\usepackage{lipsum}
\usepackage[many]{tcolorbox}
\usepackage{longtable}% 
\begin{document}
\begin{tcolorbox}[breakable]
\makeatletter
%\mathchardef\LT@end@pen=9999 %avoids the page break.

\begin{longtable}{c}
        Title
\end{longtable}

\lipsum[4] \lipsum[4] \lipsum[4] \lipsum[4] \lipsum[4]

\lipsum[4] \lipsum[4] \lipsum[4] \lipsum[4] \lipsum[4]
\end{tcolorbox}

\end{document}

相关内容