2

When gather* is used together with \everydisplay an error is produced. Is there a possibility to make these work together?

Minimal working example:

\documentclass{ctexart}
\usepackage{amsmath,color}
\everydisplay{\color{blue}}
\begin{document}
\begin{gather*}
1+\cos x
\end{gather*}
\end{document}
Martin Scharrer
  • 262,582
Rushavski
  • 281
  • 2
  • 7

2 Answers2

3

Instead of \everydisplay, \everymath could be used. This applies to gather as well. To avoid coloring of inline math, you could check if you are within gather or align similar to amsmath's own checks.

Complete example:

\documentclass{article}
\usepackage{amsmath,color}
\newcommand*{\eqcolor}{\color{blue}}
\makeatletter
\everymath{%
  \ifingather@ \eqcolor%
    \else \ifinalign@ \eqcolor
      \fi
  \fi
}
\makeatother
\begin{document}
\begin{gather*}
1+\cos x
\end{gather*}
\begin{align*}
1+\cos x
\end{align*}
\centering $1 + \cos x$
\end{document}

enter image description here

As you can see, inline math is not colored. Regarding other displayed math: instead of equation or \[ ... \] you could use gather or gather*, respectively. This could be done in the preamble, without changes to equation environments in the text, such as

\let\equation\gather
\let\endequation\endgather
Stefan Kottwitz
  • 231,401
0

If you just say \everydisplay{\color{blue}}, then the previous content of it gets erased and you will have these kind of problems. The right way to use \everydisplay is:

\everydisplay\expandafter{\the\everydisplay \color{blue}}

Then no problem should happen.

IRAN
  • 2,338