It was pointed out earlier today on chat, by Martin Sleziak, that the scope of MathJax new commands changed at some point in the (recent?) past: it was switched for Math SE in January of last year and on this site at some point in the intervening months.

The short of it is that answers now start and end with

<span class="d-none">$\begingroup$</span>


<span class="d-none">$\endgroup$</span>

markup, which scopes any \newcommand and \renewcommand instances to only that post and not the entire thread.

This is Good Thing, and indeed something we've complained about before. However, it does also mean that answers that used commands defined in the question may now be broken, and it'd be good to have a thorough search for them and implement any fixes that may be required.

As such, I'm using a SEDE query, Answered questions with LaTeX \newcommand's , which lists all the relevant questions, in case anyone wants to help me look through them.

  • $\begingroup$ Probably it is worth pointing out that not only answer, but also some comments are broken because of this. (The comments are enclosed in begingroup..endgroup, too.) I have listed some examples from this site in chat. $\endgroup$ – Martin Apr 1 '20 at 13:07
  • $\begingroup$ @Martin All the more reason for visual inspection, then. $\endgroup$ – Emilio Pisanty Apr 1 '20 at 13:10
  • $\begingroup$ That list is begging for a script that checks for what the \newcommand defines in the question and then searches the answers for it, and then (over time, like 1 or 2 per day) automatically edits the answer(s) as needed. Along the lines of the broken-image-link fixing script. Let me see if I can find somebody who has something like that up and running already. $\endgroup$ – tpg2114 Apr 1 '20 at 13:24
  • $\begingroup$ @tpg2114 it's a hundred questions or so. The time spent writing that script is more than it takes to inspect them manually, particularly since the errors are helpfully marked in red by mathjax. $\endgroup$ – Emilio Pisanty Apr 1 '20 at 13:25
  • $\begingroup$ @EmilioPisanty Okay, dealer's choice there. We might have different thresholds for that tradeoff :) $\endgroup$ – tpg2114 Apr 1 '20 at 13:28
  • $\begingroup$ @tpg2114 Well, I just went through all of 2016-2020, whereas on the script route I think I'd only now be beginning to unpack the data-dump xml within Mathematica. $\endgroup$ – Emilio Pisanty Apr 1 '20 at 13:32

OK, I've gone through the list of answered questions. There should be no more broken LaTeX caused by this change on the site, but if you find any more, fix it on sight!

  • $\begingroup$ As discussed in chat, commands can also be defined using \def, \let, \DeclareMathOperator. Here is an example of an answer which uses macro from the question and it wasn't fixed yet: physics.stackexchange.com/questions/389763/… (But maybe the answer to a closed question does not matter that much.) Are there some plans to do something also about comments? (Those can be edited only by mods.) $\endgroup$ – Martin Apr 1 '20 at 14:59
  • 3
    $\begingroup$ This probably goes without saying: +1 for your work on this. $\endgroup$ – Martin Apr 1 '20 at 14:59

You must log in to answer this question.

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