Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement \neq and \notin via macros like LaTeX's #1400

Merged
merged 3 commits into from
Jun 3, 2018

Conversation

edemaine
Copy link
Member

@edemaine edemaine commented Jun 2, 2018

As discussed in KaTeX/katex-fonts#47 (comment), I simplified LaTeX's definitions of \neq and \notin into KaTeX macros.

They seem visually very close to LaTeX's; here's a texcmp for the tweaked Not test (only third line is new):

image

I assume this will remain true after #1267 but it would be good to test.

This PR removes the need for the \neq and \notin symbols from the fonts, so it would fix KaTeX/katex-fonts#47

The new \neq should be essentially the same as the font-based one. Here is a comparison of the new \notin symbol (top) vs. the old \notin symbol (bottom):

image

@codecov
Copy link

codecov bot commented Jun 2, 2018

Codecov Report

Merging #1400 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1400      +/-   ##
==========================================
+ Coverage   82.33%   82.33%   +<.01%     
==========================================
  Files          77       77              
  Lines        4239     4241       +2     
  Branches      731      731              
==========================================
+ Hits         3490     3492       +2     
  Misses        647      647              
  Partials      102      102
Impacted Files Coverage Δ
src/symbols.js 100% <ø> (ø) ⬆️
src/macros.js 88.28% <100%> (+0.26%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 97d6229...9b8abc7. Read the comment docs.

@kevinbarabash
Copy link
Member

I think this is a move in the right direction. I'm confused though why the slant of the slash is different in \notin in the third line especially if \notin is now defined as \not\in now.

defineMacro("\\neq", "\\not=");
defineMacro("\\ne", "\\neq");
defineMacro("\u2260", "\\neq");
defineMacro("\\notin", "\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the / be a \not? It seems weird to use a different glyph for \notin.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinbarabash If I remember correctly, \notin was created shortly before \not was available.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what LaTeX does; see the definition in comments. I believe it's a conscious decision because the \in glyph is relatively narrow. So I think we should follow suit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They seem visually very close to LaTeX's; here's a texcmp for the tweaked Not test (only third line is new):

SGTM.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...unless there's another LaTeX package that redefines \notin differently? I know AMS doesn't redefine it. I'm on a phone so can't easily check symbols-a4.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a rather large variety of \notin symbols listed in symbols-a4, from packages fdsymbol, stix, txfonts, mathabx, MnSymbol.

image

Not sure what to make of all this. I guess I lean toward matching LaTeX's default behavior, but I'm also happy to design a \not-based macro if that's the preference.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd lean towards LaTeX's default behaviour as well.

@ronkok
Copy link
Collaborator

ronkok commented Jun 3, 2018

For what it's worth, here is the MathML from (1) font-based \notin and (2) macro-based \notin.

<mrow>
  <mo>∉</mo>
</mrow>

<mrow>
  <mstyle>
    <mrow>
      <mo>∈</mo>
    </mrow>
    <mpadded lspace="-1width" width="0px">
      <mrow>
        <mi mathvariant="normal">/</mi>
        <mspace width="0.05555555555555555em"></mspace>
      </mrow>
    </mpadded>
  </mstyle>
</mrow>

@edemaine
Copy link
Member Author

edemaine commented Jun 3, 2018

@ronkok Yes, this is a downside to the macro approach in general. I was thinking we could fix all of these with a \mathml{LaTeX code used for HTML}{MathML equivalent} command.

@ronkok
Copy link
Collaborator

ronkok commented Jun 3, 2018

Now that would be cool.

Copy link
Member

@kevinbarabash kevinbarabash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for posting a texcmp screenshot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

\notin missing metrics, \notin & \neq wrong glyph
3 participants