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.

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

2 Answers 2

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
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}
4
  • I guess that the OP's aim is to visually find the instances of eqnarray so to be able to change them in the source.
    – egreg
    Jun 19, 2020 at 21:02
  • @egreg --- I fully support any effort to find and remove instances of eqnarray. Jun 19, 2020 at 21:04
  • 1
    The OP explained time ago that he's in charge of copy editing, so my guess.
    – egreg
    Jun 19, 2020 at 21:06
  • @egreg Indeed i'll use this trick to better spot and (eventually) change the instances of eqnarray ;-) Jun 19, 2020 at 22:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .