Katex: \operatorname doesn't support all math functions

Created on 21 Jan 2018  路  5Comments  路  Source: KaTeX/KaTeX

\operatorname{x\pi\frac{1}{2}}

is valid LaTeX, but KaTeX throws the following exception:

undefined is not an object (evaluating 'n.replace')
bug

All 5 comments

Just as a clarification, I'll point out that the x and \pi parts of that argument work fine. It's the \frac{1}{2} that causes the error.

With the current version of KaTeX, \operatorname{x\pi\frac{1}{2}} throws no errors for me besides the "no character metrics" error.

I noticed that \operatorname{\sum} doesn't work right now, though it is valid LaTeX. Setting acceptUnicodeChar = true for \sum in its defineSymbol() invocation at line 654 of symbols.js, and enforcing math mode (solely to accommodate \sum in this test case) in the htmlBuilder of operatorname.js allows \operatorname{\sum} to render. What is the reason for not setting acceptUnicodeChar = true by default?

What is the reason for not setting acceptUnicodeChar = true [on \sum] by default?

@leungbk, When we were implementing Unicode support, I included the big operators by writing them in the defineFunction section of file ops.js. I felt that this gave someone reading the code a more direct way to see the connection to operator symbol re-sizing, \limits, etc.

It may be that we could do both that and also set the acceptUnicodeChar flag in symbols.js.

@ronkok #1461 closes this, right? Please re-open if there's any additional work necessary.

Yes, I closes all the use cases that I can think of.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

janosh picture janosh  路  4Comments

oddhack picture oddhack  路  3Comments

sophiebits picture sophiebits  路  3Comments

pyramation picture pyramation  路  4Comments

q2apro picture q2apro  路  3Comments