globalGroup adversely affects \color and tall right delimiters
See original GitHub issuePR #2091 has an unintended consequence. When the rendering option globalGroup is set to true, then \color escapes its group and affects tall right delimiters.
The KaTeX function\color works by creating a macro \current@color and assigning a color to it. When globalGroup is true, then this macro escapes its group. Tall right delimiters are then given that color in line https://github.com/KaTeX/KaTeX/blob/21c4bc355c04cfa13bb79dd9dd06627f5b04f54d/src/functions/delimsizing.js#L155. I don’t know why tall right delimiters get that treatment, but there it is.
The stated reason for PR #2091 was to give global scope to \newcommand. But its effect is more sweeping than that. I think that @edemaine’s comment was correct. We need some mechanism that gives global scope to \newcommand, not to all macros.
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (7 by maintainers)

Top Related StackOverflow Question
It will actually be an issue for any top level
\def, not just color. You probably already realize that, but I want it clearly stated.Please cast an eye over PR #2640. It’s intent is to restore local scope to any
\def, regardless of KaTeX settings.\newcommandcan still persist between calls to KaTeX, which accomplishes the original goal forglobalScope.I’ll mention one other thing. I think it is valuable to maintain a distinction between
\defand\gdefregardless of what happens to right delimiters.\defshould not be global.