# Proper hygiene for macros [duplicate]

I often use \def to define macros in my answers, but it concerns me that these definitions leak out of my answer and can affect the entire page.

The potential problems with this practice began to concern me one day when I was trying to write an answer and MathJax insisted on formatting all my fractions upside-down. Just before I went completely insane, I realized this was because the question I was answering had redefined \frac.

Is there a way to confine my macro definitions to my own post, or to undo my definitions at the end of my post?

• @900 Thanks! I have voted to close. – MJD Aug 10 '14 at 21:18
• Also related: old \def definitions linger – MJD Aug 10 '14 at 21:21