3

I have a tcolorboxenvironment around an AMS theorem that I would like to be breakable. The problem is that I would like a more noticeable indicator for the break than the defaults seem to provide. The best that I've found is to set the option title after break, but my other tcolorboxenvironments don't have the title, so this looks strange.

I've tried setting first's borderline south and last's borderline north, but neither has an effect. I've also tried using first's after upper and last's before lower, also without effect (this outcome would be my preference). I think it should be possible to achieve the borderline effect via the skin engines, but I'm having trouble understanding that much of the documentation.

How can I better indicate that a tcolorbox is continuing onto the next page?

\documentclass{article}

\usepackage{amsthm}
\usepackage[breakable,skins]{tcolorbox}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{lipsum}

\newtheorem{mytheorem}{Theorem}

\tcolorboxenvironment{mytheorem}{
  enhanced,
  colframe=blue,
  interior style={top color=blue!20, bottom color=blue!10},
  breakable=true,
  title after break={Theorem \themytheorem\ Continued}, % works, but not great
  extras first={
    after upper={continued \ldots}, % doesn't work
    borderline south={0.25mm}{0.5mm}{red,decoration={zigzag,amplitude=0.5mm},decorate} % doesn't work
  },
  extras last={
    before lower={\ldots\ continued\par}, % doesn't work
    borderline north={0.25mm}{0.5mm}{red,decoration={zigzag,amplitude=0.5mm},decorate} % doesn't work
  }
}

\begin{document}

\lipsum[1-3]

\begin{mytheorem}[My Theorem]
 \lipsum[4-6]
\end{mytheorem}

\end{document}
2
  • 1
    You could work with overlay first and so on as in tex.stackexchange.com/a/455377/194703. How should the box look like at the break?
    – user194703
    May 20, 2020 at 16:37
  • The zigzag of tex.stackexchange.com/a/455377/107497 would be my second choice (thanks for that). My first choice would be \textit{\small(continued)} at the end of first and to repeat the theorem head spec along with \ --- Continued at the beginning of last.
    – Teepeemm
    May 20, 2020 at 16:46

1 Answer 1

4

This is very similar to this answer. I just added some overlays.

\documentclass{article}

\usepackage{amsthm}
\usepackage[breakable,skins]{tcolorbox}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{lipsum}

\newtheorem{mytheorem}{Theorem}

\tcolorboxenvironment{mytheorem}{
  enhanced,
  colframe=blue,
  interior style={top color=blue!20, bottom color=blue!10},
  breakable=true,
  %title after break={Theorem \themytheorem\ Continued}, % works, but not great
  overlay first={%
      \path[font=\small\itshape] (frame.south) node (cont) {(continued)};
      \draw[thick,red,decoration={zigzag,amplitude=0.5mm},decorate]
       (frame.south west) -- (cont.west)
       (frame.south east) -- (cont.east);
  },
  overlay middle={%
      \path[font=\small\itshape] (frame.south) node {(continued)};
      \draw[thick,red,decoration={zigzag,amplitude=0.5mm},decorate]
       (frame.south west) -- (cont.west)
       (frame.south east) -- (cont.east);
  },
  overlay last={%
      \path[font=\small\itshape] (frame.north) node (cont) {Theorem \themytheorem\ Continued};
      \draw[thick,red,decoration={zigzag,amplitude=0.5mm},decorate]
       (frame.north west) -- (cont.west)
       (frame.north east) -- (cont.east);
  },
}

\begin{document}

\lipsum[1-3]

\begin{mytheorem}[My Theorem]
 \lipsum[4-6]
\end{mytheorem}
\end{document}

enter image description here

enter image description here

One may want to add complete zigzag's that are based on Jake's complete sines, and to make the fill stop at the decoration.

\documentclass{article}

\usepackage{amsthm}
\usepackage[breakable,skins]{tcolorbox}
\usetikzlibrary{decorations.pathmorphing}
\pgfdeclaredecoration{complete zigzag}{initial}{
\state{initial}[
        width=+0pt,
        next state=half up,
        persistent precomputation={\pgfmathsetmacro\matchinglength{
            \pgfdecoratedinputsegmentlength / int(\pgfdecoratedinputsegmentlength/\pgfdecorationsegmentlength)}
            \setlength{\pgfdecorationsegmentlength}{\matchinglength pt}
        }] {}
  \state{half up}[
        width=+.25\pgfdecorationsegmentlength,
        next state=big down]
        {\pgfpathlineto{\pgfqpoint{.25\pgfdecorationsegmentlength}{\pgfdecorationsegmentamplitude}}
    }
  \state{big down}[switch if less than=+.5\pgfdecorationsegmentlength to center finish,
                   width=+.5\pgfdecorationsegmentlength,
                   next state=big up]
  {
    \pgfpathlineto{\pgfqpoint{.5\pgfdecorationsegmentlength}{-\pgfdecorationsegmentamplitude}}
  }
  \state{big up}[switch if less than=+.5\pgfdecorationsegmentlength to center finish,
                 width=+.5\pgfdecorationsegmentlength,
                 next state=big down]
  {
    \pgfpathlineto{\pgfqpoint{.5\pgfdecorationsegmentlength}{\pgfdecorationsegmentamplitude}}
  }
  \state{center finish}[width=0pt, next state=final]{
  }
  \state{final}
  {
    \pgfpathlineto{\pgfpointdecoratedpathlast}
  }
}

\usepackage{lipsum}

\newtheorem{mytheorem}{Theorem}

