我使用tcolorbox
包跨页面绘制可破坏的盒子。我可以用钥匙引用盒子的开头label
。有没有一种自动引用盒子结尾(页面)的方法?
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{breakable, skins}
\newtcolorbox[%
auto counter]{mybox}[2][]{%
enhanced jigsaw,
breakable,
#1}
\usepackage{kantlipsum}
\begin{document}
My box begins page \pageref{begin} and ends page \pageref{end}.
\begin{mybox}[label = begin]{}
\kant
\end{mybox}
\end{document}
答案1
根据 OP 的评论,我引入了两个新键label begin
并label end
完成所要求的工作:
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{breakable, skins}
\tcbset{%
label begin/.style={label={#1}},% just for symmetry
label end/.style={after upper=\label{#1}}% new end label
}
\newtcolorbox[%
auto counter]{mybox}[2][]{%
enhanced jigsaw,
breakable,
#1}
\usepackage{kantlipsum}
\begin{document}
My box begins page \pageref{begin} and ends page \pageref{end}.
\begin{mybox}[label begin=begin,label end=end]{}
\kant
\end{mybox}
\end{document}
关键label begin
就在于对称,因为它与label
自身相同。
答案2
\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{breakable, skins}
\newtcolorbox[%
auto counter]{mybox}[2][]{%
enhanced jigsaw,
breakable,
#1}
\usepackage{kantlipsum}
\begin{document}
My box begins page \pageref{begin} and ends page \pageref{end}.
\begin{mybox}[label = begin]{}
\kant\label{end}
\end{mybox}
\end{document}