Conversation started Jan 28, 2019 at 7:49.
Jan 28, 2019 07:49
There were recently two posts on meta about problems which can be caused by newcommand/DeclareMathOperator/def in the title.
Typically when such posts appears among linked or related questions.
5
A: A possible bug regarding MathJax, previews, and the arctangent/tangent functions?

Trevor GunnA linked question contained some malicious code in the title. I've removed it.

6
Q: MathJax rendering in preview but not in actual post?

Monstrous MoonshinerSo I just passed the 2,000 rep threshold this morning and, eager to try out my newfound powers of automatic editing, I went ahead and looked for the first post I could find that could use some prettying up. I quickly found a post that was well written but had some funky-looking italic math format...

Perhaps a warning not to do this should be included in Guidelines for good use of $\rm\LaTeX$ in question titles.
Oh, I see it already is there:
5
A: Guidelines for good use of $\rm\LaTeX$ in question titles

Asaf KaragilaI think that we should also forbid \newcommand on the title. Sure, if done right there's no harm in this, but this can be a huge slippery slope for either small mistakes that accumulate to ravage the front page, or worse.

Anyway, we should probably edit out occurrences of newcommand and DeclareMathOperator in the titles.
Searching for \def using built-in search does not work well: math.stackexchange.com/search?q=title%3A%5Cdef But we should be able to find such posts using SEDE: data.stackexchange.com/math/query/972169/…
Possibly when editing such posts we could include the newcommand into begingroup...\endgroup as explained here: The scope of \newcommand is the entire page.
@quid I remember that you have used Is this true: $\DeclareMathOperator{\Hom}{Hom}\Hom_R(S,R) \otimes_S P \cong \Hom_R(P,R)$? for testing purposes (in connection with one of the questions above).
I guess further tests are no longer needed - so it would be ok to edit this away from that question too.
I hope I'll find some time to start doing such edits later this week. The searches I linked above suggest that it's about 50 questions. (Well, unless I missed some other command that causes problem - apart from \newcommand, \DeclareMathOperator and \def.)
Ok, I'll have to leave now, but I hope I'll find some time to look into this later.
I agree that this should be edited away. Another question would be if we should report it as a "missing case" now that it is fixed for most other thngs (posts and comments)
See you!
I don't really know what you mean by "fixed for posts and comments".
AFAICT if a post or commend contains newcommand without begingroup..endgroup that can still cause some problems.
replied to a message: View original message
@MartinSleziak math.meta.stackexchange.com/a/29621 I thought that's automatic since recently.
Jan 28, 2019 08:03
11
A: The scope of \newcommand is the entire page

Adam LearIt pains me to break this thread by fixing the issue, but here we are. :) We are now inserting \begingroup and \endgroup directives into post and comment bodies, so all command definitions should be scoped to individual posts. For now, I'm only enabling this on Math (and here on meta), but barr...

Oh, I completely missed that. This change is very recent.
A possible solution for titles would be to use begingroup/engroup also there. Another possibility is to forbid/blacklist \newcommand (and relatives) in the titles.
BTW the answer you linked already has a comment mentioning the recent issue:
It seems that the issue isn't completely fixed. See math.meta.stackexchange.com/q/29702/18398Joel Reyes Noche 4 hours ago
Yes I just realized that.
To add a bit more to detail to @Joel's comment: a newcommand in titles can still cause issues. This is especially a problem when a title containing a newcommand appears in "linked" and "related." This can create rather confusing situations. — quid ♦ 14 secs ago
I added some more explanation.
 
Conversation ended Jan 28, 2019 at 8:12.