%From asnd@erich.triumf.ca Sun Nov 15 02:54:04 1992
%Date: Sat, 14 Nov 1992 23:57:39 PST
%From: Donald Arseneau <asnd@erich.triumf.ca>
%===============================================================
% When get \em starting italic text, launch an italic correction aimed at
% the end of the group. When \em ends the italic, do a smart italic correction.
%
% (If used as a macro, add \makeatletter, etc (rags))
% \makeatletter
 
\let\@tempb\relax % strange bug in *Old* LaTeX
\@ifundefined{normalshape}{%
  \def\pem{\ifdim \fontdimen\@ne\font>\z@ \rm
    \else \it \expandafter\aftergroup \fi \smartitcor}%
}{%
  \def\pem{\@nomath\em \ifdim \fontdimen\@ne\font >\z@ \normalshape
    \else \it \expandafter\aftergroup \fi \smartitcor}%
}
 
\def\smartitcor{\ifhmode \expandafter \itpunclook \fi}
\def\itpunclook{\begingroup \futurelet \@tempa \itcortest}
 
\def\itcortest{\def\@tempb{\@tempa}%
\ifcat\noexpand\@tempa,% if next character could be punctuation,
   \setbox\z@\hbox{\@tempb}% check its size...
   \ifdim\ht\z@<.3ex % and if it is short,...
      \let\itcordo\endgroup % suppress italic correction
\fi\fi
\itcordo}
 
\def\itcordo{% Put \/ before any preceding space.
  \skip@\lastskip
  \ifdim\skip@=\z@skip \/\else\unskip \/\hskip\skip@ \fi
  \endgroup}
 
% Older version commented out:
% \def\pem{\ifdim \fontdimen\@ne\font>\z@ \rm
%   \else \it \expandafter\aftergroup \fi \smartitcor}
%
% \def\smartitcor{\ifhmode \expandafter \itpunclook \fi}
% \def\itpunclook{\futurelet \@tempa \itcortest}
%
% \def\itcortest{\begingroup
% \ifcat\noexpand\@tempa.% if next character could be punctuation,
%    \setbox\z@\hbox{\@tempa}% check its size...
%    \ifdim\ht\z@<.3ex % and if it is short,...
%       \let\itcordo\endgroup % suppress italic correction
% \fi\fi
% \itcordo}
%
% \def\itcordo{% Put \/ before any preceding space.
%   \skip@\lastskip
%   \ifdim\skip@=\z@skip \/\else\unskip \/\hskip\skip@ \fi
%   \endgroup}
%
% \makeatother
