I've seen somewhere such a shape of a highlight.
I am trying to repeat this using xcolor
package, but I managed to get only rectangular shape of the box.
\colorbox{red!10}{$\displaystyle\int xe^{-x}dx$}
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityOne can combine tcolorbox
and empheq
. With \tcbhighmath
you can highlight individual subexpressions.
\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}
You can always change highlight math style
to change the appearance.
top
and so on. I used these keys to make the boxes tighter. You can change the dimensions as you like.
– user194703
May 14 '20 at 18:23
\tcbhighmath[.style={top=5ex}]
is not a working syntax, yes. You need to say something like \tcbhighmath[blue eqbox,{top=2ex}]{-(1+x)e^{-x}}
. Please also consider the fact that I really tried to answer your original question, which I think I did. Comments are not meant to be a chat.
– user194703
May 14 '20 at 18:37
\colorbox
is always rectangular, look at packages such astcolorbox
which has many many options for fancier boxes – David Carlisle May 14 '20 at 17:54