# A specific confusing MathJax syntax that works randomly or not

Today I ran into the specific MahJax problem for which I cannot find the cause.

Interestingly, if this Mathjax syntax somehow works in the Q&A area, it definitely doesn't work in the comment section. (I tried many times)

Now one more interesting problem than that is that the MathJax syntax I mentioned works "completely randomly" without my intervention, or it doesn't work. The only thing I can do is refresh the page $$10-15$$ times.

As soon as the specific Mathjax syntax I mentioned runs, if the page is refreshed, unfortunately syntaxis won't work again.

Here is the MathJax syntax that "randomly works or doesn't work":

$$\cancel{\Longleftrightarrow}$$

Well here it didn't work either...

Here are the images I took:

What is the source of the problem? I am not a computer user.

• (Not an answer, but your post is a good example for this question.) – vitamin d Mar 26 at 1:31
• Not an answer but perhaps you are interested in \nLeftrightarrow$\nLeftrightarrow$ and \nRightarrow$\nRightarrow$ – Calvin Khor Mar 27 at 5:45
• @CalvinKhor also $$\not\Longleftrightarrow$$ but seems not very good... – lone student Mar 27 at 5:46

You need to add $\require{cancel}$ to your post to be able to use it, $\require{cancel}\cancel\Longleftrightarrow$ will produce $$\require{cancel}\cancel\Longleftrightarrow$$.

• (+1)So how can you explain if it works randomly?with my syntax – lone student Mar 25 at 14:20
• It might loaded on some pages? – Asaf Karagila Mar 25 at 14:21
• Important thing, we fixed the problem. But I would like to know why this syntaxis is different. Very interesting. – lone student Mar 25 at 14:24
• @lonestudent it's an extension of MathJax, not the basic package. In some circumstances it may still be available due to use elsewhere on the page (although my understanding is that the scope of MathJax extensions and definitions is meant to be limited to the applicable block). – Joffan Mar 26 at 23:51
• I wonder whether the presence of \require{cancel} in one posting on a page can cause the \cancel{} command to work in other postings on the same page. – Michael Hardy Mar 28 at 4:09

$$\def\niff{\iff\kern-1.75em/\kern1.25em}$$ This method, using the \cancel macro from the package cancel, seems not to render the cancel stroke in the correct colour. Does that package always render the stroke in black? At any rate, it is practically invisible on a black background, and its only effect is to obliterate some of the symbol it is meant to be cancelling.

I instead suggest \iff\kern-1.75em/\kern1.25em within a MathJax expression. That bit of MathJax is rather bulky if you want to typeset that symbol more than once, so you could define a MathJax token for it, for example by $\def\niff{\iff\kern-1.75em/\kern1.25em}$. You may then write $P\niff Q$ for $$P\niff Q$$ or $1\niff2$ for $$1\niff2$$.

(Earlier, in this question, I had based my definition of \niff on \Longleftrightarrow as that had already been mentioned in this question. But a comment by Calvin Khor to this answer to another question on a similar subject pointed out two advantages of \iff over \Longleftrightarrow: appropriate spacing and a name which suits what the symbol means. I accordingly use \iff.

Just as a check to see if the spacing looks right: the next line below uses \iff and the line below it uses my \niff defined above.

$$\begin{gather} P\iff Q\\ P\niff Q \end{gather}$$

• Doesn't look very good to me. The slash should be in the middle of the arrow, but I'm seeing it way over at the left end instead. – Gerry Myerson Mar 28 at 21:40
• @GerryMyerson I see you're right -- trying it in TeX and magnifying x4 showed that I was about .05em off. – Rosie F Mar 29 at 5:23
• I'm still seeing it way over to the left. – Gerry Myerson Mar 29 at 5:50
• What's a macro? – user71207 Mar 30 at 11:40

Testing @MichaelHardy's question about whether \require{cancel} in one post enables it in others. I assume it's present in @AsafKaragila's post, since it uses the macro successfully, but I'm not sure how to view the source (I usually pretend to suggest an edit and then cancel it, but that doesn't work here).

PRE: I assume that the answer is that "no, it doesn't", since the invocation in the parent post doesn't work.

$$\cancel\Leftrightarrow$$

POST: Looks like I was wrong! There's no \require{cancel} here, but it works. So why doesn't it work in the parent post?

• The order of how things are rendered may matter - Asaf's answer is displayed above yours because it is the accepted answer, which means the MathJax parser encounters \require{cancel} before the \cancel in your post. On the other hand, the parent post doesn't have a \require{cancel}. There have been similar issues in the past, but I thought they were solved by this adjustment in 2019. – KReiser Mar 30 at 20:59