I'd like to have the equation colorization process be somewhat semantic, i.e., I can still type equations or math the ordinary way, except they occur in an environment in which the colorization happens automatically, so:

this:

_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}

would result in things like this: http://owen.maresh.info/color_quations.png

without having to insert \color{} everywhere Is there a package which already does this?

  • 2
    Automating that seems difficult. What you should do is define macros (specifying the style, colour) for your variables and use those macros throughout your derivation. – jubobs Feb 19 '14 at 15:51
  • Isn't this a symptom of sensory aphasia? – John Kormylo Feb 20 '14 at 18:34
  • @JohnKormylo: you're looking for synaesthesia. q-hypergeometric function identities mostly look like wallpaper -- see /Gasper & M. Rahman Basic Hypergeometric Series/ for instance and it is really difficult to follow what's going on. Color makes it easier, and I'd prefer to have an automatic mechanism for producing colorization. – Owen Maresh Mar 5 '14 at 19:33
  • Ah yes, upload.wikimedia.org/wikipedia/commons/thumb/6/60/… I stand corrected. – John Kormylo Mar 5 '14 at 19:42
  • 1
    I am not ready to publish my project, yet, but I enclose a teaser for now. :-) striz7.fame.utb.cz/docasne/tex-sx/mal-math.pdf – Malipivo Mar 24 '15 at 7:48

enter image description here

\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}

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.