5
$\begingroup$

My understanding is that \[...\] is preferred to $$...$$ for delimiting displayed equations in latex. See this discussion on tex.stackexhange for the reasons why.

However, math.stackexchange does not seem to support \[ ...\], for example:

[ a^2 + b^2 = c^2 ]

vs $$a^2 + b^2 =c^2.$$

and the semi-official MathJax tutorial thread explicitly says to use $$...$$.

Questions:

  1. Is there a specific reason for using $$...$$ on math.stackexchange?
  2. Does MathJax just not support \[...\] and this would require semi-major back end changes?
  3. Would support for \[...\] be possible to add?
$\endgroup$
14
$\begingroup$

Note that the reasons to prefer \[...\] over $$...$$ for delimited displayed equations in LaTeX do not apply to Mathematics Stack Exchange (or any MathJax-enabled site) for the simple reason that MathJax is not LaTeX. MathJax has a tex2jax preprocessor which goes through your text looking for where LaTeX code is to be processed to be displayed via MathJax.

  1. Note that because of the way certain characters have to be escaped within the Markdown, it may cause more confusion than simply keeping with \[...\]. In Markdown, this may be seen as escaping the [ and ], causing literal [...] in the page source, which would not be recognised by the tex2jax preprocessor. Instead, you'd have to escape the \, meaning typing out \\[ \sin(x) \\], and, surprise surprise:

    \[ \sin(x) \]

    (Check the post source for yourself.)

    So the way that Markdown works may be a reason against using the default \[...\] pairs.

  2. MathJax certainly supports \[...\] for delimiting displayed equations. In fact the tex2jax preprocessor allows for the customisation of inline and display delimiters through the inlineMath and displayMath options. Any delimiter pair used in thedisplayMath option will cause MathJax to display its contents in the exact same way. (This is why those reasons to prefer \[...\] over $$...$$ don't apply here.)

  3. Nearly already done. If you check the source of any page on Mathematics Stack Exchange, and you should find the following:

    <script type="text/x-mathjax-config;executed=true">
      MathJax.Hub.Config({"HTML-CSS": { preferredFont: "TeX", availableFonts: ["STIX","TeX"], linebreaks: { automatic:true }, EqnChunk: (MathJax.Hub.Browser.isMobile ? 10 : 50) },
        tex2jax: { inlineMath: [ ["$", "$"], ["\\\\(","\\\\)"] ], displayMath: [ ["$$","$$"], ["\\[", "\\]"] ], processEscapes: true, ignoreClass: "tex2jax_ignore|dno" },
        TeX: {  noUndefined: { attributes: { mathcolor: "red", mathbackground: "#FFEEEE", mathsize: "90%" } }, Macros: { href: "{}" } },
        messageStyle: "none"
      });
    </script>
    

    So the \\[...\\] pair has explicitly been set up as displayed equation delimiters.

$\endgroup$
  • 2
    $\begingroup$ Aha, thank you! Much easier to suffer through editing almost all of my posts when I type \[ ...\] out of habit from TeX, and knowing that i can always use \\[....\\], which is a much faster edit. Thank you! Bonus for teaching me something in your answer =) $\endgroup$ – erfink Apr 1 '17 at 4:13
  • $\begingroup$ No - one of the main reasons to prefer \[...\] in Latex is better error handling. This applies to Mathjax, too: look what happens to my comment about f(x)$$ if I forget a delimiter when I write $$f(x)$$. $\endgroup$ – Federico Poloni Apr 4 '17 at 17:12
  • $\begingroup$ While with \\[, one sees that f(x)\] this is somewhat better \[f(x)\]. $\endgroup$ – Federico Poloni Apr 4 '17 at 17:14

You must log in to answer this question.

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