Skip to content

Support the \\not relation command - #280

Merged
Happypig375 merged 6 commits into
masterfrom
feat/issue-233-not-command
Aug 31, 2026
Merged

Support the \\not relation command#280
Happypig375 merged 6 commits into
masterfrom
feat/issue-233-not-command

Conversation

@Happypig375

@Happypig375 Happypig375 commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • support literal and control-word relation targets for \not
  • reject targets that are not exactly one script-free relation with a useful diagnostic
  • use an explicit table for every semantically exact registered negation instead of synthesizing \n... command names
  • prefer Unicode-precomposed negated operators when available and use U+0338 COMBINING LONG SOLIDUS OVERLAY only when no precomposed form exists
  • serialize registered, precomposed-unregistered, scripted, and repeated negations canonically and round-trip them

Semantics and specifications

LaTeX itself does not parse \not as a one-argument command: the kernel declares it as a \mathrel glyph, and defines \neq and \ne as \not=. See the official LaTeX2e kernel definitions of \neq and \ne and \not declaration. The LaTeX2e reference likewise describes \not as a long solidus that overstrikes the following relation.

CSharpMath deliberately differs by consuming one Relation. Within that parser model, rendering follows Unicode Technical Report #25: normalize to a precomposed negated operator whenever one exists, otherwise retain the base relation plus U+0338. Exact registered commands such as \neq, \nleqslant, and \nVdash remain canonical. Refinement relations such as \lneq, \lnapprox, and \subsetneq are not incorrectly inferred as simple negations.

Rendering coverage

Three distinct paths have committed display and inline PNG baselines at 32359727:

Testing

  • full Core suite: 1,583/1,583 passed
  • exhaustive exact-mapping theory: 41/41 passed
  • production glyph-layout structural checks passed
  • SkiaSharp golden rendering suite: 348/348 passed with exact PNG comparisons
  • independent code review: approved with no findings
  • git diff --check passed

Builds on merged #276

Fixes #233

@Happypig375

Happypig375 commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator Author

Resolved in 32359727, with the semantic divergence made explicit.

LaTeX itself declares \not as a relation glyph that overstrikes what follows; it is not a parser prefix that selects a named negation. The kernel even defines \neq and \ne as \not=. Sources: official LaTeX2e kernel definitions, official \not declaration, and the LaTeX2e \not reference.

CSharpMath intentionally keeps its one-Relation parser model, but now applies that deviation consistently:

  • every semantically exact registered negation is selected through an explicit table, including inequalities, precedence, membership, turnstiles, triangles, subsets/supersets, congruence, parallel/mid, and the six arrow pairs
  • command-name synthesis was removed, so refinement symbols such as \lneq, \lnapprox, and \subsetneq cannot be mistaken for simple negations
  • all remaining relations are NFC-normalized after adding U+0338, following Unicode Technical Report #25: use a precomposed operator when one exists and a combining overlay otherwise
  • serialization NFD-decomposes unregistered negations, so both precomposed and combining forms round-trip as \not <relation>

The committed PNG baselines exercise all three rendering paths:

Validation passes 1,583/1,583 Core tests and 348/348 exact SkiaSharp golden comparisons; independent review found no issues.

@Happypig375 Happypig375 added Type/Enhancement A concrete change to CSharpMath behavior or capability. Area/Parsing LaTeX tokenization, parsing, commands, and serialization. Area/Rendering Typesetting, measurement, fonts, text layout, and drawing. labels Aug 30, 2026
@Happypig375
Happypig375 force-pushed the feat/issue-233-not-command branch from 44d461a to 71129b7 Compare August 31, 2026 03:26
@Happypig375
Happypig375 force-pushed the feat/issue-233-not-command branch from f6ac096 to 726320e Compare August 31, 2026 06:44
@Happypig375
Happypig375 changed the base branch from fix/issue-182-control-word-boundary to master August 31, 2026 06:45
@Happypig375
Happypig375 merged commit d7782fd into master Aug 31, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area/Parsing LaTeX tokenization, parsing, commands, and serialization. Area/Rendering Typesetting, measurement, fonts, text layout, and drawing. Type/Enhancement A concrete change to CSharpMath behavior or capability.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support the \not negation command

2 participants