# Auto Generate Custom Text Message for Page Break

I created a new environment that creates a box around text. I used tcolorbox. Additionally, since I wanted to break from page to page, I added 'breakable'. However, what I want it to do is to break the box from page to page, but also automatically write a message, for example, "theorem x cont.", anytime there are breaks in the page. I want to write this message inside the box. How can I do this?

Edit: Basically, I want to do this: Breaking a theorem between pages, but not using mdframed and inside my box which contains other text.

I want to do something like this: The italicized text. Blue line represents page break.

My code thus far:

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\usepackage{lipsum}

\newenvironment{cframed}
{\begin{tcolorbox}[breakable,colback=gray!6]}
{\end{tcolorbox}}

\begin{document}

\begin{cframed}
\lipsum[1-10]
\end{cframed}
\end{document}

• Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – ebosi Apr 8 '16 at 7:31
• The picture is a good hint. Yet a MWE is to follow: 1) to see your attempts and 2) to just have a starting point. Help your helpers! :) – Ruben Apr 8 '16 at 8:01
• @Ruben Edited it – user102690 Apr 8 '16 at 8:08
• the title after breakcould help you : page 307 of the tcolorbox documentation – flav Apr 8 '16 at 8:51
• @flav Is there a way to get the number. For example, thm 1 cont.? – user102690 Apr 8 '16 at 8:55

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\usepackage{lipsum}

\newcounter{theoInt}
\newcommand\numtheo{\stepcounter{theoInt}\arabic{theoInt}}

\newenvironment{cframed}
{\begin{tcolorbox}[breakable,%
colback=gray!6,titlerule=0pt,
title after break=\emph{Theorem \numtheo{} cont.},
colbacktitle=white, coltitle=black]}
{\end{tcolorbox}}

\begin{document}

\begin{cframed}
\lipsum[1-10]
\end{cframed}
\end{document}


• Instead of X, I want it to show the number of the theorem – user102690 Apr 8 '16 at 8:56
• Also, is there a way to get rid of that line under Theorem X cont.? – user102690 Apr 8 '16 at 8:59
• you can use a counter – flav Apr 8 '16 at 9:10
• What about getting rid of the line? – user102690 Apr 8 '16 at 9:13
• set ,titlerule=0pt, – flav Apr 8 '16 at 9:16
\documentclass{article}
\usepackage[paperwidth=12cm,paperheight=10cm]{geometry}%for testing purposes
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\usepackage{lipsum}

\makeatletter
\declaretheoremstyle[
notefont=\mdseries,
notebraces={(}{)},
bodyfont=\normalfont,
breakable, titlerule=\z@, colbacktitle=gray!6, colback=gray!6, coltitle=black,
title after break={\itshape\thmt@thmname~\csname the\thmt@envname\endcsname~(cont.)}]},
prefoothook=\end{tcolorbox}
]{framedthm}
\makeatother
\declaretheorem[style=framedthm,numbered=yes]{theorem}

\begin{document}

\begin{theorem}
\lipsum[1-2]
\end{theorem}

\end{document}


• Is there a way to get rid of that formatting for Theorem 1 (cont.)? – user102690 Apr 8 '16 at 9:05
• @user102690, yes. I updated the answer. – Ruben Apr 8 '16 at 9:34