我试图给方程式(尤其是内联方程式)上色,以便它们从其余文本中脱颖而出,因此使用了\everymath{}
和\everydisplay{}
命令,但这似乎也会影响表格。但文本不受影响。知道为什么会发生这种情况或如何解决它吗?
\documentclass{article}
\usepackage{xcolor}
\everymath{\color{teal}}
\everydisplay{\color{magenta}}
\begin{document}
Some text.
Some text.
Some text.
Some text.
$x=\int_{-\infty}^{\infty}\frac{\sin}{x}\mathrm{d}x=\frac{\pi}{2}$
Some text.
Some text.
Some text.
Some text.
\[
x=\int_{-\infty}^{\infty}\frac{\sin}{x}\mathrm{d}x=\frac{\pi}{2}
\]
\begin{table}[!h] % also colored?
\centering
\begin{tabular}{ll}
\hline
Animal & Legs \\
\hline
Dogs & 4 \\
Human & 1 \\
\hline
\end{tabular}
\end{table}
\end{document}
答案1
\documentclass{article}
\usepackage{xcolor}
\everymath{\color{teal}}
\everydisplay{\color{magenta}}
%%%%%%%%%%%%%
\makeatletter
\def\m@th{\mathsurround\z@\color{black}}
\makeatother
%%%%%%%%%%%%%
\begin{document}
Some text.
Some text.
Some text.
Some text.
$x=\int_{-\infty}^{\infty}\frac{\sin}{x}\mathrm{d}x=\frac{\pi}{2}$
Some text.
Some text.
Some text.
Some text.
\[
x=\int_{-\infty}^{\infty}\frac{\sin}{x}\mathrm{d}x=\frac{\pi}{2}
\]
\begin{table}[!h] % also colored?
\centering
\begin{tabular}{ll}
\hline
Animal & Legs \\
\hline
Dogs & 4 \\
Human & 1 \\
\hline
\end{tabular}
\end{table}
\end{document}