fix(desktop): convert \slashed to \not for KaTeX compatibility#3750
Merged
Conversation
KaTeX doesn't support the \\slashed command from the LaTeX 'slashed'
package, which is commonly used in physics for Feynman slash notation
(\\slashed{p}, \\slashed{\\partial}).
Convert \\slashed{X} to \\not{X} before passing to KaTeX. The \\not
command provides a similar visual effect (a slash through the character)
and is supported by KaTeX.
This prevents KaTeX parse errors when the model emits physics notation
using \\slashed.
Tests: 3 new cases added, 111/111 passing
…psilon(0)
The previous fix only handled \\\\slashed{X} (braced form). User-reported
issue: \\\\slashed\\\\epsilon(0) (Greek letter + function call, no braces)
was not being converted and still showed as red KaTeX error.
Extended the regex to handle two additional forms:
- \\\\slashed X → \\\\not X (single letter, no braces)
- \\\\slashed\\\\epsilon → \\\\not{\\\\epsilon} (backslash command)
- \\\\slashed\\\\epsilon(0) → \\\\not{\\\\epsilon(0)} (backslash command + function)
- \\\\slashed a → \\\\not a (single ASCII letter)
This covers the common physics notation \\\\slashed{p} where the model
sometimes forgets the braces around the argument.
Tests: 2 new cases added, 113/113 math-golden passing.
795aa40 to
524b633
Compare
esengine
approved these changes
Jun 10, 2026
esengine
left a comment
Owner
There was a problem hiding this comment.
Thanks @lightfront — clean, well-scoped fix.
\slashed is a real gap (KaTeX ships no slashed package), and routing it to \not is the right approximation for Feynman slash notation. Since it runs inside latexNormalizeForKatex, the rewrite only touches recognized math spans — code blocks and prose are untouched — and the golden tests cover both the braced and unbraced forms. CI is green across the board.
One tiny thing I'll tidy in a follow-up (not blocking): a couple of the braced test inputs use a double backslash (\slashed{p}) where real model output is a single one (\slashed{p}); the regex handles both, so the tests pass either way. Merging now — appreciate the contribution!
esengine
added a commit
that referenced
this pull request
Jun 10, 2026
#3761) The \slashed -> \not cases (#3750) wrote their braced inputs with a double backslash (\slashed{p}); real model output is a single one. The regex matched either way so the tests passed, but they exercised a form the model never emits. Switch them to single-backslash inputs and the eq() helper the surrounding golden tests already use. Co-authored-by: reasonix <reasonix@deepseek.com>
SuMuxi66
pushed a commit
to SuMuxi66/DeepSeek-Reasonix
that referenced
this pull request
Jun 10, 2026
…ine#3750) * fix(desktop): convert \\slashed to \\not for KaTeX compatibility KaTeX doesn't support the \\slashed command from the LaTeX 'slashed' package, which is commonly used in physics for Feynman slash notation (\\slashed{p}, \\slashed{\\partial}). Convert \\slashed{X} to \\not{X} before passing to KaTeX. The \\not command provides a similar visual effect (a slash through the character) and is supported by KaTeX. This prevents KaTeX parse errors when the model emits physics notation using \\slashed. Tests: 3 new cases added, 111/111 passing * fix(desktop): handle unbraced \\\\slashed forms like \\\\slashed\\\\epsilon(0) The previous fix only handled \\\\slashed{X} (braced form). User-reported issue: \\\\slashed\\\\epsilon(0) (Greek letter + function call, no braces) was not being converted and still showed as red KaTeX error. Extended the regex to handle two additional forms: - \\\\slashed X → \\\\not X (single letter, no braces) - \\\\slashed\\\\epsilon → \\\\not{\\\\epsilon} (backslash command) - \\\\slashed\\\\epsilon(0) → \\\\not{\\\\epsilon(0)} (backslash command + function) - \\\\slashed a → \\\\not a (single ASCII letter) This covers the common physics notation \\\\slashed{p} where the model sometimes forgets the braces around the argument. Tests: 2 new cases added, 113/113 math-golden passing. --------- Co-authored-by: Xingbo Zhao <xbzhao@impcas.ac.cn>
SuMuxi66
pushed a commit
to SuMuxi66/DeepSeek-Reasonix
that referenced
this pull request
Jun 10, 2026
esengine#3761) The \slashed -> \not cases (esengine#3750) wrote their braced inputs with a double backslash (\slashed{p}); real model output is a single one. The regex matched either way so the tests passed, but they exercised a form the model never emits. Switch them to single-backslash inputs and the eq() helper the surrounding golden tests already use. Co-authored-by: reasonix <reasonix@deepseek.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Convert \slashed to \not for KaTeX compatibility
Problem
KaTeX doesn't support the
\slashedcommand from the LaTeX 'slashed' package, which is commonly used in physics for Feynman slash notation (\slashed{p},\slashed{\partial}).When the model emits these commands, Reasonix shows raw LaTeX source as red error text instead of rendering the formula.
Solution
Convert
\slashed{X}to\not{X}inlatexNormalizeForKatex. The\notcommand provides a similar visual effect (a slash through the character) and is supported by KaTeX.Example:
$\slashed{p}$$\not{p}$Changes
desktop/frontend/src/components/latexNormalize.ts: Added regex conversiondesktop/frontend/src/__tests__/math-golden.test.ts: Added 3 test casesTests
\slashedconversionRelated