# overriding \everymath color: Is there an efficient way to apply color on every line for all arrays, and doing the same for cases as well?

TLDR; How does one efficiently apply color on every line of every array to override the color by \everymath? i.e from

to

(A compilable example of this is at the bottom)

Is there a way to efficiently apply \color{black} on every line for all arrays (rather than doing it line-by-line)?

I am a big fan of colors and I would like to color up all my inline maths to make the text more readable:

But I would like the color for display maths to remain black.

After some googling, I found Stefan's solution, which uses \everymath and \everydisplay from the everysel package. However, there is a known problem with \everydisplay: it does not work with some maths environments in amsmath. To get around it, he suggested redefining displayed math, and I found the following code snippet in OP's comments to his answer:

\let\originaldisplaystyle\displaystyle \renewcommand\displaystyle{\color{black}\originaldisplaystyle}
\let\oldeq\equation \def\equation{\oldeq\color{black}}

So I tried using them with \everymath, and they are working pretty well, except that the colors in array & cases are not overridden, and I get something like this:

I tried redefining cases like this:

\let\oldcase\cases \def\cases{\oldcase\color{black}}

but it only overrides the color of the first symbol:

Here is the latex for the equation above:

\label{phi} \phi(\delta,w)= \begin{cases} 1 & \text{if } \; \quad (a \in div_1 \land b \in div_2) \Leftrightarrow div_1 = div_2 \\ 0 & \text{if } \; \quad (a \in div_1 \land b \in div_2) \Leftrightarrow div_1 \not= div_2 \\ \end{cases} \text{ where } \begin{aligned} \renewcommand\arraystretch{1.25}\begin{array}[t]{|@{\hskip0.6em}l} \delta =\{div_1, div_2\} \\ w = \{a,b\} \end{array} \end{aligned}

On the other hand, I get Error: Illegal Character in array tag while trying to redefine array by \let\olda\array \def\array{\olda\color{black}}.

However, I am able to change one line of the array by putting \color{black} at the start of the line:

Is there a way to efficiently apply \color{black} on every line for all arrays (rather than doing it line-by-line)? How do I do the same for cases as well?

Here is a compilable example:

\documentclass[11pt, oneside]{article}
\usepackage{geometry}
\geometry{letterpaper}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{mathtools}

\usepackage{xcolor}
\definecolor{myColor}{HTML}{E93F3C}

\usepackage{everysel}

\everymath{\color{myColor}}
\let\originaldisplaystyle\displaystyle \renewcommand\displaystyle{\color{black}\originaldisplaystyle}
\let\oldeq\equation \def\equation{\oldeq\color{black}}

\begin{document}

A  \textit{div point set} is any order-pair $(P,\Theta_P)$ satisfying
\begin{alignat}{2}
\label{def1_1}
&\mathrlap{\lvert\Theta_P\rvert = \binom{\lvert P\rvert}{2} \land P \not= \varnothing} \\[1.5ex]
\label{def1_2}
& \forall D_n \in \Theta_P & \quad & \begin{aligned}[t] \renewcommand\arraystretch{1.25}\begin{array}[t]{|@{\hskip0.6em}l} \color{black}
(d_n,\delta_n) \mkern-2mu\coloneqq D_n \\
\lvert d_n\rvert =2\\
d_n \in \mathcal{P}(P)\\
\lvert\delta_n\rvert = 2\\
\bigcup \delta_n = P \setminus d_n \\
\bigcap \delta_n = \varnothing
\end{array}
\end{aligned}\\[1.5ex]
\label{def1_3}
& \forall D_n, D_m \in \Theta_P & \quad & \begin{aligned}[t] \renewcommand\arraystretch{1.25}\begin{array}[t]{|@{\hskip0.6em}l}
(d_n,\delta_n) \mkern-2mu\coloneqq D_n \\
(d_m,\delta_m) \coloneqq D_m\\
d_n= d_m \Leftrightarrow D_n=D_m
\end{array}
\end{aligned}
\end{alignat}

\label{phi} \phi(\delta,w)= \begin{cases} 1 & \text{if } \; \quad (a \in div_1 \land b \in div_2) \Leftrightarrow div_1 = div_2 \\ 0 & \text{if } \; \quad (a \in div_1 \land b \in div_2) \Leftrightarrow div_1 \not= div_2 \\ \end{cases} \text{ where } \begin{aligned} \renewcommand\arraystretch{1.25}\begin{array}[t]{|@{\hskip0.6em}l} \delta =\{div_1, div_2\} \\ w = \{a,b\} \end{array} \end{aligned}

\end{document}
• A complete compilable example would be better. – Manuel Sep 19 '15 at 11:20
• @Manuel alright, I have updated my answer regarding that. – Archy Will He 何魏奇 Sep 19 '15 at 11:36