改变 align* 环境的颜色

改变 align* 环境的颜色

我有一段想要包含在 LaTeX 文档中的文本。我只想更改 align* 环境中方程的颜色,但当我这样做时,文档其余部分的颜色也会改变。

这是一个最小的 tex 文档:

\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{amsmath}

\begin{document}

\color{blue}{\begin{align*}
\tau_1 -\frac{1}{2}(\tau_2 + \tau_3) & \in \left( -0.035 -\frac{1}{2}(2.70) 
-\frac{1}{2}(1.99) \pm \sqrt{(3-1)(4.26)} \sqrt{ 0.081 \left( \frac{1^2 +(- 
\frac{1}{2})^2 + (-\frac{1}{2})^2}{4} \right) } \right) \\
\tau_1 -\frac{1}{2}(\tau_2 + \tau_3) & \in \left( -2.38 \pm \sqrt{8.52} 
\sqrt{0.081(0.375)} \right) = \left( -2.38 \pm 2.92 \sqrt{0.30} \right) = 
(-2.38 \pm 1.60)\\
\tau_1 -\frac{1}{2}(\tau_2 + \tau_3) & \in (-3.98, -0.78)
\end{align*}}

I do not want this text to be blue, but it still is blue. Why?

\end{document}

谢谢!

答案1

您必须进行适当的分组(围绕颜色块),因为\color没有第二个参数(与相反\textcolor)而是充当开关。

\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{amsmath}

\begin{document}

{\color{blue}\begin{align*}
\tau_1 -\frac{1}{2}(\tau_2 + \tau_3) & \in \left( -0.035 -\frac{1}{2}(2.70) 
-\frac{1}{2}(1.99) \pm \sqrt{(3-1)(4.26)} \sqrt{ 0.081 \left( \frac{1^2 +(- 
\frac{1}{2})^2 + (-\frac{1}{2})^2}{4} \right) } \right) \\
\tau_1 -\frac{1}{2}(\tau_2 + \tau_3) & \in \left( -2.38 \pm \sqrt{8.52} 
\sqrt{0.081(0.375)} \right) = \left( -2.38 \pm 2.92 \sqrt{0.30} \right) = 
(-2.38 \pm 1.60)\\
\tau_1 -\frac{1}{2}(\tau_2 + \tau_3) & \in (-3.98, -0.78)
\end{align*}}
I do not want this text to be blue, but it still is blue. Why?

\end{document}

相关内容