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

Support proper notations for math/equations #189

Open
heavywatal opened this issue Aug 31, 2017 · 7 comments
Open

Support proper notations for math/equations #189

heavywatal opened this issue Aug 31, 2017 · 7 comments

Comments

@heavywatal
Copy link

heavywatal commented Aug 31, 2017

Using $$ ... $$ for display-style equations is not recommended in LaTeX. Instead, users are supposed to use the following notations:

  • \[ ... \]
  • \begin{equation*} ... \end{equation*}
  • \begin{equation} ... \end{equation}

They work well with MathJax. So I tried adding them to grammars/repositories/flavors/math-block.cson:

key: 'math-block'
patterns: [
  {
    name: 'block.math.markup.md'
    begin: '\\['
    end: '\\]'
    patterns: [{ include: 'text.tex.latex' }]
    beginCaptures:
      1: name: 'punctuation.md'
    endCaptures:
      1: name: 'punctuation.md'
  }
  {
    name: 'block.math.markup.md'
    begin: '\\begin{equation}'
    end: '\\end{equation}'
    patterns: [{ include: 'text.tex.latex' }]
    beginCaptures:
      1: name: 'punctuation.md'
    endCaptures:
      1: name: 'punctuation.md'
  }
]

After compiling and reloading, Atom recognizes \\[ ... \\] as a math block, but ignores \[ ... \] and \begin{equation} ... \end{equation}. I may be misunderstanding how regex works in Atom.

@burodepeper
Copy link
Owner

Could you add a link to documentation that supports your request?

@heavywatal
Copy link
Author

It is written in the first page of "Short Math Guide for LaTeX" from
http://www.ams.org/publications/authors/tex/amslatex
but their FTP server seems not working now. Here is my copy: short-math-guide.pdf.

Also I found a discussion in Stack Exchange:
https://tex.stackexchange.com/questions/503/why-is-preferable-to

@burodepeper
Copy link
Owner

Thanks!

To get this working, I think you need to escape the { and } in the second pattern as well. If your change doesn't cause any regressions/issues with the other elements of the grammar, please submit this a PR.

@burodepeper
Copy link
Owner

burodepeper commented Aug 31, 2017

begin: '\\begin\{equation\}'
end: '\\end\{equation\}'

@heavywatal
Copy link
Author

Thanks, but it didn't work. Those single backslashes are removed in the compiled language-markdown.json:

        {
          "name": "block.math.markup.md",
          "begin": "\\begin{equation}",
          "end": "\\end{equation}",
          "patterns": [

Double backslashes in cson remain double in the compiled json:

    begin: '\\begin\\{equation\\}'
    end: '\\end\\{equation\\}'

Of course it didn't match \begin{equation} in markdown.

@burodepeper
Copy link
Owner

Let me know if and when you've got it figured out. I'm heading into a meeting now.

@heavywatal
Copy link
Author

Now I understand we need \\\\\\[ for a regex pattern in JSON string to match \[.

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

No branches or pull requests

2 participants