我希望方程式着色过程具有一定的语义,即,我仍然可以以普通方式输入方程式或数学,只是它们发生在自动进行着色的环境中,因此:
这:
_1\psi_1 \left[\begin{matrix} a \\ b \end{matrix} ; q,z \right]
= \sum_{n=-\infty}^\infty \frac {(a;q)_n} {(b;q)_n} z^n
= \frac {(b/a,q,q/az,az;q)_\infty }
{(b,b/az,q/a,z;q)_\infty}
结果是这样的:
(来源:玛雷什信息网)
无需到处插入 \color{}有没有可以实现这个功能的包?
答案1
\documentclass{article}
\usepackage[dvipsnames,usenames]{color}
\usepackage{amsmath}
\def\zz#1#2#3{%
\begingroup
\lccode`\~`#1%
\lowercase{\endgroup\edef~}{#2{#3}}%
\mathcode`#1"8000
}
\begin{document}
\zz\a{}{\noexpand\textcolor{red}{\mathchar\the\mathcode`\a}}
\zz\b{}{\noexpand\textcolor{green}{\mathchar\the\mathcode`\b}}
\zz\q{}{\noexpand\textcolor{Mahogany}{\mathchar\the\mathcode`\q}}
\zz\z{}{\noexpand\textcolor{yellow}{\mathchar\the\mathcode`\z}}
\zz\n{}{\noexpand\textcolor{Aquamarine}{\mathchar\the\mathcode`\n}}
\zz\=\mathrel{\noexpand\textcolor{green}{\mathchar\the\mathcode`\=}}
\zz\-\mathbin{\noexpand\textcolor{YellowGreen}{\mathchar\the\mathcode`\-}}
\zz\1{}{\noexpand\textcolor{cyan}{\mathchar\the\mathcode`\1}}
\zz\,\mathpunct{\noexpand\textcolor{Sepia}{\mathchar\the\mathcode`\,}}
\zz\/{}{\noexpand\textcolor{Tan}{\mathchar\the\mathcode`\/}}
\zz\;\mathpunct{\noexpand\textcolor{blue}{\mathchar\the\mathcode`\;}}
\let\oldinfty\infty
\def\infty{{\textcolor{PineGreen}{\oldinfty}}}
\pagecolor{black}
\color{white}
zzz
\begin{equation}
_1\psi_1 \left[\begin{matrix} a \\ b \end{matrix} ; q,z \right]
= \sum_{n=-\infty}^\infty \frac {(a;q)_n} {(b;q)_n} z^n
= \frac {(b/a,q,q/az,az;q)_\infty }
{(b,b/az,q/a,z;q)_\infty}
\end{equation}
\end{document}