mathjax / MathJax

Beautiful and accessible math in all browsers
http://www.mathjax.org/
Apache License 2.0
10.22k stars 1.16k forks source link

Unable to show `\{` #1832

Closed yxliang01 closed 7 years ago

yxliang01 commented 7 years ago

When using mathjax, \{ is unable to produce {...

Below is the configuration:


MathJax.Hub.Config({
  config: ["MMLorHTML.js"],
  extensions: ["tex2jax.js"],
  jax: ["input/TeX"],
  tex2jax: {
    inlineMath: [ ['$','$'], ["\\(","\\)"] ],
    displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
    processEscapes: false
  },
  TeX: {
    extensions: ["AMSmath.js", "AMSsymbols.js"],
    TagSide: "right",
    TagIndent: ".8em",
    MultLineWidth: "85%",
    equationNumbers: {
      autoNumber: "AMS",
    },
    unicode: {
      fonts: "STIXGeneral,'Arial Unicode MS'"
    }
  },
  showProcessingMessages: false
});

Thanks!

pkra commented 7 years ago

I'm unable to reproduce this.$\{$ works fine for me, e.g., in https://cdn.rawgit.com/mathjax/MathJax/2.7.2/test/sample-dynamic-2.html.

You might want to post a complete example, e.g., using jsbin.

yxliang01 commented 7 years ago

@pkra Thanks for your reply. Hmm, this is weird. When I paste the following line to the test html you posted and change to Mathjax 2.7.1 (https://cdn.rawgit.com/mathjax/MathJax/2.7.1/test/sample-dynamic-2.html), it works fine. Even I fork this repo, and change that test page to my config, it still works fine. This is weird... https://github.com/yxliang01/MathJax/blob/master/test/sample-dynamic-2.html

Formula $ \{C_1, C_2\} $ represents $ C_1 \land C_2 $
yxliang01 commented 7 years ago

You may want to have a look at https://github.com/yxliang01/UnimelbSharedFiles/blob/master/Models%20of%20Computation/MoC-summary.html All \{ and \} don't work...

pkra commented 7 years ago

All \{ and \} don't work...

There's no \{ in the page's HTML source. I'm guessing you're using markdown and the HTML conversion is stripping out backslashes. This is a well known issues with (some) markdown processors; you'll either need to escape the backslash or find out if your markdown processor has other means of protecting TeX input.

FWIW, this problem is documented in http://docs.mathjax.org/en/latest/tex.html#tex-and-latex-in-html-documents.

pkra commented 7 years ago

All \{ and \} don't work...

There's no \{ in the page's HTML source. I'm guessing you're using markdown and the HTML conversion is stripping out backslashes. This is a well known issues with (some) markdown processors; you'll either need to escape the backslash or find out if your markdown processor has other means of protecting TeX input.

FWIW, this problem is documented in http://docs.mathjax.org/en/latest/tex.html#tex-and-latex-in-html-documents.

yxliang01 commented 7 years ago

well-spoted @pkra . However, in the file https://github.com/yxliang01/UnimelbSharedFiles/blob/test-mathjax/Models%20of%20Computation/MoC-summary.html , I added \ to the html source code manually. But, now the formula can't be displayed...

Thanks!

dpvc commented 7 years ago

The only expression including \{ is $ p : D^n \rightarrow \{f, t} $, which is invalid TeX, since the closing brace } has no matching open brace {. Try $ p : D^n \rightarrow \{f, t\} $ instead.

dpvc commented 7 years ago

(Also, the : should be \colon to get the spacing correct, but that is a different issue.)

yxliang01 commented 7 years ago

Oh! @dpvc Right! Thank you all! Problem solved! Very appreciated! :) It's not a bug. So, it comes out to be that, when I was testing the escape thing, I tried to write \\{ in markdown. But then, forgot to change \} to \\}. Therefore, I thought it was a bug.