I'm sure this is a pretty standard questions that's been asked (and answered!) a hundered times before, so apologies for boring people.
In LaTeX, I'd like to write a macro for abbreviations, such as, "e.g." or "i.e." but I'd like LaTeX to get the spacing after the trailing dot right: sometimes I enclose the "e.g." in commas and sometimes I don't, depending on the document I'm writing:
A lot of fruits contain vitamin C, e.g., lemons and oranges. To practice a sport like e.g. rugby, a good level of fitness is adviced.
(Please let's not discuss whether this use of commas is correct or not.)
How can I write a macro
\eg that gets the spacing right automatically for both cases?