ntheorem Box 跨越多页并有持续提示?

ntheorem Box 跨越多页并有持续提示?

当我的 ntheorem Box 跨越多页时,我希望它在每一页上都有一个提示,表明它是一个延续。该怎么做?

下面是一些示例代码,跨越两页的框,但第二页上缺少一个提示,表明它是一个延续。

\documentclass[]{article}

\usepackage{blindtext}

\usepackage{framed} 
\usepackage{pstricks} 
\usepackage[framed]{ntheorem}

\begin{document}
\newshadedtheorem{test}{Example}

\begin{test}
\textbf{Some sample text}
\blindtext[5]
\end{test}

At the beginning of the box at page 2 it shall have\\
\textbf{Example 1 (Continued)}.\\
(Included at the top of the box, not before the box).

\end{document}

预览:

在此处输入图片描述

答案1

这可以通过使用以下任一方式轻松实现mdframed或者tcolorbox包。

使用的选项mdframed

\documentclass[]{article}
\usepackage[a6paper]{geometry}% just for the example
\usepackage{blindtext}
\usepackage[framemethod=tikz]{mdframed} 
\usepackage{ntheorem}

\newmdtheoremenv[
  ntheorem=true,
  hidealllines=true,
  backgroundcolor=gray!50,
  splittopskip=2\baselineskip,
  middleextra={\node[anchor=north west,font=\bfseries,inner xsep=0pt,xshift=10pt] at (P-|O) {Example~\thetest\ (Continued)};},
  secondextra={\node[anchor=north west,font=\bfseries,inner xsep=0pt,xshift=10pt] at (P-|O) {Example~\thetest\ (Continued)};}
]{test}{Example}

\begin{document}

\begin{test}[An example]
\blindtext[3]
\end{test}

\end{document}

在此处输入图片描述

现在可以使用以下选项tcolorbox

\documentclass[]{article}
\usepackage[a6paper]{geometry}% just for the example
\usepackage{blindtext}
\usepackage[most]{tcolorbox} 

\newcounter{test}

\newtcolorbox{test}[2][%
breakable,
arc=0pt,
outer arc=0pt,
coltitle=black,
fonttitle=\bfseries,
boxrule=0pt,
colframe=gray!30,
colback=gray!30,
title after break={Example~\thetest\ (Continued)}
]{%
before upper={
  \stepcounter{test}\textbf{Example~\thetest.\ }%
},
label={#2},
#1}

\begin{document}

\begin{test}{testa}
\blindtext[3]
\end{test}

\end{document}

在此处输入图片描述

相关内容