尝试在显示方程中应用颜色,我刚刚从修改了环境amsmath.sty
。应用颜色时,上方和下方的空间会被修改(增加空间),请参见下图,在第一个方程中,下方空间更多,而第二个方程上方空间更多。
如何修复提到的默认空间\abovedisplayskip \belowdisplayskip
?
梅威瑟:
\documentclass{book}
\usepackage{amsmath,amsfonts,amssymb,color}
\makeatletter
\renewenvironment{equation}{\color{red}%
\incr@eqnum
\mathdisplay@push
\st@rredfalse \global\@eqnswtrue
\mathdisplay{equation}%
}{%
\endmathdisplay{equation}%
\mathdisplay@pop
\ignorespacesafterend
}
\def\start@align#1#2#3{\color{red}%
\let\xatlevel@#1% always \z@, \@ne, or \tw@
\maxfields@#3\relax
\ifnum\maxfields@>\m@ne
\checkat@true
\ifnum\xatlevel@=\tw@
\xxat@true
\fi
\multiply\maxfields@\tw@
\else
\checkat@false
\fi
\ifingather@
\iffalse{\fi\ifnum0=`}\fi
\DN@{\vcenter\bgroup\savealignstate@\align@#2}%
\else
\ifmmode
\if@display
\DN@{\align@recover}%
\else
\nomath@env
\DN@{\@namedef{end\@currenvir}{}\@gobble}%
\fi
\else
$$%
\let\split\insplit@
\DN@{\align@#2}%
\fi
\fi
\collect@body\next@
}
\makeatother
\begin{document}
text $inline equation a+b$
\[
a = b, \text{\qquad by assumption}
\]
Note the spacing command \qquad in the argument of \text. You could also
type
\[
a = b, \qquad \text{by assumption}
\]
because \qquad works in math as well as in text (see Sections 8.1 and B.9).
\begin{equation}\label{E:firstInt}
aa+bb \sin x \, dx = 2
\end{equation}
because \qquad works in math as well as in text (see Sections 8.1 and B.9).
\begin{equation}\label{E:firstInt}
\int_{0}^{\pi} \sin x \, dx = 2
\end{equation}
type the following, using as the line separator and \& as the alignment point:
\begin{align}
r^{2} &= s^{2} + t^{2}, \label{E:Pyth}\\
2u + 1 &= v + w^{\alpha}, \label{E:alpha}\\
x &= \frac{y + z}{\sqrt{s + 2u}};\label{E:frac}
\end{align}
is typed as follows:
$$
f(x)=
\begin{cases}
-x^{2}, &\text{if $x < 0$;}\\
\alpha + x, &\text{if $0 \leq x \leq 1$;}\\
x^{2}, &\text{otherwise.}
\end{cases}
$$
which is typed as
\begin{gather*}
\overleftarrow{a} \quad \overrightarrow{aa}\\
\overleftrightarrow{aaa} \quad \underleftarrow{aaaa}\quad
\underrightarrow{aaaaa} \quad \underleftrightarrow{aaaaaa}
\end{gather*}
This formula is typed as
\begin{multline}\label{E:mm2}
(x_{1} x_{2} x_{3} x_{4} x_{5} x_{6})^{2}\\
+ (y_{1} y_{2} y_{3} y_{4} y_{5}
+ y_{1} y_{3} y_{4} y_{5} y_{6}
+ y_{1} y_{2} y_{4} y_{5} y_{6}
+ y_{1} y_{2} y_{3} y_{5} y_{6})^{2}\\
+ (z_{1} z_{2} z_{3} z_{4} z_{5}
+ z_{1} z_{3} z_{4} z_{5} z_{6}
+ z_{1} z_{2} z_{4} z_{5} z_{6}
+ z_{1} z_{2} z_{3} z_{5} z_{6})^{2}\\
+ (u_{1} u_{2} u_{3} u_{4} + u_{1} u_{2} u_{3} u_{5}
+ u_{1} u_{2} u_{4} u_{5} + u_{1} u_{3} u_{4} u_{5})^{2}
\end{multline}
\end{document}