I would like to be able to highlight mathematical formulas by placing them in a nice box (with rounded corners and a background color).
So far, I have found this in my macros, but it is not working for centered formulas.
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand\myBox[2][]{\tikz[overlay]\node[fill=blue!20,inner xsep=4pt, inner ysep=4pt, anchor=text, rectangle, rounded corners=3pt,#1] {#2};\phantom{#2}}
\begin{document}
\myBox{Test}
[
\myBox{\left |\int_0^1 f(x)g(x)dx \right |} % This does not compile
]
\end{document}
Optional arguments
As in this answer, if the command could take arguments like \myBox[lr=3pt,tb=9pt]{...} to change the inner sep or inner ysep it would be great.


\usepackage[most]{tcolorbox}and\tcbhighmath{Test}, for example ... Thehighlightmathstyle is configurable, or you could usetcboxmathinstead, so changing the margins, colour etc. is no real problem then – Jan 14 '17 at 17:32