Macros for common abbreviations

I think the \eg and \ie macros should be defined differently to \etc, because they will never be at the end of a sentence. You can simply use \@\xspace at the end to ensure a space with the correct width if one is required. For \etc you can use \@ifnextchar{.}{<yes>}{<no>} to check for a following full stop.

\documentclass{article}

\usepackage{xspace}
\newcommand*{\eg}{e.g.\@\xspace}
\newcommand*{\ie}{i.e.\@\xspace}

\makeatletter
\newcommand*{\etc}{%
    \@ifnextchar{.}%
        {etc}%
        {etc.\@\xspace}%
}
\makeatother

\begin{document}
\noindent
You should eat more fruit, \eg apples, bananas, oranges, \etc. Next sentence.

\noindent
You should eat more fruit, \eg, apples, bananas, oranges, \etc but also tomatoes.

\end{document}

Phil Ratcliffe has recently posted to CTAN two packages to deal with this question:

  • xpunctuate “provides the commands \xperiod, \xcomma and \xperiodcomma, which follow a similar procedure to that of \xspace, and insert punctuation if and only if it is necessary,” and
  • foreign which, among other things, uses the commands from xpunctuate to define \eg and \ie as the OP requests.

These commands attempt to correctly handle sentence spacing via a simple convention, better illustrated than described:

  • The forest is filled with lions, tigers, bears, \etc.” becomes
    The forest is filled with lions, tigers, bears, {\em etc}.
  • The forest is filled with lions, tigers, bears, \etc!” becomes
    The forest is filled with lions, tigers, bears, {\em etc}.!
  • Lions, tigers, bears, \etc fill the forest.” becomes
    Lions, tigers, bears, {\em etc}.\@ fill the forest.

(Actually, the font selection is a bit more complicated than I’ve shown.)

There’s even code that inserts a comma after mid-sentence \ie & \eg. (This comma can be disabled via the [UKenglish] option.)