答案1
可以将tcolorbox
和组合起来empheq
。使用\tcbhighmath
可以突出显示单个子表达式。
\documentclass{article}
\usepackage[theorems,skins]{tcolorbox}
\usepackage{empheq}
\tcbset{red eqbox/.style={enhanced,top=0.2ex, bottom=0.2ex,
left=0.1ex,right=0.1ex,
overlay={\fill[red!10] (frame.south west) to[bend left]
(frame.north west) -- (frame.north east) to[bend left]
(frame.south east) -- cycle;},
boxrule=0pt},
blue eqbox/.style={enhanced,top=0.2ex, bottom=0.2ex,
left=0.1ex,right=0.1ex,
overlay={\fill[blue!10] (frame.south west) to[bend left]
(frame.north west) -- (frame.north east) to[bend left]
(frame.south east) -- cycle;},
boxrule=0pt},
highlight math style=red eqbox}
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
\begin{document}
\begin{empheq}[box=\tcbhighmath]{equation}
\int x \,e^{-x}\,\diff x
\end{empheq}
\begin{align}
\tcbhighmath{\int x \,e^{-x}\,\diff x}~&=
\left.\int x \,e^{-ax}\,\diff x\right|_{a=1}
\notag\\
&=
\left[-\frac{\diff}{\diff a}
\int e^{-ax}\,\diff x\right]_{a=1}
=\left[\frac{\diff}{\diff a}\frac{e^{-ax}}{a}\right]_{a=1}
\notag\\
&=~\tcbhighmath[blue eqbox]{-(1+x)e^{-x}}
\end{align}
\end{document}
您可以随时改变highlight math style
以改变外观。