2

For (copy) editing purposes I'd like to redefine the eqnarray envinronment to render its content in red (or any other colour). How can I do it?

Edit. I'll use this trick to better spot and (eventually) change the instances of eqnarray.

Gabriele
  • 1,815
  • It would be better to explain why you want it. I remember about your job, other people might not. – egreg Jun 19 '20 at 21:07

2 Answers2

5

I think etoolbox can do the trick

\documentclass{article}

\usepackage{xcolor} \usepackage{etoolbox}

\AtBeginEnvironment{eqnarray*}{\color{red}} \begin{document}

\begin{eqnarray} \dot x &=& v \ \dot v &=& F(x) \end{eqnarray}

\end{document}

1

Of course, one shouldn't use eqnarray. A similar approach to the suggestion by @Denys Potapov works with the align environment from the amsmath package. Note that the equation numbers will be coloured with align, whereas I don't think they will with eqnarray.

\documentclass{article}
\usepackage{amsmath}
\usepackage{color}
\let\oldalign\align
\def\align{%
\color{red}\oldalign}
\begin{document}
abc
\begin{align}
a &= b \\
  &= c
\end{align}
def
\end{document}
Ian Thompson
  • 43,767