4

Structure: Using tcolorbox to take advantage of page-breakable paragraph or list contents, I am trying to use a long table above this to align some summary information.

But I am observing that if I place a long table above an environment created list, the once breakable tcolorbox, decides it can only break in between the distinct objects (i.e. at the seam between the longtable and the list). Removing the commented out longtable environment in the MWE below will demonstrate what I mean.

Is there a bug in tcolorbox, or some longtable induced par or wrapping insertion that tricks tcolorbox into placing the list in it's own vbox or something?

\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}

credit: How to align `tcolorbox` at the top? for the base of this MWE

EngBIRD
  • 3,985

1 Answers1

5

The problem is not related to lists, and longtable doesn't make things "unbreakable". The source of the problem is a penalty inserted by longtable which forces a page break. One can avoid it by setting this penalty to a smaller value. But I don't know if this will have bad side effects, imho David Carlisle and Thomas Sturm will have to look into it.

\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}
Ulrike Fischer
  • 327,261
  • Thanks!!!!! Since testing your solution didn't have any ramifications on my other non-tcolorbox encapsulated longtables this is a nice clean solution I can use until I am cautioned against it and provided with an alternative. – EngBIRD Nov 19 '15 at 19:45
  • This solution is still useful as of 2021. I have several shorter longtables (this may sound weird, but anyways ...) placed below one another in a breakable tcolorbox. In certain cases, all longtables except the first one would be shifted to the next page. Decreasing the said penaltiy solved this. – Jasper Habicht Nov 11 '21 at 07:51