获取长断 tcolorbox 的 tcbbreakpart 的最大值

获取长断 tcolorbox 的 tcbbreakpart 的最大值

很长的序列tcolorbox可以分成许多个框。“中断序列的各个部分由计数器 tcbbreakpart 编号。”(手册 4.11 第 363 页)

有没有办法获取的最大值tcbbreakpart并用其替换“X”?

\documentclass[twoside]{book}
\usepackage[all]{tcolorbox}
\usepackage{lipsum}

\begin{document}

% Example modified from  tcolorbox-example.tex (2017-09-14) by Prof. Dr. Dr. Thomas F. Sturm

\begin{tcolorbox}[enhanced jigsaw,breakable,pad at break*=1mm,
colback=blue!5!white,colframe=blue!75!black,title={Example modified from  tcolorbox-example.tex (2017-09-14) by Prof. Dr. Dr. Thomas F. Sturm},
fonttitle=\huge\bfseries,
title after break={\huge\bfseries
This is p. \arabic{tcbbreakpart} of a total of X pages for this long  broken TColorBox},
watermark color=yellow,watermark text=\Roman{tcbbreakpart}]
\lipsum[1-30]
\end{tcolorbox}


\end{document}

在此处输入图片描述

答案1

一种方法是使用\label和系统,提取特定盒子的reference存储号码。tcbbreakpart

该宏添加了一个带有值\postboxlabel的虚假标签tcbbreakpart该框已排版。

\documentclass[twoside]{book}
\usepackage[all]{tcolorbox}
\usepackage{lipsum}
\usepackage{refcount}

\makeatletter
\newcommand{\postboxlabel}[1]{\protected@edef\@currentlabel{\csname p@tcbbreakpart\endcsname\thetcbbreakpart}\label{#1}}
\makeatother

\begin{document}

% Example modified from  tcolorbox-example.tex (2017-09-14) by Prof. Dr. Dr. Thomas F. Sturm

\begin{tcolorbox}[enhanced jigsaw,breakable,pad at break*=1mm,
colback=blue!5!white,colframe=blue!75!black,title={Example modified from  tcolorbox-example.tex (2017-09-14) by Prof. Dr. Dr. Thomas F. Sturm},
fonttitle=\huge\bfseries,
title after break={\huge\bfseries
This is p. \arabic{tcbbreakpart} of a total of \getrefnumber{mynicebox} pages for this long  broken TColorBox},
watermark color=yellow,watermark text=\Roman{tcbbreakpart},after={\postboxlabel{mynicebox}}]
\lipsum[1-30]
\end{tcolorbox}


\end{document}

在此处输入图片描述

相关内容