10

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:
(source: maresh.info)

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. – jub0bs 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 05 '14 at 19:33
  • Ah yes, http://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Synesthesia.svg/250px-Synesthesia.svg.png I stand corrected. – John Kormylo Mar 05 '14 at 19:42
  • 1
    I am not ready to publish my project, yet, but I enclose a teaser for now. :-) http://striz7.fame.utb.cz/docasne/tex-sx/mal-math.pdf – Malipivo Mar 24 '15 at 07:48
  • This looks a bit like what I was trying to achieve in https://tex.stackexchange.com/q/335/86 – Andrew Stacey May 04 '17 at 19:38

1 Answers1

3

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}
David Carlisle
  • 757,742