### Who is online

In total there are 10 users online :: 0 registered, 0 hidden and 10 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: No registered users and 10 guests

## empheq | Coloring all Equations in an aligned System

empheqequationsAdd tags Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).

### empheq | Coloring all Equations in an aligned System

Suppose I'm using the empheq package with the corresponding environment and have the following code.
Code: Select all  •  Open in writeLaTeX
\begin{empheq}[box=\widefbox]{align}{\color{red}A}&=B+C\nonumber\\&=D \nonumber\\&=E+F\end{empheq}

This paints A in red. I want to color all of the equations, e.g. like this.
Code: Select all  •  Open in writeLaTeX
\begin{empheq}[box=\widefbox]{align}{\color{red}A&=B+C\nonumber\\&=D \nonumber\\&=E+F}\end{empheq}

But I get an error.

How can sort this out? I don't want to specify color command for each expression of equation line (e.g. I may have 20 equations).

Thanks
hbaromega

Posts: 48
Joined: Mon Mar 7th, 2011

### Re: empheq | Coloring all Equations in an aligned System

This is not working because every cell in align is a group in itself (just like in a {tabular}). The error you're getting is because you open a new group with { in the first cell but don't close it there again. Similarly the color setting is forgotten in the next cell because it was limited to the scope of the first cell. An own environment might be of help:

Code: Select all  •  Open in writeLaTeX
\documentclass{article}\usepackage{amsmath,empheq,xcolor}\newcommand*\widefbox[1]{\fbox{\hspace{1em}#1\hspace{1em}}}% see the empheq documentation for examples like this one:\newenvironment{important}[2][]{%  \setkeys{EmphEqEnv}{#2}%  \setkeys{EmphEqOpt}{box=\normalcolor\widefbox,#1}%  \color{red}%  \EmphEqMainEnv}%  {\endEmphEqMainEnv}\begin{document}\begin{important}{align} A &= B+C\nonumber\\   &= D \nonumber\\   &= E+F\end{important}\end{document}

But this will also color the equation numbers.

Regards
Clemens
------------------------------
New German Q&A site about TeX: http://texwelt.de/wissen

cgnieder
Site Moderator

Posts: 1699
Joined: Sat Apr 16th, 2011
Location: Germany

### Re: empheq | Coloring all Equations in an aligned System

Thanks, Clemens.

But for every coloring (suppose, next time I want to color in blue) I have to define a new environment. Isn't it? Could be there an alternative/simpler way?
hbaromega

Posts: 48
Joined: Mon Mar 7th, 2011

### Re: empheq | Coloring all Equations in an aligned System

No, you can define an optional argument for that:

Code: Select all  •  Open in writeLaTeX
\documentclass{article}\usepackage{amsmath,empheq,xcolor}\newcommand*\widefbox[1]{\fbox{\hspace{1em}#1\hspace{1em}}}\usepackage{xparse}% flexible defining of document commands% see the empheq documentation for examples like this one:\NewDocumentEnvironment{important}{O{red}O{}m}{%  \setkeys{EmphEqEnv}{#3}%  \setkeys{EmphEqOpt}{box=\normalcolor\widefbox,#2}%  \color{#1}%  \EmphEqMainEnv}%  {\endEmphEqMainEnv}\begin{document}\begin{important}{align} A &= B+C\nonumber\\   &= D \nonumber\\   &= E+F\end{important}\begin{important}[blue]{align} A &= B+C\nonumber\\   &= D \nonumber\\   &= E+F\end{important}\end{document}

Regards
Clemens
------------------------------
New German Q&A site about TeX: http://texwelt.de/wissen

cgnieder
Site Moderator

Posts: 1699
Joined: Sat Apr 16th, 2011
Location: Germany

### Re: empheq | Coloring all Equations in an aligned System

Interesting! This will go into me "treasure box" of LaTeX tricks.
In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

svend_tveskaeg

Posts: 477
Joined: Sun Jul 12th, 2009
Location: Aarhus, Denmark

empheqequations