12
$\begingroup$

MathJax supports possibility do define macros. (Using \newcommand, \DeclareMathOperator, \def, etc.) They are certainly useful, however sometimes they can cause minor problems - for example clash of macros defined differently in two different posts. Therefore it is recommended to enclose them within \begingroup .. \endgroup. Now the Stack Exchange software encloses each post/comment in \begingroup .. \endgroup.

This was changed relatively recently. (In the past this was not done automatically - so the posts contained \begingroup .. \endgroup only if it was included manually by the poster or editors.) Here is copy of the relevant part from Recent feature changes to Stack Exchange:

2019-01-14: On sites with MathJax enabled, the effect of \newcommand and similar directives is now scoped to individual posts and comments rather than the entire page. (Bug report on Math.SE's meta)

One side effect of this change: In the past some users might have posted answers relying on macros defined in the question or comments relying on macros defined in posts. In such cases, the macros will no longer be rendered correctly. (Although they were working fine at the time of the posting.) The question is what to do with such posts and comments.

  • I suppose that for posts the answer is simply to edit such posts - with the usual caveat that we should avoid bumping many old posts at the same time.
  • However, comments can only be edited by mods. (Possibly in some cases the poster would be able to delete comment and post a new one without disturbing the flow of the conversation - but if the comment is mid-conversation this would not be ideal.) Should we simply flag such comments and ask the moderators to edit?

I certainly do not want to cause flood of flags for the moderators. But I will assume that there will not be too many such comments, so most likely this will not be a major problem. But still it would be good to have confirmation whether flagging is the way to do.

EDIT: Of course, there might be even cases when the comments cannot be fixed - in the cases when the edit (either expanding the macro or including the definition directly into the comment) would lead to number of characters above the allowed length of a comment.


I will add at least on example illustrating this problem - this answer (and a snapshot from Wayback Machine). I have also included a screenshot below. And here is also an example of a comment with this problem (Wayback Machine) - again I have added also a screenshot below.

You can find also further examples in this chatroom, if you search for mathoverlow, mathoverflow.net or the messages tagged mathoverflow.

EDIT: One of the commenters asks how many comments/posts were affected by the change. I do not have an easy way how to find all content affected by this. As you can see in the chatroom I linked to, I searched for some specific common names (\Spec, \Hom, \Ext, \norm), etc. I was able to find some examples but not many of them. (Most what I found is listed in today's chat transcript. Of course, feel free to use the linked chatroom if you have additional suggestions how to search for such posts.)

I was surprised that I found several posts and comments where somebody used a macro which wasn't defined anywhere on the page. In the other words, the macros are not rendered, but it was not caused by the recent change described here - it was a mistake made already when posting. (I was surprised mainly because I expect a typical MO user to have some experience with LaTeX. But I have also made many mistakes in my comments and posts which I would have noticed if I checked them more carefully right after posting - so such things do happen.)

Screenshot of a post:

Screenshot

Screenshot of a comment:

Screenshot

$\endgroup$
15
  • 1
    $\begingroup$ For the examples you give, I see the possibility where the macro names are better than the symbols they might define for communication, so I would leave those alone. In general, I would use this post as a place to list problem examples for which a strong argument for change should be made. If there are a lot of such, then we can consider automated editing or even editing. Gerhard "Prefers Clarity Over Font Choice" Paseman, 2019.01.30. $\endgroup$ Commented Jan 30, 2019 at 15:57
  • 2
    $\begingroup$ @GerhardPaseman Just to make this more clear, the way this post/comment is displayed now is different from what the OP intended - since the macros worked at the time of the posting. (Before the question was enclosed in a separate begingroup..endgroup.) $\endgroup$ Commented Jan 30, 2019 at 16:07
  • 2
    $\begingroup$ Yes, and in some cases the intent of the original poster is clear enough that someone can make changes respecting that intent. Most of the time we can at best guess. My point is that, except for extreme cases, we should not even guess or edit. Let the original poster change it or request change. Gerhard "Sometimes Inaction Is The Best" Paseman, 2019.01.30. $\endgroup$ Commented Jan 30, 2019 at 16:46
  • 5
    $\begingroup$ @GerhardPaseman Actually, your comment seems to me as an argument in favor of editing. You say that we should respect the posters' intent - and the intention was very likely for the post to look the way it looked after it was posted (i.e., with the macros rendered), not influenced by later changes in the software. $\endgroup$ Commented Jan 30, 2019 at 16:51
  • $\begingroup$ Perhaps. If the intent was to use the macros as a convenience and the side effect of the changes improves the clarity of the communication, it might also be the posters intent to preserve the current rendering. In your last comment, you are guessing at the posters intent. (I am also guessing.) Even though you may be right, you also assume that we can reconstruct the original presentation. I do not assume that. I assume that if it matters to the poster, they will ask. They will benefit from seeing this meta post. Gerhard "Thanks For Presenting The Issue" Paseman, 2019.01.30. $\endgroup$ Commented Jan 30, 2019 at 17:04
  • $\begingroup$ How many posts have you seen affected by this change? I suppose I'm suspicious that so long as users are only passively editing such posts or flagging comments as they come across them, there won't be a flood of flags to mods' inboxes, or of bumped questions to the front page. $\endgroup$ Commented Jan 31, 2019 at 23:18
  • 4
    $\begingroup$ @GerhardPaseman It would be a bit tougher, but an editor could find the place on the page where the \newcommand macro is defined (it's gotta be somewhere on the page, right?), and just copy the definition of that macro into the post where the errors are occurring. This would preserve the author's original rendering without guesswork. I can't imagine a user of one of these affected posts wanting their post to have red-highlighted errors rendered in it, although you are correct that that's only an assumption. $\endgroup$ Commented Jan 31, 2019 at 23:27
  • $\begingroup$ @MikePierce I do not know how many such posts and comment are there in total - since I cannot think of an easy how to search for all instances of this problem. The examples from MathOverflow that I have found so far are listed in chat - there is not too many of them. (On Mathematics you can find more such cases - some of them have already been edited. But that it very natural, considering that MO is about 10-times smaller.) $\endgroup$ Commented Feb 1, 2019 at 12:27
  • 2
    $\begingroup$ One possibility would be to put \endgroup just before the definitions and \begingroup right after, which would make the definitions global again (unless SE has modified the begingroup extension to prevent that). I suspect some will not like this idea, as it circumvents the intent of using begingroup, but it would help reduce the number of posts that need to be modified. Then again, it might be something that SE disables in the future, and we'd be back at this point again. Just a thought. $\endgroup$ Commented Feb 1, 2019 at 14:21
  • 2
    $\begingroup$ @DavideCervone If I understand your solution correctly, it would need some edits anyway - I think that it's better to make edits which are less likely to break things in the future. (Although I understand that some advantage to this would be that editing comments would not be needed.) $\endgroup$ Commented Feb 1, 2019 at 14:55
  • $\begingroup$ @MartinSleziak, yes, there are still some edits needed, but fewer than if you had to copy global definitions to all answers and comments that needed them. And, as you say, that could avoid the problems inherent in editing comments. $\endgroup$ Commented Feb 1, 2019 at 15:53
  • $\begingroup$ @DavideCervone One additional problem with using the workaround suggested in your comments is that it might be seen as intentionally disrupting the intended usage of MathJax and potentially lead to some problems. Quote of a SE employee: "The only way this'd happen is from someone trying to mess with the page and I'm okay with leaving that up to being edited out and the user potentially being suspended if they keep at it. " $\endgroup$ Commented Apr 12, 2019 at 15:32
  • $\begingroup$ It seems that on Physics, the posts with this problem have been mostly edited, see: The scope of \newcommand changed. $\endgroup$ Commented Apr 2, 2020 at 14:01
  • $\begingroup$ There's a typo in "mathoverlow" (I can't suggest an edit to fix it). $\endgroup$
    – joriki
    Commented Apr 15, 2020 at 12:40
  • $\begingroup$ @joriki Thanks for letting me know - I'll try not to forget to correct it if this thread is bumped for some other reason. $\endgroup$ Commented Apr 15, 2020 at 12:47

1 Answer 1

3
$\begingroup$

This is a community wiki answer intended as a place to collect examples of posts and comments which are examples of the described problem. Feel free to add further examples if you find some more. (But let's restrict this to examples where the problem was caused by the recent software change described in the question - not those posts/comments where the poster simply made a mistake used a macro that wasn't defined anywhere.)

This answer is posted partially as a response to the comments asking how many "problematic" posts and comments are there. (Of course, without some systematic way to search for them, the list is very likely to be incomplete.)

Answers

$\endgroup$
3
  • $\begingroup$ I have mentioned already in the question this chatroom. You can see there how I searched for these examples - and the same room can be used for any discussions related to this issue. $\endgroup$ Commented Feb 7, 2019 at 13:44
  • 2
    $\begingroup$ BTW when trying to find these examples, I was a bit surprised to see that many people often use macros (perhaps out of habit) without noticing that the macro is undefined and it does not render in the comment (or in the post). $\endgroup$ Commented Feb 7, 2019 at 14:30
  • $\begingroup$ Some examples of posts broken by this change are listed also here in chat: Examples from MathOverflow 1 and [Examples from MathOverflow 2. $\endgroup$ Commented Feb 13, 2020 at 1:09

You must log in to answer this question.

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