如果我在环境\tcbhighmath
外使用tcolorbox
,它可以正常工作,但如果我在环境\tcbhighmath
内使用tcolorbox
,它会出错并且无法按预期工作。请查看下面的代码。代码生成附加的图像。知道如何让它在环境内工作吗tcolorbox
?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[most]{tcolorbox}
\begin{document}
\tcbset{highlight math style={enhanced,%<-- needed for the `remember' options
colframe=blue,colback=red!10!white,boxsep=0pt}} \begin{align*}
\tcbhighmath[remember as=fx]{f(x)}
&= \int\limits_{1}^{x} \frac{1}{t^2}~dt
= \left[ -\frac{1}{t} \right]_{1}^{x}\\
&= -\frac{1}{x} + \frac{1}{1}\\
&= \tcbhighmath[remember,overlay={%
\draw[red,very thick,->] (fx.south) to[bend right] ([yshift=2mm]frame.west);}]
{1-\frac{1}{x}.}
\end{align*}
\begin{tcolorbox}[title=Title]
\tcbset{highlight math style={enhanced,%<-- needed for the `remember' options
colframe=red,colback=red!10!white,boxsep=0pt}} \begin{align*}
\tcbhighmath[remember as=fx]{f(x)}
&= \int\limits_{1}^{x} \frac{1}{t^2}~dt
= \left[ -\frac{1}{t} \right]_{1}^{x}\\
&= -\frac{1}{x} + \frac{1}{1}\\
&= \tcbhighmath[remember,overlay={%
\draw[blue,very thick,->] (fx.south) to[bend right] ([yshift=2mm]frame.west);}]
{1-\frac{1}{x}.}
\end{align*}
\end{tcolorbox}
\end{document}
答案1
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[most]{tcolorbox}
\begin{document}
\tcbset{
highlight math style={
enhanced,%<-- needed for the `remember' options
colframe=blue,
colback=red!10!white,
boxsep=0pt},
%
every box on layer 2/.style={ % <---- applied to the nested boxes on layer 2
highlight math style={
enhanced,%<-- needed for the `remember' options
colframe=red,
colback=red!10!white,
boxsep=0pt}}}
\begin{align*}
\tcbhighmath[remember as=fx]{f(x)}
&= \int\limits_{1}^{x} \frac{1}{t^2}~dt
= \left[ -\frac{1}{t} \right]_{1}^{x}\\
&= -\frac{1}{x} + \frac{1}{1}\\
&= \tcbhighmath[remember,overlay={%
\draw[red,very thick,->] (fx.south) to[bend right] ([yshift=2mm]frame.west);}]
{1-\frac{1}{x}.}
\end{align*}
\begin{tcolorbox}[title=Title]
\begin{align*}
\tcbhighmath[remember as=fx]{f(x)}
&= \int\limits_{1}^{x} \frac{1}{t^2}~dt
= \left[ -\frac{1}{t} \right]_{1}^{x}\\
&= -\frac{1}{x} + \frac{1}{1}\\
&= \tcbhighmath[remember,overlay={%
\draw[blue,very thick,->] (fx.south) to[bend right] ([yshift=2mm]frame.west);}]
{1-\frac{1}{x}.}
\end{align*}
\end{tcolorbox}
\end{document}