22
$\begingroup$

A little over 4 years go I discovered that MathJax supports the $\LaTeX$ command \newcommand, and started to use it in my own answers and questions: this makes certain repetitive things so much easier to write.

In the meantime I've done this in 171 answers, 4 questions, and 11 comments.

(As a side note, currently I'm mostly using these for making it easy to write proofs and calculations in a 'calculational style'; see, e.g., EWD1300. A gist which I use as a template is here.)

However, I've recently discovered that \newcommand is not without its disadvantages: its scope is the rest of the math.se page on which it occurs. This means that my posts could be affecting other people's answers and comments.

I'd like to fix this.

There is a simple way to fix this, as explained in this answer to the above question and elsewhere: surround such posts with $\require{begingroup}\begingroup$ ... $\endgroup$

(My first example can be seen in the source of this answer of mine.)

And I'm perfectly willing to go through all of the above posts, and apply this fix.

However, a disadvantage is that all these posts will suddenly jump to the top of the 'active' lists, for no good reason. That's probably considered bad form. (And there is no way to indicate 'trivial edits', or is there?)

Another disadvantage is that occasionally people have used a \newcommand of mine in a comment on that post. So using begingroup would make those start to fail.

Finally, the actual chance of having a conflict is low, except in those cases where I've used something like \newcommand{\equiv}{\Leftrightarrow} to redefine a predefined MathJax command. So going back applying this fix might not be worth it.

So my question is: Should I fix this?

$\endgroup$
10
  • 1
    $\begingroup$ Related: When is it ok to use \newcommand and \DeclareMathOperator? $\endgroup$ Aug 8, 2017 at 19:04
  • 2
    $\begingroup$ I mean, if you'd like to fix it, don't let us stop you. $\endgroup$ Aug 8, 2017 at 21:58
  • 10
    $\begingroup$ Actually, no, don't fix it, meaning don't fix it all rapidly, in a short period of time; that's an awfully large number of posts, that if edited within too short of a period of time, could risk an unwelcome reception. Maybe edit once-a-day edit, over the long haul...editing would be fine. But doing so in abundance, in the short term, would be very annoying, and perhaps even suspect. $\endgroup$
    – amWhy
    Aug 8, 2017 at 23:38
  • 3
    $\begingroup$ I think you should use a practical approach. You already mentioned that tha chance of having a conflict is low. So I think you could identify the pages where there is a possible conflict because you redefined a predefined MathJax command. For this pages you check if there is actually a conflict. If so, you should edit it otherwise you can ignore it (of there are many) because the chance that there will be added new answer that will have a conflict is rather low. $\endgroup$
    – miracle173
    Aug 9, 2017 at 12:37
  • 6
    $\begingroup$ Another alternative: only fix it if you discover that it affects other answers that have been given. Sure, in theory it's possible to happen on any of the posts, but in reality it will probably never come to be a problem in most of them. And I second the advice amWhy gave above about not doing them wholesale all at once, in any case. $\endgroup$
    – rschwieb
    Aug 9, 2017 at 13:02
  • $\begingroup$ My general advice: edit at most three dormant posts per day. Of course for any of those posts which you edit for some other reason, you should do this edit at the same time. $\endgroup$
    – GEdgar
    Aug 9, 2017 at 13:18
  • 2
    $\begingroup$ The main reason I suggested "No, don't fix it" (too rapidly) is largely due to the fact that no one should do too much editing in too short of time, given that each and every edit of a question or of an answer triggers it's reappearance at the top of the "active questions" board, ust as you've noted. I've yet to see a complaint from anyone, any user to the effect that they have been "adversely" affected in your use of "\newcommand". Perhaps, you're "making a mountain out of a mole hill." However, Kudos to you, for asking on meta about your options, and being open to suggestions. $\endgroup$
    – amWhy
    Aug 9, 2017 at 17:04
  • 4
    $\begingroup$ Props for asking!!! I also suggest that you keep the bursts of edits short. Take your time :-) $\endgroup$ Aug 9, 2017 at 20:14
  • $\begingroup$ Why not replace all \newcommand s with \providecommand ? $\endgroup$
    – MCCCS
    Aug 15, 2017 at 13:18
  • $\begingroup$ You can ask SE to edit the post for you, if you can offer a programatic solution. $\endgroup$
    – Braiam
    Aug 22, 2017 at 18:56

1 Answer 1

10
$\begingroup$

In my opinion, the obvious solution would be to gradually edit all and only those posts where you have redefined a predefined LaTeX-MathJax command. The reasons are as follows:

  1. If anyone wants to submit a new answer they might not understand why their LaTeX is not working. Worse still, it is possible that their accidental use of your redefined command might cause their page to crash, making them lose their work.

  2. The only reason anyone would need to use a non-predefined new command that clashes with your definition is that they want to define it. In that case they would almost surely define it at the start of their answer, so your definition would not affect them.

  3. There is a possibility that someone would think that a command existed and used it, and it so happens to work because of your definition. In this case it is also unnecessary to edit your post and not good to do so unless you also edit theirs.

  4. As pointed out by others, gradually editing the problematic posts will not push them all to the front page at once. Also, I doubt there are many of your posts that actually redefine predefined commands, so it should not take that long.

$\endgroup$

You must log in to answer this question.

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