1

Let's assume that I have defined very carefully the parameters of the highlight math style from the tcolorbox package.

I would like to define an environment

\newenvironment{equationbox}{%
    \begin{equation}%
    \tcbhighmath{% opening tcbhighmath
}{%
    }% closing tcbhighmath
    \end{equation}%
}

so that the result of using the environment would be:

\begin{equation}
\tcbhighmath{%the environment contents%}
\end{equation}

The current version is obviously not working. I tried to replace the braces with \bgroup \egroup but it does not seem to work either. How to do it?

3

The environ package seems to be made for this.

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{environ}
\NewEnviron{equationbox}{%
    \begin{equation}%
    \tcbhighmath{\BODY}
    \end{equation}%
}

\begin{document}
\begin{equation}%
    \tcbhighmath{E=mc^2}
\end{equation}
\begin{equationbox}
E=mc^2
\end{equationbox}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.