4

I'm trying to write the following equation on math.SE:

(\mathcal L_r \eta)_{\mu_1...\mu_p}=(r+p)\eta_{\mu_1...\mu_n}

However, you will find that if you put this expression between dollar signs, it doesn't format. The expressions before and after the equals sign work separately, but not when put together.

Can someone please explain why this is happening, and how to fix it?

3
  • 4
    It seems to work for me when I try it here: i.stack.imgur.com/suOLA.png - MathJax is disabled on most sites, including this one, for performance reasons. What do you see?
    – Glorfindel Mod
    Feb 28, 2023 at 18:49
  • 1
    It also works for me on Chrome / Win 10: i.stack.imgur.com/gOz3c.png Could it be that your browser is blocking some scripts? Mathjax is a separate script that needs to load and run.
    – rene
    Feb 28, 2023 at 18:50
  • 1
    @Glorfindel So I tried again and used $\_$ instead of$_$ for the subscript, and it works. That's really unusual because I always use $_$ for the subscript. Thanks anyways guys.
    – dennis
    Feb 28, 2023 at 18:54

1 Answer 1

7

MathJax is a fugly hack. And it becomes even fuglier when Markdown interferes with it.

MathJax scans through the entire page looking for text fragments enclosed in dollar signs, without any interspersed formatting markup, and then transforms them into mathematical notation. This works… acceptably (though it performs pretty poorly even then) when you author HTML directly, but less so when there is an intermediate preprocessing stage of Markdown. Which, on Stack Exchange, there is.

Let’s have a look at how your markup renders without MathJax:

$ (\mathcal L_r \eta){\mu_1...\mu_p}=(r+p)\eta{\mu_1...\mu_n} $

Markdown has no awareness of MathJax and its $ delimiters, whether the latter is enabled on a given site or not; $ is just a character like any other. So the later pair of underscore characters _ between the brackets is interpreted as italics formatting like usual. This becomes interspersed formatting markup that breaks up the string and makes it invisible to MathJax.

As a workaround, you can write _ as \_, so that Markdown turns it back into _ in the rendered HTML without any formatting, which MathJax will in turn recognise and interpret as subscript. And do similarly with everything else Markdown may misinterpret: square brackets, asterisks…

As an alternative (but for display math) something I noticed is that you can also suppress Markdown interpretation by inserting an HTML <p> (paragraph) tag at the beginning of the line:

<p> $$ (\mathcal L_r \eta)_{\mu_1...\mu_p}=(r+p)\eta_{\mu_1...\mu_n} $$

$$ (\mathcal L_r \eta)_{\mu_1...\mu_p}=(r+p)\eta_{\mu_1...\mu_n} $$

Of course the real fix would be to make the Markdown renderer aware of MathJax. Make it recognise the $ and $$ delimiters and refrain from interpreting anything between them as formatting markup (and probably wrap it in tags MathJax could look for instead of scraping everything), much like it does with ` and ``. At the very least.

You must log in to answer this question.

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