Recently I had to prepare a simple picture with multiple graphs of functions. For that purpose, I wanted to color each graph of function accordingly to the displayed function itself. Of course, because I listed the functions I used the align environment. Soon the trouble started arising. First, here is a MWE:




\color{blue}f(x) &\color{blue} = x+1 \\
\color{red}g(x) &\color{red} = 4 \\
\color{green}h(x) &\color{green} = -\frac{1}{2}x - 2


The document of course compiles just fine and the output is indeed satisfactory, but since I am dedicated to details I can't help myself but ask: how can I make the color function work over multiple cells? I of course know that the so called "cell", or the alignment symbol & if you will is the source of the problem, since color is only meant for the whole environment or one cell. Any kind of help is much appreciated.

  • a table cell is a tex group, so fonts assignments and everything else is scoped to a group it is possible in some cases to make colors not obey tex grouping but latex goes to a lot of effort to make colors act like fonts and you would have to undo all that. May 21 '17 at 17:36
  • Hm, sounds like a very complex solution, and I'm not very well versed in deconstruction programming. If you have any idea, please share it with me. For now, I don't know how to get a hold of the problem.
    – God bless
    May 21 '17 at 17:58
  • my strong advice would be not to do it: the whole colour setup is designed to make colours obey tex groups May 21 '17 at 18:27
  • You can do it with tikz, it allows math environments inside nodes and you can set node groups that share styles. But don't; You lose what you get from the actual math environment such as equation numbering, easy alignment… It is easier just to copy the \color command to the equation.
    – Huang_d
    May 21 '17 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.