Post History
#3: Post edited
- The problem lies in a conflict between the Markdown and MathJax parsers. The Markdown parser runs first[^1] and uses \\ as an escape character, and so `\\` becomes a single backslash. The MathJax parser then only sees that single backslash, which means it won't create the newline.
- This also breaks some other formulations, for example, sets:
- ```
- $\{1,2,3\}$
- ```
- Expected result: $\\{1,2,3\\}$
- Actual result: $\{1,2,3\}$
- The Markdown parser turns `\{` into a literal `{`.
- A list of backslash-escaped characters can be found [here](https://github.github.com/gfm/#backslash-escapes).
- There are two ways to get around this problem.
- Firstly, you can wrap the code in HTML tags. This will prevent the Markdown renderer from parsing the inside of it. Taking the earlier example, we would type
- ```
- <p>$\{1,2,3\}$</p>
- ```
- which turns into
- <p>$\{1,2,3\}$</p>
- You could also escape your backslashes if it comes before a markdown escape character. This method is more annoying, however, as it will break compatibility with pure LaTeX.
- The previous example would be written as either `\\{1,2,3\\}` (escaping the backslash) or `\\\{1,2,3\\\}` (escaping both the backslash and braces), and a newline would be written as `\\\\`.
- (You can use `\\\` if the character following it isn't a Markdown escape character)
- [^1]: Technically, the Markdown parser runs server side and gives the parsed document to the client, which runs MathJax on it, but all that matters here is the order.
- ## Tl;dr, Markdown and LaTeX don't like each other
- The problem lies in a conflict between the Markdown and MathJax parsers. The Markdown parser runs first[^1] and uses \\ as an escape character, and so `\\` becomes a single backslash. The MathJax parser then only sees that single backslash, which means it won't create the newline.
- This also breaks some other formulations, for example, sets:
- ```
- $\{1,2,3\}$
- ```
- Expected result: $\\{1,2,3\\}$
- Actual result: $\{1,2,3\}$
- The Markdown parser turns `\{` into a literal `{`.
- A list of backslash-escaped characters can be found [here](https://github.github.com/gfm/#backslash-escapes).
- ## Workarounds
- There are two ways to get around this problem.
- Firstly, you can wrap the code in HTML tags. This will prevent the Markdown renderer from parsing the inside of it. Taking the earlier example, we would type
- ```
- <p>$\{1,2,3\}$</p>
- ```
- which turns into
- <p>$\{1,2,3\}$</p>
- You could also escape your backslashes if it comes before a markdown escape character. This method is more annoying, however, as it will break compatibility with pure LaTeX.
- The previous example would be written as either `\\{1,2,3\\}` (escaping the backslash) or `\\\{1,2,3\\\}` (escaping both the backslash and braces), and a newline would be written as `\\\\`.
- (You can use `\\\` if the character following it isn't a Markdown escape character)
- ## Note: [MathJax 3 has issues with `\\`](https://github.com/mathjax/MathJax/issues/2312)
- If the above doesn't work, then it might be a problem with MathJax. Try using the `\displaylines` environment (Note: it uses three backslashes instead of two, or you can use `\cr`)
- ```
- <p>$$\displaylines{123 \\\ 321}$$</p>
- ```
- or
- ```
- <p>$$\displaylines{123 \cr 321}$$</p>
- ```
- will give you
- <p>$$\displaylines{123 \cr 321}$$</p>
- [^1]: Technically, the Markdown parser runs server side and gives the parsed document to the client, which runs MathJax on it, but all that matters here is the order.
#2: Post edited
- The problem lies in a conflict between the Markdown and MathJax parsers. The Markdown parser runs first[^1] and uses \\ as an escape character, and so `\\` becomes a single backslash. The MathJax parser then only sees that single backslash, which means it won't create the newline.
- This also breaks some other formulations, for example, sets:
- ```
- $\{1,2,3\}$
- ```
- Expected result: $\\{1,2,3\\}$
- Actual result: $\{1,2,3\}$
- The Markdown parser turns `\{` into a literal `{`.
- A list of backslash-escaped characters can be found [here](https://github.github.com/gfm/#backslash-escapes).
To get around this problem, you must escape your backslashes if it comes before a markdown escape character. Thus, the previous set example must be written as either `\\{1,2,3\\}` (escaping the backslash) or `\\\{1,2,3\\\}` (escaping both the backslash and braces)A newline must be written as- ```
\\\\- ```
- (You can use `\\\` if the character following it isn't a Markdown escape character)
- [^1]: Technically, the Markdown parser runs server side and gives the parsed document to the client, which runs MathJax on it, but all that matters here is the order.
- The problem lies in a conflict between the Markdown and MathJax parsers. The Markdown parser runs first[^1] and uses \\ as an escape character, and so `\\` becomes a single backslash. The MathJax parser then only sees that single backslash, which means it won't create the newline.
- This also breaks some other formulations, for example, sets:
- ```
- $\{1,2,3\}$
- ```
- Expected result: $\\{1,2,3\\}$
- Actual result: $\{1,2,3\}$
- The Markdown parser turns `\{` into a literal `{`.
- A list of backslash-escaped characters can be found [here](https://github.github.com/gfm/#backslash-escapes).
- There are two ways to get around this problem.
- Firstly, you can wrap the code in HTML tags. This will prevent the Markdown renderer from parsing the inside of it. Taking the earlier example, we would type
- ```
- <p>$\{1,2,3\}$</p>
- ```
- which turns into
- <p>$\{1,2,3\}$</p>
- You could also escape your backslashes if it comes before a markdown escape character. This method is more annoying, however, as it will break compatibility with pure LaTeX.
- The previous example would be written as either `\\{1,2,3\\}` (escaping the backslash) or `\\\{1,2,3\\\}` (escaping both the backslash and braces), and a newline would be written as `\\\\`.
- (You can use `\\\` if the character following it isn't a Markdown escape character)
- [^1]: Technically, the Markdown parser runs server side and gives the parsed document to the client, which runs MathJax on it, but all that matters here is the order.
#1: Initial revision
The problem lies in a conflict between the Markdown and MathJax parsers. The Markdown parser runs first[^1] and uses \\ as an escape character, and so `\\` becomes a single backslash. The MathJax parser then only sees that single backslash, which means it won't create the newline. This also breaks some other formulations, for example, sets: ``` $\{1,2,3\}$ ``` Expected result: $\\{1,2,3\\}$ Actual result: $\{1,2,3\}$ The Markdown parser turns `\{` into a literal `{`. A list of backslash-escaped characters can be found [here](https://github.github.com/gfm/#backslash-escapes). To get around this problem, you must escape your backslashes if it comes before a markdown escape character. Thus, the previous set example must be written as either `\\{1,2,3\\}` (escaping the backslash) or `\\\{1,2,3\\\}` (escaping both the backslash and braces) A newline must be written as ``` \\\\ ``` (You can use `\\\` if the character following it isn't a Markdown escape character) [^1]: Technically, the Markdown parser runs server side and gives the parsed document to the client, which runs MathJax on it, but all that matters here is the order.