sympy/sympy — pull request #8386 by mstimberg (2014-11-05 16:07:04+00:00)
Title: Fix invalid latex output for all-uppercase greek letter symbol names

Symbol names such as TAU (but also taU, TaU, etc.) led to invalid latex output. All symbol names corresponding to a greek letter will now always use the lower case version, upper case names such as Tau or Gamma are explicitly mapped.

The code previously only checked whether `s.lower()` was a greek letter and then used `'\' + s` as the LaTeX output. This made it possible to automatically support `Gamma` --> `\Gamma` etc. without explicitly handling them (`Tau` -> `T`, etc. were explicitly handled). Unfortunately, this also led to invalid LaTeX code when using for example `TAU` (not unthinkable for a constant) and -- surely less common -- mixed case names such as `TaU`. With this pull request, all capitalized greek letter names (`Gamma`, `Tau`, etc.) are handled explicitly in `tex_greek_dictionary` and all other names (`TAU`, `gaMMA`, etc.) are treated like the lowercase versions. More complicated solutions are certainly possible (e.g. treat everything that starts with an uppercase letter as an uppercase greek letter) but I'm not sure it is worth the effort. The most important thing to me is to never generate invalid LaTeX output.

The second commit adds a test that all the uppercase greek letters are handled explicitly in `tex_greek_dictionary` -- I'm not sure about this test, though, since it tests the internal implementation that might change at some point.