很长的序列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}