I keep getting surprised of these little yet amazing packages. I just stumbled upon
xspace. Nowadays, I often use commands to abbreviate certain phrases, or make stuff consistent. For instance, after reading this PracTeX article on Productivity with macros and packages I started using commands like
\ie to get my abbrevations straight. And for my bachelor's theses, I am using
\matlab because I'm not yet sure how I want it to be written: small-caps, all caps, only the first letter caps?
When doing this, you'll find yourself adding explicit spaces after the macro, otherwise TeX will just eat the space and put the following text directly next to the macro expansion. But no more so!
xspace solves this, you just put
\xspace at the end of your definition and it will automatically put appropriate spacing. Because not every macro expansion needs to be appended with an explicit space, e.g., at the end of sentences there is no need for this.