\tcolorboxenvironment{mytheorem}{
  enhanced,
  colframe=blue,
  interior style={top color=blue!20, bottom color=blue!10},
  breakable=true,
  %title after break={Theorem \themytheorem\ Continued}, % works, but not great
  overlay first={%
      \path[font=\small\itshape] (frame.south) node (cont) {(continued)};
      \begin{scope}[decoration={complete zigzag,amplitude=0.5mm}]
       \path[fill=blue!10]  decorate {([xshift=1.2pt]frame.south west) -- (cont.west)} --++
        (0,0.5ex) -| cycle
        decorate {([xshift=-1.2pt]frame.south east) -- (cont.east)} --++
        (0,0.5ex) -| cycle;
       \path[fill=white]
        decorate {([xshift=1.2pt]frame.south west) -- (cont.west)} --++
        (0,-0.5ex) -| cycle
        decorate {([xshift=-1.2pt]frame.south east) -- (cont.east)} --++
        (0,-0.5ex) -| cycle;
       \draw[thick,red,decorate] ([xshift=1.2pt]frame.south west) -- (cont.west);
       \draw[thick,red,decorate] ([xshift=-1.2pt]frame.south east) -- (cont.east);
      \end{scope} 
  },
  overlay middle={%
      \path[font=\small\itshape] (frame.south) node (cont) {(continued)};
      \begin{scope}[decoration={complete zigzag,amplitude=0.5mm}]
       \path[fill=blue!10]  decorate {([xshift=1.2pt]frame.south west) -- (cont.west)} --++
        (0,0.5ex) -| cycle
        decorate {([xshift=-1.2pt]frame.south east) -- (cont.east)} --++
        (0,0.5ex) -| cycle;
       \path[fill=white]
        decorate {([xshift=1.2pt]frame.south west) -- (cont.west)} --++
        (0,-0.5ex) -| cycle
        decorate {([xshift=-1.2pt]frame.south east) -- (cont.east)} --++
        (0,-0.5ex) -| cycle;
       \draw[thick,red,decorate] ([xshift=1.2pt]frame.south west) -- (cont.west);
       \draw[thick,red,decorate] ([xshift=-1.2pt]frame.south east) -- (cont.east);
      \end{scope} 
      \path[font=\small\itshape] (frame.north) node (thm) {Theorem \themytheorem\ continued};
      \begin{scope}[decoration={complete zigzag,amplitude=0.5mm}]
       \path[fill=blue!20]  decorate {([xshift=1.2pt]frame.north west) -- (thm.west)} --++
        (0,-0.5ex) -| cycle
        decorate {([xshift=-1.2pt]frame.north east) -- (thm.east)} --++
        (0,-0.5ex) -| cycle;
       \path[fill=white]
        decorate {([xshift=1.2pt]frame.north west) -- (thm.west)} --++
        (0,0.5ex) -| cycle
        decorate {([xshift=-1.2pt]frame.north east) -- (thm.east)} --++
        (0,0.5ex) -| cycle;
       \draw[thick,red,decorate] ([xshift=1.2pt]frame.north west) -- (thm.west);
       \draw[thick,red,decorate] ([xshift=-1.2pt]frame.north east) -- (thm.east);
      \end{scope} 
  },
  overlay last={%
      \path[font=\small\itshape] (frame.north) node (thm) {Theorem \themytheorem\ continued};
      \begin{scope}[decoration={complete zigzag,amplitude=0.5mm}]
       \path[fill=blue!20]  decorate {([xshift=1.2pt]frame.north west) -- (thm.west)} --++
        (0,-0.5ex) -| cycle
        decorate {([xshift=-1.2pt]frame.north east) -- (thm.east)} --++
        (0,-0.5ex) -| cycle;
       \path[fill=white]
        decorate {([xshift=1.2pt]frame.north west) -- (thm.west)} --++
        (0,0.5ex) -| cycle
        decorate {([xshift=-1.2pt]frame.north east) -- (thm.east)} --++
        (0,0.5ex) -| cycle;
       \draw[thick,red,decorate] ([xshift=1.2pt]frame.north west) -- (thm.west);
       \draw[thick,red,decorate] ([xshift=-1.2pt]frame.north east) -- (thm.east);
      \end{scope} 
  },
}

\begin{document}

\lipsum[1-3]

\begin{mytheorem}[My Theorem]
 \lipsum[4-6]
\end{mytheorem}
\end{document}

enter image description here

enter image description here

4
  • Thanks for this; I'll have to study complete zigzag for awhile. I have two questions so far. (1) It seems that the big challenge for complete zigzags and complete sines is to have it end at just the right time. But since we can have an empty horizontal break leading into the added text, does that simplify the calculations of "complete zigzag"? (It does seem that the \path[fill] is what makes the fill stop at the decoration, so ``complete zigzag'' isn't needed for that effect.)
    – Teepeemm
    May 20, 2020 at 22:10
  • (2) I newcommanded \continuebottom and \continuetop so that I could have overlay first={\continuebottom}, overlay middle={\continuebottom\continuetop}, overlay last={\continuetop}, without retyping everything. Is there any downside to doing so?
    – Teepeemm
    May 20, 2020 at 22:10
  • 2
    @Teepeemm (1) Yes, these are separate issues, which I combined in one optional upgrade. One can disentangle them, of course. (2) Yes, absolutely, or, instead of macros continue top/.code={...},continue bottom/.code={...} to save some name space. The name space issue is the only potential downside I could see, but this can be mitigated by using pgf keys.
    – user194703
    May 20, 2020 at 22:19
  • This is absolutely beautiful! It helped me solve an issue in a book I'm writing which bothered me for a while. Many thanks!
    – pelegs
    Nov 23, 2023 at 19:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .