I use the empheq
package along with the xcolor
package to display equations in coloured boxes. I also wish to change the text colour of the equation. In single-line environments, such as equation
, this works perfectly. With multi-line AMS environments, however, the text colour is only applied to the first line, then the equation goes on with the default colour from the second line.
The MWE goes as follows:
\documentclass{article}
\usepackage[svgnames, x11names]{xcolor}
\usepackage{amsmath}
\usepackage{empheq}
\newcommand{\HEG}[1]{\begin{empheq}[box = \colorbox{Thistle4}]{gather}{\color{Snow1}#1}\end{empheq}}
\begin{document}
\HEG{\mathcal{T}\left(a_1\left\{x_{1k}\right\} + a_2\left\{x_{2k}\right\}\right) =\\\nonumber
= a_1 \mathcal{T}\left(\left\{x_{1k}\right\}\right) + a_2 \mathcal{T}\left(\left\{x_{2k}\right\}\right)}
\end{document}
This will produce the following output:
Manually inserting colour definition at the beginning of the new line will work, ie:
\documentclass{article}
\usepackage[svgnames, x11names]{xcolor}
\usepackage{amsmath}
\usepackage{empheq}
\newcommand{\HEG}[1]{\begin{empheq}[box = \colorbox{Thistle4}]{gather}{\color{Snow1}#1}\end{empheq}}
\begin{document}
\HEG{\mathcal{T}\left(a_1\left\{x_{1k}\right\} + a_2\left\{x_{2k}\right\}\right) =\\\nonumber
\color{Snow1}= a_1 \mathcal{T}\left(\left\{x_{1k}\right\}\right) + a_2 \mathcal{T}\left(\left\{x_{2k}\right\}\right)}
\end{document}
will produce
Is there a way to configure empheq
to keep the text colour across multiple lines without manual insertions of the colour definition? Your thoughts are much appreciated.
\newcommand{\HEG}[1]{{\color{Snow1}\begin{empheq}[box = \colorbox{Thistle4}]{gather}{#1}\end{empheq}}}
amsmath
beforeempheq
.