2
$\begingroup$

I noticed the problem in this post in the definition of $\mathbb N_\infty= \{0\} \cup \{\frac1n; n\in\mathbb N\}$. However, I was not able to reproduce the problem from the post (I do not know why there was need of two backlashes in that post.) However, as I noticed using, if LaTeX-code follows the text without any space then sometimes left and right braces are not displayed correctly.

Is this a bug?

Examples:

Here everything works fine (I do not know why) - I will post the example of that behavior in a separate answer.

$\{ 0 \} \cup \{ \frac{1}{n} | n \in \mathbb{N} \}$

abc$\\{ 0 \\} \cup \\{ \frac{1}{n} | n \in \mathbb{N} \\}$

abc$\{ 0 \} \cup \{ \frac{1}{n} | n \in \mathbb{N} \}$

EDIT: Now I am confused - while editing, in the preview everything was displayed correctly, but not after posting.

EDIT 2: Adding (part of) a screenshot:

Screenshot

EDIT 3: After reading this: http://meta.math.stackexchange.com/questions/2330/mathjax-bug-with-braces-and-parenthesis I checked the post again, and it seems that the problem was caused by parenthesis.

The post I linked to originally contained the following:

(it is homeomorphic to $\{ 0 \} \cup \{ \frac{1}{n} | n \in \mathbb{N} \}$)

(it is homeomorphic to $\{ 0 \} \cup \{ \frac{1}{n} | n \in \mathbb{N} \}$)

$\endgroup$
3

4 Answers 4

5
$\begingroup$

The best bet is always to have some "obvious space" between math and non-math; Willie Wong's answer explains very well why some issues are unavoidable.

However, it should be clear even in the preview that something is broken, so you can fix it immediately, and not be surprised only after submitting the post. There were some inconsistencies here between the preview and the final rendered version; these should be fixed in the next build of the site.

While still not everything may look as expected, at least you'll notice this instantly.

$\endgroup$
9
$\begingroup$

The backslash \ is often used in various computer-related contexts as the escape operator (which is also how it is used in LaTeX). Unfortunately posts here at Math.SE goes through two layers of parsing: first by MarkDown, and second by MathJax, and both languages use the backslash for "escaping".

(For example, if you type \*a\* this is what shows up: "*a*". But if you type *a* you get "a".)

This means that sometimes the expression \{ gets first parsed by MarkDown, which strips the (what it thinks as useless) escape character to retain {, which then gets passed to MathJax...

This problem was "solved" a while back by the SE team by adding some regexp magic into the MarkDown code to treat texts between dollar signs $...$ as protected in the same way "code" between backticks ` is protected from the MarkDown parser. Hence for the most part the "double backslash" hack is no longer necessary.

Unfortunately (again), since there are valid uses of dollar signs other than as MathJax delimiters (such as marking a dollar amount), it is not so simple to detect when to protect the MathJax code and when not to protect the non-MathJax uses of $. What you observed is you hitting against an edge case that the algorithm incorrectly determined as non-MathJax.

The simplest solution is: stop doing what you know is not working, and stick to using what works.

The cleanest solution would be for MarkDown to be extended to officially incorporate MathJax, so that to get a simple dollar sign one would need to type, a la LaTeX, \$, and then we can treat all dollar signs as delimiters for mathematics expressions. (Good luck explaining that to other SE users.)

Anything less will be hacks and will occasionally run into false positive/negatives. And we'll have to just have to live with it.

$\endgroup$
2
  • $\begingroup$ Thanks a lot. I haven't heard about MarkDown before, so this explained quite a lot for me. The only question that remains is why it behaves differently in preview and in the post, but this is perhaps not that important. I'll keep in mind that such a problems can appear when posting anything. $\endgroup$ Commented Nov 4, 2011 at 14:48
  • 1
    $\begingroup$ I like your approach of "If it's broken and you can't fix it, use something else." :-) $\endgroup$
    – Asaf Karagila Mod
    Commented Nov 4, 2011 at 14:55
1
$\begingroup$

$\{0\}\cup\{\frac 1{2k+1}; k\in\mathbb N\}$

abc$\{ 0 \} \cup \{ \frac{1}{n} | n \in \mathbb{N} \}$

abc${ 0 } \cup { \frac{1}{n} | n \in \mathbb{N} }$

Obtained by:

$\{0\}\cup\{\frac 1{2k+1}; k\in\mathbb N\}$

abc$\\{ 0 \\} \cup \\{ \frac{1}{n} | n \in \mathbb{N} \\}$

abc$\{ 0 \} \cup \{ \frac{1}{n} | n \in \mathbb{N} \}$

This answer was posted merely to show the problem with LaTeX rendering. In this case the problem appeared already in preview during the editing.

$\endgroup$
1
$\begingroup$

Note that sometimes text parenthesis may interfere with curly braces. (For example if the dollar sign is right next to the parenthesis, like here ${x\mid x={x}}$).

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .