Basically, I would like to something like \xspace does, i.e. the meaning of the macro should depend on what is following it. So for example if I say
\mymacro a
it might expand to foo, and if any other character is following, it should expand to bar. In my specific case I'll try to match a unicode character, if that makes a difference.
Edit: Specifically, I want to influence the spacing after an integral. When it stands alone, the default spacing is fine. If it is the first of multiple integrals, the space became too wide. Here is what I cobbled together from the previous answer:
\newcommand\timeintegral[1]{
∫_{t_0}^{t_1} \if ∫#1 \!\!\! \fi #1
}
This is how it looks in use:
\timeintegral E \, dt = \timeintegral ∫_z ∫_φ f \, dφ dz dt


pdflatexit's different than withxelatexorlualatex. Knowledge of the character is needed; also a “real world” use case would be nice. – egreg Mar 26 '14 at 18:16pdflatexand tested for a Unicode character beyond the ASCII block. – egreg Mar 26 '14 at 18:36\ifis only going to test a byte. There are other tests that could capture it, I'm sure, but I'm not too keen on unicode testing. If the answer works for you, I'll leave it. If not, or if someone gives a better answer, I'll delete mine. – Steven B. Segletes Mar 26 '14 at 19:11